File indexing completed on 2025-01-18 10:15:19
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_XERCESXPATH_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XERCESXPATH_HPP
0024
0025
0026
0027
0028
0029 #include <xercesc/util/QName.hpp>
0030 #include <xercesc/util/RefVectorOf.hpp>
0031 #include <xercesc/util/ValueVectorOf.hpp>
0032 #include <xercesc/validators/schema/NamespaceScope.hpp>
0033 #include <xercesc/internal/XSerializable.hpp>
0034
0035 XERCES_CPP_NAMESPACE_BEGIN
0036
0037
0038
0039
0040 class XMLStringPool;
0041
0042 class VALIDATORS_EXPORT XercesNodeTest : public XSerializable, public XMemory
0043 {
0044 public:
0045
0046
0047
0048 enum NodeType {
0049 NodeType_QNAME = 1,
0050 NodeType_WILDCARD = 2,
0051 NodeType_NODE = 3,
0052 NodeType_NAMESPACE= 4,
0053 NodeType_UNKNOWN
0054 };
0055
0056
0057
0058
0059 XercesNodeTest(const short type,
0060 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0061 XercesNodeTest(const QName* const qName);
0062 XercesNodeTest(const XMLCh* const prefix, const unsigned int uriId,
0063 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0064 XercesNodeTest(const XercesNodeTest& other);
0065 ~XercesNodeTest() { delete fName; }
0066
0067
0068
0069
0070 XercesNodeTest& operator= (const XercesNodeTest& other);
0071 bool operator== (const XercesNodeTest& other) const;
0072 bool operator!= (const XercesNodeTest& other) const;
0073
0074
0075
0076
0077 short getType() const { return fType; }
0078 QName* getName() const { return fName; }
0079
0080
0081
0082
0083 DECL_XSERIALIZABLE(XercesNodeTest)
0084
0085 XercesNodeTest(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0086
0087 private:
0088
0089
0090
0091 short fType;
0092 QName* fName;
0093 };
0094
0095
0096
0097
0098
0099 class VALIDATORS_EXPORT XercesStep : public XSerializable, public XMemory
0100 {
0101 public:
0102
0103
0104
0105 enum AxisType {
0106 AxisType_CHILD = 1,
0107 AxisType_ATTRIBUTE = 2,
0108 AxisType_SELF = 3,
0109 AxisType_DESCENDANT = 4,
0110 AxisType_UNKNOWN
0111 };
0112
0113
0114
0115
0116 XercesStep(const unsigned short axisType, XercesNodeTest* const nodeTest);
0117 XercesStep(const XercesStep& other);
0118 ~XercesStep() { delete fNodeTest; }
0119
0120
0121
0122
0123 XercesStep& operator= (const XercesStep& other);
0124 bool operator== (const XercesStep& other) const;
0125 bool operator!= (const XercesStep& other) const;
0126
0127
0128
0129
0130 unsigned short getAxisType() const { return fAxisType; }
0131 XercesNodeTest* getNodeTest() const { return fNodeTest; }
0132
0133
0134
0135
0136 DECL_XSERIALIZABLE(XercesStep)
0137
0138 XercesStep(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0139
0140 private:
0141
0142
0143
0144 unsigned short fAxisType;
0145 XercesNodeTest* fNodeTest;
0146 };
0147
0148
0149
0150
0151
0152 class VALIDATORS_EXPORT XercesLocationPath : public XSerializable, public XMemory
0153 {
0154 public:
0155
0156
0157
0158 XercesLocationPath(RefVectorOf<XercesStep>* const steps);
0159 ~XercesLocationPath() { delete fSteps; }
0160
0161
0162
0163
0164 bool operator== (const XercesLocationPath& other) const;
0165 bool operator!= (const XercesLocationPath& other) const;
0166
0167
0168
0169
0170 XMLSize_t getStepSize() const;
0171 void addStep(XercesStep* const aStep);
0172 XercesStep* getStep(const XMLSize_t index) const;
0173
0174
0175
0176
0177 DECL_XSERIALIZABLE(XercesLocationPath)
0178
0179 XercesLocationPath(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0180
0181 private:
0182
0183
0184
0185 XercesLocationPath(const XercesLocationPath& other);
0186 XercesLocationPath& operator= (const XercesLocationPath& other);
0187
0188
0189
0190
0191 RefVectorOf<XercesStep>* fSteps;
0192 };
0193
0194
0195 class VALIDATORS_EXPORT XercesXPath : public XSerializable, public XMemory
0196 {
0197 public:
0198
0199
0200
0201
0202
0203
0204
0205
0206 enum {
0207 EXPRTOKEN_OPEN_PAREN = 0,
0208 EXPRTOKEN_CLOSE_PAREN = 1,
0209 EXPRTOKEN_OPEN_BRACKET = 2,
0210 EXPRTOKEN_CLOSE_BRACKET = 3,
0211 EXPRTOKEN_PERIOD = 4,
0212 EXPRTOKEN_DOUBLE_PERIOD = 5,
0213 EXPRTOKEN_ATSIGN = 6,
0214 EXPRTOKEN_COMMA = 7,
0215 EXPRTOKEN_DOUBLE_COLON = 8,
0216 EXPRTOKEN_NAMETEST_ANY = 9,
0217 EXPRTOKEN_NAMETEST_NAMESPACE = 10,
0218 EXPRTOKEN_NAMETEST_QNAME = 11,
0219 EXPRTOKEN_NODETYPE_COMMENT = 12,
0220 EXPRTOKEN_NODETYPE_TEXT = 13,
0221 EXPRTOKEN_NODETYPE_PI = 14,
0222 EXPRTOKEN_NODETYPE_NODE = 15,
0223 EXPRTOKEN_OPERATOR_AND = 16,
0224 EXPRTOKEN_OPERATOR_OR = 17,
0225 EXPRTOKEN_OPERATOR_MOD = 18,
0226 EXPRTOKEN_OPERATOR_DIV = 19,
0227 EXPRTOKEN_OPERATOR_MULT = 20,
0228 EXPRTOKEN_OPERATOR_SLASH = 21,
0229 EXPRTOKEN_OPERATOR_DOUBLE_SLASH = 22,
0230 EXPRTOKEN_OPERATOR_UNION = 23,
0231 EXPRTOKEN_OPERATOR_PLUS = 24,
0232 EXPRTOKEN_OPERATOR_MINUS = 25,
0233 EXPRTOKEN_OPERATOR_EQUAL = 26,
0234 EXPRTOKEN_OPERATOR_NOT_EQUAL = 27,
0235 EXPRTOKEN_OPERATOR_LESS = 28,
0236 EXPRTOKEN_OPERATOR_LESS_EQUAL = 29,
0237 EXPRTOKEN_OPERATOR_GREATER = 30,
0238 EXPRTOKEN_OPERATOR_GREATER_EQUAL = 31,
0239 EXPRTOKEN_FUNCTION_NAME = 32,
0240 EXPRTOKEN_AXISNAME_ANCESTOR = 33,
0241 EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF = 34,
0242 EXPRTOKEN_AXISNAME_ATTRIBUTE = 35,
0243 EXPRTOKEN_AXISNAME_CHILD = 36,
0244 EXPRTOKEN_AXISNAME_DESCENDANT = 37,
0245 EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF = 38,
0246 EXPRTOKEN_AXISNAME_FOLLOWING = 39,
0247 EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING = 40,
0248 EXPRTOKEN_AXISNAME_NAMESPACE = 41,
0249 EXPRTOKEN_AXISNAME_PARENT = 42,
0250 EXPRTOKEN_AXISNAME_PRECEDING = 43,
0251 EXPRTOKEN_AXISNAME_PRECEDING_SIBLING = 44,
0252 EXPRTOKEN_AXISNAME_SELF = 45,
0253 EXPRTOKEN_LITERAL = 46,
0254 EXPRTOKEN_NUMBER = 47,
0255 EXPRTOKEN_VARIABLE_REFERENCE = 48
0256 };
0257
0258
0259
0260
0261 XercesXPath(const XMLCh* const xpathExpr,
0262 XMLStringPool* const stringPool,
0263 XercesNamespaceResolver* const scopeContext,
0264 const unsigned int emptyNamespaceId,
0265 const bool isSelector = false,
0266 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0267 ~XercesXPath();
0268
0269
0270
0271
0272 bool operator== (const XercesXPath& other) const;
0273 bool operator!= (const XercesXPath& other) const;
0274
0275
0276
0277
0278 RefVectorOf<XercesLocationPath>* getLocationPaths() const;
0279
0280
0281
0282
0283 DECL_XSERIALIZABLE(XercesXPath)
0284
0285 XercesXPath(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0286
0287 XMLCh* getExpression();
0288
0289 private:
0290
0291
0292
0293 XercesXPath(const XercesXPath& other);
0294 XercesXPath& operator= (const XercesXPath& other);
0295
0296
0297
0298
0299 void cleanUp();
0300 void checkForSelectedAttributes();
0301 void parseExpression(XMLStringPool* const stringPool,
0302 XercesNamespaceResolver* const scopeContext);
0303
0304
0305
0306
0307 unsigned int fEmptyNamespaceId;
0308 XMLCh* fExpression;
0309 RefVectorOf<XercesLocationPath>* fLocationPaths;
0310 MemoryManager* fMemoryManager;
0311 };
0312
0313
0314 class VALIDATORS_EXPORT XPathScanner : public XMemory
0315 {
0316 public:
0317
0318
0319
0320 enum {
0321 CHARTYPE_INVALID = 0,
0322 CHARTYPE_OTHER = 1,
0323 CHARTYPE_WHITESPACE = 2,
0324 CHARTYPE_EXCLAMATION = 3,
0325 CHARTYPE_QUOTE = 4,
0326 CHARTYPE_DOLLAR = 5,
0327 CHARTYPE_OPEN_PAREN = 6,
0328 CHARTYPE_CLOSE_PAREN = 7,
0329 CHARTYPE_STAR = 8,
0330 CHARTYPE_PLUS = 9,
0331 CHARTYPE_COMMA = 10,
0332 CHARTYPE_MINUS = 11,
0333 CHARTYPE_PERIOD = 12,
0334 CHARTYPE_SLASH = 13,
0335 CHARTYPE_DIGIT = 14,
0336 CHARTYPE_COLON = 15,
0337 CHARTYPE_LESS = 16,
0338 CHARTYPE_EQUAL = 17,
0339 CHARTYPE_GREATER = 18,
0340 CHARTYPE_ATSIGN = 19,
0341 CHARTYPE_LETTER = 20,
0342 CHARTYPE_OPEN_BRACKET = 21,
0343 CHARTYPE_CLOSE_BRACKET = 22,
0344 CHARTYPE_UNDERSCORE = 23,
0345 CHARTYPE_UNION = 24,
0346 CHARTYPE_NONASCII = 25
0347 };
0348
0349
0350
0351
0352 XPathScanner(XMLStringPool* const stringPool);
0353 virtual ~XPathScanner() {}
0354
0355
0356
0357
0358 bool scanExpression(const XMLCh* const data, XMLSize_t currentOffset,
0359 const XMLSize_t endOffset, ValueVectorOf<int>* const tokens);
0360
0361 protected:
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372 virtual void addToken(ValueVectorOf<int>* const tokens, const int aToken);
0373
0374 private:
0375
0376
0377
0378 XPathScanner(const XPathScanner& other);
0379 XPathScanner& operator= (const XPathScanner& other);
0380
0381
0382
0383
0384 void init();
0385
0386
0387
0388
0389 XMLSize_t scanNCName(const XMLCh* const data, const XMLSize_t endOffset,
0390 XMLSize_t currentOffset);
0391 XMLSize_t scanNumber(const XMLCh* const data, const XMLSize_t endOffset,
0392 XMLSize_t currentOffset, ValueVectorOf<int>* const tokens);
0393
0394
0395
0396
0397 int fAndSymbol;
0398 int fOrSymbol;
0399 int fModSymbol;
0400 int fDivSymbol;
0401 int fCommentSymbol;
0402 int fTextSymbol;
0403 int fPISymbol;
0404 int fNodeSymbol;
0405 int fAncestorSymbol;
0406 int fAncestorOrSelfSymbol;
0407 int fAttributeSymbol;
0408 int fChildSymbol;
0409 int fDescendantSymbol;
0410 int fDescendantOrSelfSymbol;
0411 int fFollowingSymbol;
0412 int fFollowingSiblingSymbol;
0413 int fNamespaceSymbol;
0414 int fParentSymbol;
0415 int fPrecedingSymbol;
0416 int fPrecedingSiblingSymbol;
0417 int fSelfSymbol;
0418 XMLStringPool* fStringPool;
0419
0420 static const XMLByte fASCIICharMap[128];
0421 };
0422
0423
0424 class VALIDATORS_EXPORT XPathScannerForSchema: public XPathScanner
0425 {
0426 public:
0427
0428
0429
0430 XPathScannerForSchema(XMLStringPool* const stringPool);
0431 ~XPathScannerForSchema() {}
0432
0433 protected:
0434
0435
0436
0437 void addToken(ValueVectorOf<int>* const tokens, const int aToken);
0438
0439 private:
0440
0441
0442
0443 XPathScannerForSchema(const XPathScannerForSchema& other);
0444 XPathScannerForSchema& operator= (const XPathScannerForSchema& other);
0445 };
0446
0447
0448
0449
0450 inline XMLSize_t XercesLocationPath::getStepSize() const {
0451
0452 if (fSteps)
0453 return fSteps->size();
0454
0455 return 0;
0456 }
0457
0458 inline void XercesLocationPath::addStep(XercesStep* const aStep) {
0459
0460 fSteps->addElement(aStep);
0461 }
0462
0463 inline XercesStep* XercesLocationPath::getStep(const XMLSize_t index) const {
0464
0465 if (fSteps)
0466 return fSteps->elementAt(index);
0467
0468 return 0;
0469 }
0470
0471
0472
0473
0474 inline void XPathScanner::addToken(ValueVectorOf<int>* const tokens,
0475 const int aToken) {
0476 tokens->addElement(aToken);
0477 }
0478
0479
0480
0481
0482
0483 inline RefVectorOf<XercesLocationPath>* XercesXPath::getLocationPaths() const {
0484
0485 return fLocationPaths;
0486 }
0487
0488 inline XMLCh* XercesXPath::getExpression() {
0489 return fExpression;
0490 }
0491
0492 XERCES_CPP_NAMESPACE_END
0493
0494 #endif
0495
0496
0497
0498
0499