Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:02

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_TOKEN_HPP)
0023 #define XERCESC_INCLUDE_GUARD_TOKEN_HPP
0024 
0025 // ---------------------------------------------------------------------------
0026 //  Includes
0027 // ---------------------------------------------------------------------------
0028 #include <xercesc/util/RuntimeException.hpp>
0029 #include <xercesc/util/PlatformUtils.hpp>
0030 
0031 XERCES_CPP_NAMESPACE_BEGIN
0032 
0033 // ---------------------------------------------------------------------------
0034 //  Forward Declaration
0035 // ---------------------------------------------------------------------------
0036 class RangeToken;
0037 class TokenFactory;
0038 
0039 
0040 class XMLUTIL_EXPORT Token : public XMemory
0041 {
0042 public:
0043     // -----------------------------------------------------------------------
0044     //  Public Constants
0045     // -----------------------------------------------------------------------
0046     // Token types
0047     typedef enum {
0048         T_CHAR = 0,
0049         T_CONCAT = 1,
0050         T_UNION = 2,
0051         T_CLOSURE = 3,
0052         T_RANGE = 4,
0053         T_NRANGE = 5,
0054         T_PAREN = 6,
0055         T_EMPTY = 7,
0056         T_ANCHOR = 8,
0057         T_NONGREEDYCLOSURE = 9,
0058         T_STRING = 10,
0059         T_DOT = 11,
0060         T_BACKREFERENCE = 12
0061     } tokType;
0062 
0063     // -----------------------------------------------------------------------
0064     //  Public Constructors and Destructor
0065     // -----------------------------------------------------------------------
0066     Token(const tokType tkType
0067         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0068         );
0069     virtual ~Token();
0070 
0071     static const XMLInt32        UTF16_MAX;
0072 
0073     typedef enum {
0074         FC_CONTINUE = 0,
0075         FC_TERMINAL = 1,
0076         FC_ANY = 2
0077     } firstCharacterOptions;
0078 
0079     // -----------------------------------------------------------------------
0080     //  Getter methods
0081     // -----------------------------------------------------------------------
0082     tokType              getTokenType() const;
0083     XMLSize_t            getMinLength() const;
0084     int                  getMaxLength() const;
0085     virtual Token*       getChild(const XMLSize_t index) const;
0086     virtual XMLSize_t    size() const;
0087     virtual int          getMin() const;
0088     virtual int          getMax() const;
0089     virtual int          getNoParen() const;
0090     virtual int          getReferenceNo() const;
0091     virtual const XMLCh* getString() const;
0092     virtual XMLInt32     getChar() const;
0093 
0094     // -----------------------------------------------------------------------
0095     //  Setter methods
0096     // -----------------------------------------------------------------------
0097     void setTokenType(const tokType tokType);
0098     virtual void setMin(const int minVal);
0099     virtual void setMax(const int maxVal);
0100 
0101     // -----------------------------------------------------------------------
0102     //  Range manipulation methods
0103     // -----------------------------------------------------------------------
0104     virtual void addRange(const XMLInt32 start, const XMLInt32 end);
0105     virtual void mergeRanges(const Token *const tok);
0106     virtual void sortRanges();
0107     virtual void compactRanges();
0108     virtual void subtractRanges(RangeToken* const tok);
0109     virtual void intersectRanges(RangeToken* const tok);
0110 
0111     // -----------------------------------------------------------------------
0112     //  Putter methods
0113     // -----------------------------------------------------------------------
0114     virtual void addChild(Token* const child, TokenFactory* const tokFactory);
0115 
0116     // -----------------------------------------------------------------------
0117     //  Helper methods
0118     // -----------------------------------------------------------------------
0119     firstCharacterOptions analyzeFirstCharacter(RangeToken* const rangeTok, const int options,
0120                                                 TokenFactory* const tokFactory);
0121     Token* findFixedString(int options, int& outOptions);
0122 
0123 private:
0124     // -----------------------------------------------------------------------
0125     //  Unimplemented constructors and operators
0126     // -----------------------------------------------------------------------
0127     Token(const Token&);
0128     Token& operator=(const Token&);
0129 
0130     // -----------------------------------------------------------------------
0131     //  Private Helper methods
0132     // -----------------------------------------------------------------------
0133     bool isSet(const int options, const unsigned int flag);
0134     bool isShorterThan(Token* const tok);
0135 
0136     // -----------------------------------------------------------------------
0137     //  Private data members
0138     // -----------------------------------------------------------------------
0139     tokType fTokenType;
0140 protected:
0141     MemoryManager* const    fMemoryManager;
0142 };
0143 
0144 
0145 // ---------------------------------------------------------------------------
0146 //  Token: getter methods
0147 // ---------------------------------------------------------------------------
0148 inline Token::tokType Token::getTokenType() const {
0149 
0150     return fTokenType;
0151 }
0152 
0153 inline XMLSize_t Token::size() const {
0154 
0155     return 0;
0156 }
0157 
0158 inline Token* Token::getChild(const XMLSize_t) const {
0159 
0160     return 0;
0161 }
0162 
0163 inline int Token::getMin() const {
0164 
0165     return -1;
0166 }
0167 
0168 inline int Token::getMax() const {
0169 
0170     return -1;
0171 }
0172 
0173 inline int Token::getReferenceNo() const {
0174 
0175     return 0;
0176 }
0177 
0178 inline int Token::getNoParen() const {
0179 
0180     return 0;
0181 }
0182 
0183 inline const XMLCh* Token::getString() const {
0184 
0185     return 0;
0186 }
0187 
0188 inline XMLInt32 Token::getChar() const {
0189 
0190     return -1;
0191 }
0192 
0193 // ---------------------------------------------------------------------------
0194 //  Token: setter methods
0195 // ---------------------------------------------------------------------------
0196 inline void Token::setTokenType(const Token::tokType tokType) {
0197     
0198     fTokenType = tokType;
0199 }
0200 
0201 inline void Token::setMax(const int) {
0202     // ClosureToken
0203 }
0204 
0205 inline void Token::setMin(const int) {
0206     // ClosureToken
0207 }
0208 
0209 inline bool Token::isSet(const int options, const unsigned int flag) {
0210 
0211     return (options & flag) == flag;
0212 }
0213 
0214 // ---------------------------------------------------------------------------
0215 //  Token: setter methods
0216 // ---------------------------------------------------------------------------
0217 inline void Token::addChild(Token* const, TokenFactory* const) {
0218 
0219     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0220 }
0221 
0222 // ---------------------------------------------------------------------------
0223 //  Token: Range manipulation methods
0224 // ---------------------------------------------------------------------------
0225 inline void Token::addRange(const XMLInt32, const XMLInt32) {
0226 
0227     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0228 }
0229 
0230 inline void Token::mergeRanges(const Token *const) {
0231 
0232     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0233 }
0234 
0235 inline void Token::sortRanges() {
0236 
0237     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0238 }
0239 
0240 inline void Token::compactRanges() {
0241 
0242     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0243 }
0244 
0245 inline void Token::subtractRanges(RangeToken* const) {
0246 
0247     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0248 }
0249 
0250 inline void Token::intersectRanges(RangeToken* const) {
0251 
0252     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0253 }
0254 
0255 XERCES_CPP_NAMESPACE_END
0256 
0257 #endif
0258 
0259 /**
0260   * End of file Token.hpp
0261   */
0262