16 #if !defined(XPATHEXPRESSION_HEADER_GUARD_1357924680)
17 #define XPATHEXPRESSION_HEADER_GUARD_1357924680
30 #if defined(XALAN_CLASSIC_IOSTREAMS)
52 XALAN_CPP_NAMESPACE_BEGIN
56 XALAN_USING_XERCES(MemoryManager)
76 #define XALAN_XPATH_EXPRESSION_USE_ITERATORS
78 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
81 typedef OpCodeMapSizeType OpCodeMapPositionType;
390 eOP_EXTFUNCTION = 23,
423 eOP_LOCATIONPATH = 25,
443 eNODETYPE_COMMENT = 27,
498 eNODETYPE_ANYELEMENT = 33,
510 eFROM_ANCESTORS = 34,
511 eFROM_ANCESTORS_OR_SELF = 35,
512 eFROM_ATTRIBUTES = 36,
514 eFROM_DESCENDANTS = 38,
515 eFROM_DESCENDANTS_OR_SELF = 39,
516 eFROM_FOLLOWING = 40,
517 eFROM_FOLLOWING_SIBLINGS = 41,
519 eFROM_PRECEDING = 43,
520 eFROM_PRECEDING_SIBLINGS = 44,
522 eFROM_NAMESPACE = 46,
533 eOP_MATCHPATTERN = 48,
543 eOP_LOCATIONPATHPATTERN = 49,
546 eMATCH_ATTRIBUTE = 50,
547 eMATCH_ANY_ANCESTOR = 51,
548 eMATCH_IMMEDIATE_ANCESTOR = 52,
549 eMATCH_ANY_ANCESTOR_WITH_PREDICATE = 53,
550 eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL = 54,
561 eOP_PREDICATE_WITH_POSITION = 55,
567 eOP_FUNCTION_POSITION = 56,
568 eOP_FUNCTION_LAST = 57,
569 eOP_FUNCTION_COUNT = 58,
570 eOP_FUNCTION_NOT = 59,
571 eOP_FUNCTION_TRUE = 60,
572 eOP_FUNCTION_FALSE = 61,
573 eOP_FUNCTION_BOOLEAN = 62,
574 eOP_FUNCTION_NAME_0 = 63,
575 eOP_FUNCTION_NAME_1 = 64,
576 eOP_FUNCTION_LOCALNAME_0 = 65,
577 eOP_FUNCTION_LOCALNAME_1 = 66,
578 eOP_FUNCTION_FLOOR = 67,
579 eOP_FUNCTION_CEILING = 68,
580 eOP_FUNCTION_ROUND = 69,
581 eOP_FUNCTION_NUMBER_0 = 70,
582 eOP_FUNCTION_NUMBER_1 = 71,
583 eOP_FUNCTION_STRING_0 = 72,
584 eOP_FUNCTION_STRING_1 = 73,
585 eOP_FUNCTION_STRINGLENGTH_0 = 74,
586 eOP_FUNCTION_STRINGLENGTH_1 = 75,
587 eOP_FUNCTION_NAMESPACEURI_0 = 76,
588 eOP_FUNCTION_NAMESPACEURI_1 = 77,
589 eOP_FUNCTION_SUM = 78,
590 eOP_FUNCTION_CONCAT = 79,
637 FormatErrorMessage(OpCodeMapValueType theOpCode,
657 OpCodeMapValueType theOpCode,
658 OpCodeMapValueType theExpectedCount,
659 OpCodeMapValueType theSuppliedCount,
669 OpCodeMapValueType theOpCode,
670 OpCodeMapValueType theExpectedCount,
671 OpCodeMapValueType theSuppliedCount,
689 OpCodeMapValueType theOpCode,
690 OpCodeMapValueType theValue,
700 OpCodeMapValueType theOpCode,
701 OpCodeMapValueType theValue,
712 #if defined(XALAN_INLINE_INITIALIZATION)
713 static const TokenQueueSizeType s_opCodeMapLengthIndex = 1;
717 s_opCodeMapLengthIndex = 1
729 return m_opMap.getMemoryManager();
751 return OpCodeMapSizeType(m_opMap.size());
768 const OpCodeMapSizeType theSize = opCodeMapSize();
770 if (theSize > s_opCodeMapLengthIndex)
772 assert(theSize == OpCodeMapSizeType(m_opMap[s_opCodeMapLengthIndex]));
774 return m_opMap[s_opCodeMapLengthIndex];
778 assert(theSize == OpCodeMapValueType(theSize));
780 return OpCodeMapValueType(theSize);
784 OpCodeMapPositionType
787 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
788 return m_opMap.begin();
797 const OpCodeMapDifferenceType theDifference =
798 OpCodeMapDifferenceType(opPos - getInitialOpCodePosition());
800 return theDifference >= 0 &&
801 theDifference < opCodeMapSize();
804 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
808 return theIndex >= 0 && theIndex < opCodeMapSize();
821 assert(theIndex < opCodeMapLength());
823 return m_opMap[theIndex];
837 assert(opPos < getInitialOpCodePosition() + opCodeMapLength());
839 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
843 return m_opMap[opPos];
856 OpCodeMapSizeType theOpCodeMapIndex,
857 const OpCodeMapValueType& theValue)
859 assert(theOpCodeMapIndex < opCodeMapLength());
861 m_opMap[theOpCodeMapIndex] = theValue;
878 getOpCodeLengthFromOpMap(OpCodeMapPositionType opPos,
881 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
890 getOpCodeLengthFromOpMap(OpCodeMapSizeType theIndex,
894 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
902 OpCodeMapPositionType
905 assert(opPos < getInitialOpCodePosition() + opCodeMapLength());
907 return opPos + *(opPos + s_opCodeMapLengthIndex);
919 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
922 getNextOpCodePosition(OpCodeMapPositionType theIndex)
const
925 assert(theIndex < opCodeMapLength());
927 assert(theIndex + m_opMap[theIndex + s_opCodeMapLengthIndex] ==
928 OpCodeMapSizeType(theIndex + m_opMap[theIndex + s_opCodeMapLengthIndex]));
930 return OpCodeMapSizeType(theIndex + m_opMap[theIndex + s_opCodeMapLengthIndex]);
945 OpCodeMapSizeType theIndex,
946 const OpCodeMapValueVectorType& theArgs);
955 appendOpCode(eOpCodes theOpCode);
966 const OpCodeMapValueVectorType& theArgs)
968 const OpCodeMapSizeType thePosition = appendOpCode(theOpCode);
970 setOpCodeArgs(theOpCode,
986 OpCodeMapSizeType theIndex,
987 eOpCodes theOldOpCode,
988 eOpCodes theNewOpCode);
999 OpCodeMapSizeType theIndex);
1013 assert(theIndex < opCodeMapSize());
1015 updateOpCodeLength(m_opMap[theIndex], theIndex);
1027 updateShiftedOpCodeLength(
1028 OpCodeMapValueType theOpCode,
1029 OpCodeMapSizeType theOriginalIndex,
1030 OpCodeMapSizeType theNewIndex);
1044 OpCodeMapValueType theOpCode,
1045 OpCodeMapSizeType theIndex);
1055 isNodeTestOpCode(OpCodeMapValueType theOpCode);
1063 updateOpCodeLengthAfterNodeTest(OpCodeMapSizeType theIndex);
1073 return tokenQueueSize() > m_currentPosition ?
true :
false;
1084 return TokenQueueSizeType(m_tokenQueue.size());
1090 return thePosition < tokenQueueSize();
1101 return m_currentPosition;
1110 m_currentPosition = 0;
1122 assert(thePosition < tokenQueueSize());
1124 return &m_tokenQueue[thePosition];
1135 if (hasMoreTokens() ==
true)
1137 return getToken(m_currentPosition++);
1153 if (m_currentPosition > 0)
1155 return getToken(--m_currentPosition);
1179 TokenQueuePositionType theOffset,
1182 const TokenQueuePositionType thePosition =
1183 calculateRelativePosition(theOffset, theDirection);
1185 if (thePosition == tokenQueueSize())
1191 return getToken(thePosition);
1203 m_tokenQueue.push_back(
XToken(theToken, getMemoryManager()));
1217 m_tokenQueue.push_back(
XToken(theNumber, theString));
1229 m_tokenQueue.insert(m_tokenQueue.begin() + (m_currentPosition - 1),
XToken(theToken, getMemoryManager()));
1244 m_tokenQueue.insert(m_tokenQueue.begin() + (m_currentPosition - 1),
XToken(theNumber, theString));
1255 TokenQueuePositionType theOffset,
1259 const TokenQueuePositionType thePosition =
1260 calculateRelativePosition(theOffset, theDirection);
1261 assert(thePosition < tokenQueueSize());
1263 m_tokenQueue[thePosition].set(theString, getMemoryManager());
1275 OpCodeMapSizeType theStartPosition = 0)
const;
1285 OstreamType& theStream,
1286 OpCodeMapSizeType theStartPosition = 0)
const;
1297 TokenQueueSizeType theStartPosition = 0)
const;
1307 OstreamType& theStream,
1308 TokenQueueSizeType theStartPosition = 0)
const;
1316 dumpRemainingTokenQueue(
PrintWriter& thePrintWriter)
const;
1325 dumpRemainingTokenQueue(
1326 OstreamType& theStream,
1327 MemoryManager& theMemoryManager)
const;
1339 m_opMap.push_back(theValue);
1342 ++m_opMap[s_opCodeMapLengthIndex];
1352 pushArgumentOnOpCodeMap(
const XToken& theXToken);
1371 pushArgumentOnOpCodeMap(
1382 pushNumberLiteralOnOpCodeMap(
double theNumber);
1392 assert(theIndex >= 0 &&
1403 pushCurrentTokenOnOpCodeMap();
1413 m_currentPattern = &thePattern;
1424 assert(m_currentPattern != 0);
1426 return *m_currentPattern;
1440 TokenQueuePositionType
1441 calculateRelativePosition(
1442 TokenQueuePositionType theOffset,
1443 eRelativeDirection theDirection)
const
1445 if (theDirection == eRelativeBackward &&
1446 theOffset <= m_currentPosition)
1448 return m_currentPosition - theOffset;
1450 else if (theDirection == eRelativeForward &&
1451 m_currentPosition + theOffset < tokenQueueSize())
1453 return m_currentPosition + theOffset;
1457 return tokenQueueSize();
1467 OpCodeMapType m_opMap;
1473 OpCodeMapSizeType m_lastOpCodeIndex;
1480 TokenQueueType m_tokenQueue;
1485 TokenQueueSizeType m_currentPosition;
1495 eDefaultOpMapSize = 100,
1496 eDefaultTokenQueueSize = 30
1499 NumberLiteralValueVectorType m_numberLiteralValues;
1504 XALAN_CPP_NAMESPACE_END
1508 #endif // XPATHEXPRESSION_HEADER_GUARD_1357924680
Exception class thrown when an invalid XPath argument is encountered.
Definition: XPathExpression.hpp:678
Definition: XToken.hpp:35
int value_type
Definition: XalanVector.hpp:66
TokenQueueSizeType TokenQueuePositionType
Definition: XPathExpression.hpp:86
bool isValidTokenQueuePosition(TokenQueueSizeType thePosition) const
Definition: XPathExpression.hpp:1088
void updateOpCodeLength(OpCodeMapSizeType theIndex)
Update the length of an operation code at a specified index in the list.
Definition: XPathExpression.hpp:1011
Exception class thrown when an invalid number of XPath arguments is encountered.
Definition: XPathExpression.hpp:645
const value_type * const_iterator
Definition: XalanVector.hpp:92
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
void pushToken(double theNumber, const XalanDOMString &theString)
Push a token onto the token queue.
Definition: XPathExpression.hpp:1213
OpCodeMapSizeType opCodeMapSize() const
Retrieve number of elements in the operations code map.
Definition: XPathExpression.hpp:749
TokenQueueSizeType tokenQueueSize() const
Retrieve number of elements in the token queue.
Definition: XPathExpression.hpp:1082
const XToken * getPreviousToken()
Retrieve the previous token in the token queue.
Definition: XPathExpression.hpp:1151
XalanVector< XToken > TokenQueueType
Definition: XPathExpression.hpp:67
const XalanDOMString & getCurrentPattern() const
Retrieve the current pattern in the pattern map.
Definition: XPathExpression.hpp:1422
const XToken * getToken(TokenQueuePositionType thePosition) const
Retrieve a token at the specified position in the token queue.
Definition: XPathExpression.hpp:1120
Definition: XPathExpression.hpp:60
void pushValueOnOpCodeMap(const OpCodeMapType::value_type &theValue)
Push a value onto the operations code map.
Definition: XPathExpression.hpp:1336
bool hasMoreTokens() const
Whether there are any more tokens in the token queue.
Definition: XPathExpression.hpp:1071
OpCodeMapSizeType appendOpCode(eOpCodes theOpCode, const OpCodeMapValueVectorType &theArgs)
Add an operation code with supplied arguments to the list.
Definition: XPathExpression.hpp:964
MemoryManagerType & getMemoryManager()
Definition: XPathExpression.hpp:727
void resetTokenPosition()
Set the current position in the token queue to zero.
Definition: XPathExpression.hpp:1108
Exception class thrown when an invalid XPath expression is encountered.
Definition: XPathExpression.hpp:600
Definition: PrintWriter.hpp:35
XalanVector< double > NumberLiteralValueVectorType
Definition: XPathExpression.hpp:74
XALAN_STD_QUALIFIER ostream OstreamType
Definition: XPathExpression.hpp:64
const XToken * getNextToken()
Retrieve the next token in the token queue.
Definition: XPathExpression.hpp:1133
ptrdiff_t difference_type
Definition: XalanVector.hpp:72
double getNumberLiteral(int theIndex) const
Get a number literal from the vector of number literals.
Definition: XPathExpression.hpp:1390
int TokenQueueSizeType
Definition: XPathExpression.hpp:85
OpCodeMapValueType opCodeMapLength() const
Retrieve length of the operations code map stored in the map.
Definition: XPathExpression.hpp:766
eRelativeDirection
Definition: XPathExpression.hpp:1163
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:44
bool isValidOpCodePosition(OpCodeMapPositionType opPos) const
Definition: XPathExpression.hpp:795
OpCodeMapPositionType getInitialOpCodePosition() const
Definition: XPathExpression.hpp:785
const XToken * getRelativeToken(TokenQueuePositionType theOffset, eRelativeDirection theDirection) const
Retrieve a token at the specified offset relative to the current position in the token queue...
Definition: XPathExpression.hpp:1178
OpCodeMapType::difference_type OpCodeMapDifferenceType
Definition: XPathExpression.hpp:83
void pushToken(const XalanDOMString &theToken)
Push a token onto the token queue.
Definition: XPathExpression.hpp:1201
eDummy
The length is always the opcode position + 1.
Definition: XPathExpression.hpp:715
TokenQueueType::value_type TokenQueueValueType
Definition: XPathExpression.hpp:84
eOpCodes
List of operations codes.
Definition: XPathExpression.hpp:106
XalanVector< int > OpCodeMapType
Definition: XPathExpression.hpp:66
TokenQueueSizeType getTokenPosition() const
Retrieve the current position in the token queue.
Definition: XPathExpression.hpp:1099
size_t size_type
Definition: XalanVector.hpp:71
XalanVector< OpCodeMapValueType > OpCodeMapValueVectorType
Definition: XPathExpression.hpp:72
OpCodeMapValueType getOpCodeMapValue(OpCodeMapSizeType theIndex) const
Retrieve the value of an operation code at a specified index in the op code map.
Definition: XPathExpression.hpp:819
void setOpCodeMapValue(OpCodeMapSizeType theOpCodeMapIndex, const OpCodeMapValueType &theValue)
Set the value of an operation code at a specified index in the OpCode map.
Definition: XPathExpression.hpp:855
Definition: XPathExpression.hpp:1165
OpCodeMapValueType getOpCodeMapValue(OpCodeMapPositionType opPos) const
Retrieve the value of an operation code at a specified position in the list.
Definition: XPathExpression.hpp:835
void insertToken(double theNumber, const XalanDOMString &theString)
Insert a token onto the token queue at the current position.
Definition: XPathExpression.hpp:1240
void setCurrentPattern(const XalanDOMString &thePattern)
Change the current pattern in the pattern map.
Definition: XPathExpression.hpp:1411
OpCodeMapPositionType getNextOpCodePosition(OpCodeMapPositionType opPos) const
Retrieve the position of the next operation code at a specified position in the list.
Definition: XPathExpression.hpp:903
Definition: XalanDOMString.hpp:42
OpCodeMapValueType OpCodeMapSizeType
Definition: XPathExpression.hpp:70
OpCodeMapSizeType getNextOpCodePosition(OpCodeMapSizeType theIndex) const
Retrieve the position of the next operation code at a specified index in the list.
Definition: XPathExpression.hpp:920
void replaceRelativeToken(TokenQueuePositionType theOffset, eRelativeDirection theDirection, const XalanDOMString &theString)
Replace a token in the token queue.
Definition: XPathExpression.hpp:1254
Exception class thrown when an invalid XPath operation code is encountered.
Definition: XPathExpression.hpp:619
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:33
OpCodeMapType::const_iterator OpCodeMapPositionType
Definition: XPathExpression.hpp:79
void insertToken(const XalanDOMString &theToken)
Insert a token onto the token queue at the current position.
Definition: XPathExpression.hpp:1227
OpCodeMapType::value_type OpCodeMapValueType
Definition: XPathExpression.hpp:69
bool isValidOpCodePosition(OpCodeMapSizeType theIndex) const
Definition: XPathExpression.hpp:806
Definition: XPathExpression.hpp:717
Definition: XalanXPathException.hpp:44
OpCodeMapValueType getOpCodeArgumentLength(OpCodeMapPositionType opPos) const
Definition: XPathExpression.hpp:865