00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XTOKEN_HEADER_GUARD_1357924680) 00019 #define XTOKEN_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base header file. Must be first. 00024 #include <xalanc/XPath/XPathDefinitions.hpp> 00025 00026 00027 00028 // Base class... 00029 #include <xalanc/XPath/XObject.hpp> 00030 00031 00032 00033 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00034 00035 00036 00037 XALAN_CPP_NAMESPACE_BEGIN 00038 00039 00040 00041 class XALAN_XPATH_EXPORT XToken : public XObject 00042 { 00043 public: 00044 00045 /** 00046 * Create an XToken. 00047 * 00048 * @param theMemoryManager The MemoryManager instance. 00049 */ 00050 XToken(MemoryManager& theMemoryManager); 00051 00052 /** 00053 * Create an XToken for string in the token queue. 00054 * 00055 * @param theString The string data for the token. The instance will keep a point to this string, so it must be persistent. 00056 * @param theNumber The numeric data for the token. This must be consistent with the lexical value in theString. 00057 * @param theMemoryManager The MemoryManager instance. 00058 */ 00059 XToken( 00060 const XalanDOMString& theString, 00061 double theNumber, 00062 MemoryManager& theMemoryManager); 00063 00064 /** 00065 * Create an XToken for number in the token queue. 00066 * 00067 * @param theNumber The numeric data for the token. This must be consistent with the lexical value in theString. 00068 * @param theString The string data for the token. The instance will keep a point to this string, so it must be persistent. 00069 * @param theMemoryManager The MemoryManager instance. 00070 */ 00071 XToken( 00072 double theNumber, 00073 const XalanDOMString& theString, 00074 MemoryManager& theMemoryManager); 00075 00076 /** 00077 * Create an XToken from another one. 00078 * 00079 * In most cases, the following copy constructor, 00080 * which accepts an explicit MemoryManager instance, 00081 * is recommended. 00082 * 00083 * @param theSource The source XToken instance. 00084 */ 00085 XToken(const XToken& theSource); 00086 00087 /** 00088 * Create an XToken from another one. 00089 * 00090 * @param theSource The source XToken instance. 00091 * @param theMemoryManager The MemoryManager instance. 00092 */ 00093 XToken( 00094 const XToken& theSource, 00095 MemoryManager& theMemoryManager); 00096 00097 virtual 00098 ~XToken(); 00099 00100 virtual const XalanDOMString& 00101 getTypeString() const; 00102 00103 virtual double 00104 num(XPathExecutionContext& executionContext) const; 00105 00106 virtual bool 00107 boolean(XPathExecutionContext& executionContext) const; 00108 00109 virtual const XalanDOMString& 00110 str(XPathExecutionContext& executionContext) const; 00111 00112 virtual const XalanDOMString& 00113 str() const; 00114 00115 virtual void 00116 str( 00117 XPathExecutionContext& executionContext, 00118 FormatterListener& formatterListener, 00119 MemberFunctionPtr function) const; 00120 00121 virtual void 00122 str( 00123 FormatterListener& formatterListener, 00124 MemberFunctionPtr function) const; 00125 00126 virtual void 00127 str( 00128 XPathExecutionContext& executionContext, 00129 XalanDOMString& theBuffer) const; 00130 00131 virtual void 00132 str(XalanDOMString& theBuffer) const; 00133 00134 virtual double 00135 stringLength(XPathExecutionContext& executionContext) const; 00136 00137 virtual void 00138 ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject); 00139 00140 virtual void 00141 ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const; 00142 00143 XToken& 00144 operator=(const XToken& theRHS) 00145 { 00146 m_stringValue = theRHS.m_stringValue; 00147 00148 m_numberValue = theRHS.m_numberValue; 00149 00150 return *this; 00151 } 00152 00153 bool 00154 boolean() const 00155 { 00156 assert(m_stringValue != 0); 00157 00158 return m_isString == true ? XObject::boolean(*m_stringValue) : XObject::boolean(m_numberValue); 00159 } 00160 00161 double 00162 num() const 00163 { 00164 assert(m_stringValue != 0); 00165 00166 return m_numberValue; 00167 } 00168 00169 double 00170 stringLength() const 00171 { 00172 assert(m_stringValue != 0); 00173 00174 return static_cast<double>(m_stringValue->length()); 00175 } 00176 00177 /** 00178 * Set the instance as a string in the token queue. 00179 * 00180 * @param theString The string data for the token. XToken will keep a point to this string, so it must be persistent. 00181 * @param theNumber The numeric data for the token. This must be consistent with the lexical value in theString. 00182 */ 00183 void 00184 set( 00185 const XalanDOMString& theString, 00186 double theNumber); 00187 00188 /** 00189 * Set the instance as a number in the token queue. 00190 * 00191 * @param theNumber The numeric data for the token. This must be consistent with the lexical value in theString. 00192 * @param theString The string data for the token. XToken will keep a point to this string, so it must be persistent. 00193 */ 00194 void 00195 set( 00196 double theNumber, 00197 const XalanDOMString& theString); 00198 00199 protected: 00200 00201 virtual void 00202 referenced(); 00203 00204 virtual void 00205 dereferenced(); 00206 00207 private: 00208 00209 // Not defined... 00210 bool 00211 operator==(const XToken&) const; 00212 00213 // Data members... 00214 const XalanDOMString* m_stringValue; 00215 00216 double m_numberValue; 00217 00218 bool m_isString; 00219 }; 00220 00221 00222 00223 XALAN_USES_MEMORY_MANAGER(XToken) 00224 00225 00226 00227 XALAN_CPP_NAMESPACE_END 00228 00229 00230 00231 #endif // XTOKEN_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|