File indexing completed on 2025-01-18 10:15:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_TOKEN_HPP)
0023 #define XERCESC_INCLUDE_GUARD_TOKEN_HPP
0024
0025
0026
0027
0028 #include <xercesc/util/RuntimeException.hpp>
0029 #include <xercesc/util/PlatformUtils.hpp>
0030
0031 XERCES_CPP_NAMESPACE_BEGIN
0032
0033
0034
0035
0036 class RangeToken;
0037 class TokenFactory;
0038
0039
0040 class XMLUTIL_EXPORT Token : public XMemory
0041 {
0042 public:
0043
0044
0045
0046
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
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
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
0096
0097 void setTokenType(const tokType tokType);
0098 virtual void setMin(const int minVal);
0099 virtual void setMax(const int maxVal);
0100
0101
0102
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
0113
0114 virtual void addChild(Token* const child, TokenFactory* const tokFactory);
0115
0116
0117
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
0126
0127 Token(const Token&);
0128 Token& operator=(const Token&);
0129
0130
0131
0132
0133 bool isSet(const int options, const unsigned int flag);
0134 bool isShorterThan(Token* const tok);
0135
0136
0137
0138
0139 tokType fTokenType;
0140 protected:
0141 MemoryManager* const fMemoryManager;
0142 };
0143
0144
0145
0146
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
0195
0196 inline void Token::setTokenType(const Token::tokType tokType) {
0197
0198 fTokenType = tokType;
0199 }
0200
0201 inline void Token::setMax(const int) {
0202
0203 }
0204
0205 inline void Token::setMin(const int) {
0206
0207 }
0208
0209 inline bool Token::isSet(const int options, const unsigned int flag) {
0210
0211 return (options & flag) == flag;
0212 }
0213
0214
0215
0216
0217 inline void Token::addChild(Token* const, TokenFactory* const) {
0218
0219 ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
0220 }
0221
0222
0223
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
0261
0262