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(STRINGTOKENIZER_HEADER_GUARD_1357924680) 00019 #define STRINGTOKENIZER_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 00030 00031 00032 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00033 00034 00035 00036 XALAN_CPP_NAMESPACE_BEGIN 00037 00038 00039 00040 class XALAN_PLATFORMSUPPORT_EXPORT StringTokenizer 00041 { 00042 public: 00043 00044 static const XalanDOMChar s_defaultTokens[]; 00045 00046 typedef size_t size_type; 00047 00048 /** 00049 * Constructs a tokenizer for the target string. No copies of any input 00050 * strings are made. 00051 * 00052 * @param theString string to tokenize 00053 * @param theTokens string of delimiters used to parse target, default 00054 * is " \t\n\r" 00055 * @param fReturnTokens if true, delimiter characters are also returned 00056 * as tokens, default is false 00057 */ 00058 StringTokenizer(const XalanDOMString& theString, 00059 const XalanDOMString& theTokens, 00060 bool fReturnTokens = false); 00061 00062 /** 00063 * Constructs a tokenizer for the target string. No copies of any input 00064 * strings are made. 00065 * 00066 * @param theString string to tokenize 00067 * @param theTokens string of delimiters used to parse target, default 00068 * is " \t\n\r" 00069 * @param fReturnTokens if true, delimiter characters are also returned 00070 * as tokens, default is false 00071 */ 00072 StringTokenizer(const XalanDOMString& theString, 00073 const XalanDOMChar* theTokens = s_defaultTokens, 00074 bool fReturnTokens = false); 00075 00076 /** 00077 * Constructs a tokenizer for the target string. No copies of any input 00078 * strings are made. 00079 * 00080 * @param theString string to tokenize 00081 * @param theTokens string of delimiters used to parse target. 00082 * @param fReturnTokens if true, delimiter characters are also returned 00083 * as tokens, default is false 00084 */ 00085 StringTokenizer(const XalanDOMChar* theString, 00086 const XalanDOMChar* theTokens = s_defaultTokens, 00087 bool fReturnTokens = false); 00088 00089 /** 00090 * Constructs a tokenizer for the target string. No copies of any input 00091 * strings are made. 00092 * 00093 * @param theString string to tokenize 00094 * @param theTokens string of delimiters used to parse target. 00095 * @param fReturnTokens if true, delimiter characters are also returned 00096 * as tokens, default is false 00097 */ 00098 StringTokenizer(const XalanDOMChar* theString, 00099 const XalanDOMString& theTokens, 00100 bool fReturnTokens = false); 00101 00102 ~StringTokenizer(); 00103 00104 /** 00105 * Determine if there are tokens remaining 00106 * 00107 * @return true if there are more tokens 00108 */ 00109 bool 00110 hasMoreTokens() const; 00111 00112 00113 /** 00114 * Retrieve the next token to be parsed; behavior is undefined if there are 00115 * no more tokens 00116 * 00117 * @param theToken next token string 00118 */ 00119 void 00120 nextToken(XalanDOMString& theToken); 00121 00122 /** 00123 * Count the number of tokens yet to be parsed 00124 * 00125 * @return number of remaining tokens 00126 */ 00127 size_type 00128 countTokens() const; 00129 00130 void 00131 reset() 00132 { 00133 m_currentIndex = 0; 00134 } 00135 00136 protected: 00137 00138 XalanDOMString::size_type 00139 FindNextDelimiterIndex(XalanDOMString::size_type theStartIndex) const; 00140 00141 private: 00142 00143 // These are not implemented... 00144 StringTokenizer(const StringTokenizer&); 00145 00146 StringTokenizer& 00147 operator=(const StringTokenizer&); 00148 00149 bool 00150 operator==(const StringTokenizer&) const; 00151 00152 00153 // Data members... 00154 const XalanDOMChar* const m_string; 00155 00156 const XalanDOMChar* const m_tokens; 00157 00158 const bool m_returnTokens; 00159 00160 XalanDOMString::size_type m_currentIndex; 00161 00162 const XalanDOMString::size_type m_stringLength; 00163 00164 const XalanDOMString::size_type m_tokensLength; 00165 }; 00166 00167 00168 00169 XALAN_CPP_NAMESPACE_END 00170 00171 00172 00173 #endif // STRINGTOKENIZER_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 |
|