18 #if !defined(XPATHEXPRESSION_HEADER_GUARD_1357924680) 19 #define XPATHEXPRESSION_HEADER_GUARD_1357924680 32 #if defined(XALAN_CLASSIC_IOSTREAMS) 54 XALAN_CPP_NAMESPACE_BEGIN
78 #define XALAN_XPATH_EXPRESSION_USE_ITERATORS 80 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 83 typedef OpCodeMapSizeType OpCodeMapPositionType;
392 eOP_EXTFUNCTION = 23,
425 eOP_LOCATIONPATH = 25,
445 eNODETYPE_COMMENT = 27,
500 eNODETYPE_ANYELEMENT = 33,
512 eFROM_ANCESTORS = 34,
513 eFROM_ANCESTORS_OR_SELF = 35,
514 eFROM_ATTRIBUTES = 36,
516 eFROM_DESCENDANTS = 38,
517 eFROM_DESCENDANTS_OR_SELF = 39,
518 eFROM_FOLLOWING = 40,
519 eFROM_FOLLOWING_SIBLINGS = 41,
521 eFROM_PRECEDING = 43,
522 eFROM_PRECEDING_SIBLINGS = 44,
524 eFROM_NAMESPACE = 46,
535 eOP_MATCHPATTERN = 48,
545 eOP_LOCATIONPATHPATTERN = 49,
548 eMATCH_ATTRIBUTE = 50,
549 eMATCH_ANY_ANCESTOR = 51,
550 eMATCH_IMMEDIATE_ANCESTOR = 52,
551 eMATCH_ANY_ANCESTOR_WITH_PREDICATE = 53,
552 eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL = 54,
563 eOP_PREDICATE_WITH_POSITION = 55,
569 eOP_FUNCTION_POSITION = 56,
570 eOP_FUNCTION_LAST = 57,
571 eOP_FUNCTION_COUNT = 58,
572 eOP_FUNCTION_NOT = 59,
573 eOP_FUNCTION_TRUE = 60,
574 eOP_FUNCTION_FALSE = 61,
575 eOP_FUNCTION_BOOLEAN = 62,
576 eOP_FUNCTION_NAME_0 = 63,
577 eOP_FUNCTION_NAME_1 = 64,
578 eOP_FUNCTION_LOCALNAME_0 = 65,
579 eOP_FUNCTION_LOCALNAME_1 = 66,
580 eOP_FUNCTION_FLOOR = 67,
581 eOP_FUNCTION_CEILING = 68,
582 eOP_FUNCTION_ROUND = 69,
583 eOP_FUNCTION_NUMBER_0 = 70,
584 eOP_FUNCTION_NUMBER_1 = 71,
585 eOP_FUNCTION_STRING_0 = 72,
586 eOP_FUNCTION_STRING_1 = 73,
587 eOP_FUNCTION_STRINGLENGTH_0 = 74,
588 eOP_FUNCTION_STRINGLENGTH_1 = 75,
589 eOP_FUNCTION_NAMESPACEURI_0 = 76,
590 eOP_FUNCTION_NAMESPACEURI_1 = 77,
591 eOP_FUNCTION_SUM = 78,
592 eOP_FUNCTION_CONCAT = 79,
612 MemoryManager& theManager);
631 OpCodeMapValueType theOpCode,
641 OpCodeMapValueType theOpCode,
661 OpCodeMapValueType theOpCode,
662 OpCodeMapValueType theExpectedCount,
663 OpCodeMapValueType theSuppliedCount,
673 OpCodeMapValueType theOpCode,
674 OpCodeMapValueType theExpectedCount,
675 OpCodeMapValueType theSuppliedCount,
693 OpCodeMapValueType theOpCode,
694 OpCodeMapValueType theValue,
704 OpCodeMapValueType theOpCode,
705 OpCodeMapValueType theValue,
716 #if defined(XALAN_INLINE_INITIALIZATION) 717 static const TokenQueueSizeType s_opCodeMapLengthIndex = 1;
721 s_opCodeMapLengthIndex = 1
733 return m_opMap.getMemoryManager();
774 if (theSize > s_opCodeMapLengthIndex)
788 OpCodeMapPositionType
791 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 792 return m_opMap.begin();
801 const OpCodeMapDifferenceType theDifference =
804 return theDifference >= 0 &&
808 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 827 return m_opMap[theIndex];
843 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 847 return m_opMap[opPos];
860 OpCodeMapSizeType theOpCodeMapIndex,
861 const OpCodeMapValueType& theValue)
865 m_opMap[theOpCodeMapIndex] = theValue;
883 MemoryManager& theManager)
const;
885 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 895 MemoryManager& theManager)
const;
898 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 906 OpCodeMapPositionType
923 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 931 assert(theIndex + m_opMap[theIndex + s_opCodeMapLengthIndex] ==
949 OpCodeMapSizeType theIndex,
950 const OpCodeMapValueVectorType& theArgs);
970 const OpCodeMapValueVectorType& theArgs)
972 const OpCodeMapSizeType thePosition =
appendOpCode(theOpCode);
990 OpCodeMapSizeType theIndex,
1003 OpCodeMapSizeType theIndex);
1032 OpCodeMapValueType theOpCode,
1033 OpCodeMapSizeType theOriginalIndex,
1034 OpCodeMapSizeType theNewIndex);
1048 OpCodeMapValueType theOpCode,
1049 OpCodeMapSizeType theIndex);
1105 return m_currentPosition;
1114 m_currentPosition = 0;
1128 return &m_tokenQueue[thePosition];
1141 return getToken(m_currentPosition++);
1157 if (m_currentPosition > 0)
1159 return getToken(--m_currentPosition);
1183 TokenQueuePositionType theOffset,
1186 const TokenQueuePositionType thePosition =
1187 calculateRelativePosition(theOffset, theDirection);
1207 m_tokenQueue.push_back(
1226 m_tokenQueue.push_back(
1242 m_tokenQueue.insert(
1243 m_tokenQueue.begin() + (m_currentPosition - 1),
1262 m_tokenQueue.insert(
1263 m_tokenQueue.begin() + (m_currentPosition - 1),
1278 TokenQueuePositionType theOffset,
1282 const TokenQueuePositionType thePosition =
1283 calculateRelativePosition(theOffset, theDirection);
1286 m_tokenQueue[thePosition].set(
1300 OpCodeMapSizeType theStartPosition = 0)
const;
1310 OstreamType& theStream,
1311 OpCodeMapSizeType theStartPosition = 0)
const;
1322 TokenQueueSizeType theStartPosition = 0)
const;
1332 OstreamType& theStream,
1333 TokenQueueSizeType theStartPosition = 0)
const;
1351 OstreamType& theStream,
1352 MemoryManager& theMemoryManager)
const;
1364 m_opMap.push_back(theValue);
1417 assert(theIndex >= 0 &&
1438 m_currentPattern = &thePattern;
1449 assert(m_currentPattern != 0);
1451 return *m_currentPattern;
1465 TokenQueuePositionType
1466 calculateRelativePosition(
1467 TokenQueuePositionType theOffset,
1470 if (theDirection == eRelativeBackward &&
1471 theOffset <= m_currentPosition)
1473 return m_currentPosition - theOffset;
1475 else if (theDirection == eRelativeForward &&
1478 return m_currentPosition + theOffset;
1492 OpCodeMapType m_opMap;
1498 OpCodeMapSizeType m_lastOpCodeIndex;
1505 TokenQueueType m_tokenQueue;
1510 TokenQueueSizeType m_currentPosition;
1520 eDefaultOpMapSize = 100,
1521 eDefaultTokenQueueSize = 30
1524 NumberLiteralValueVectorType m_numberLiteralValues;
1529 XALAN_CPP_NAMESPACE_END
1533 #endif // XPATHEXPRESSION_HEADER_GUARD_1357924680 Exception class thrown when an invalid XPath argument is encountered.
bool isValidOpCodePosition(OpCodeMapPositionType opPos) const
TokenQueueSizeType TokenQueuePositionType
void updateOpCodeLength(OpCodeMapSizeType theIndex)
Update the length of an operation code at a specified index in the list.
void updateOpCodeLengthAfterNodeTest(OpCodeMapSizeType theIndex)
Update the length of an operation code after a node test code.
Exception class thrown when an invalid number of XPath arguments is encountered.
const value_type * const_iterator
const MemoryManager & getMemoryManager() const
TokenQueueSizeType getTokenPosition() const
Retrieve the current position in the token queue.
void pushToken(double theNumber, const XalanDOMString &theString)
Push a token onto the token queue.
OpCodeMapValueType insertOpCode(eOpCodes theOpCode, OpCodeMapSizeType theIndex)
Insert an operation code at a specified index in the list.
OpCodeMapValueType opCodeMapLength() const
Retrieve length of the operations code map stored in the map.
OpCodeMapSizeType opCodeMapSize() const
Retrieve number of elements in the operations code map.
const XToken * getPreviousToken()
Retrieve the previous token in the token queue.
TokenQueueSizeType tokenQueueSize() const
Retrieve number of elements in the token queue.
XalanVector< XToken > TokenQueueType
XPathExpression(MemoryManager &theManager)
void dumpOpCodeMap(PrintWriter &thePrintWriter, OpCodeMapSizeType theStartPosition=0) const
Diagnostic function to output the operation code map.
void shrink()
Shrink internal tables.
void pushValueOnOpCodeMap(const OpCodeMapType::value_type &theValue)
Push a value onto the operations code map.
OpCodeMapSizeType appendOpCode(eOpCodes theOpCode, const OpCodeMapValueVectorType &theArgs)
Add an operation code with supplied arguments to the list.
void pushNumberLiteralOnOpCodeMap(double theNumber)
Push a number literal onto the vector of number literals and its index onto the operations code map...
void updateShiftedOpCodeLength(OpCodeMapValueType theOpCode, OpCodeMapSizeType theOriginalIndex, OpCodeMapSizeType theNewIndex)
Update the length of an operation code that has moved to a new index in the list. ...
void setOpCodeArgs(eOpCodes theOpCode, OpCodeMapSizeType theIndex, const OpCodeMapValueVectorType &theArgs)
Set the arguments for an operation code at a specified index in the list.
void resetTokenPosition()
Set the current position in the token queue to zero.
Exception class thrown when an invalid XPath expression is encountered.
bool isValidOpCodePosition(OpCodeMapSizeType theIndex) const
void dumpRemainingTokenQueue(PrintWriter &thePrintWriter) const
Diagnostic function to output the remaining tokens in the token queue.
XalanVector< double > NumberLiteralValueVectorType
void reset()
Reset the expression.
void dumpTokenQueue(PrintWriter &thePrintWriter, TokenQueueSizeType theStartPosition=0) const
Diagnostic function to output the token queue.
XALAN_STD_QUALIFIER ostream OstreamType
const XToken * getNextToken()
Retrieve the next token in the token queue.
ptrdiff_t difference_type
void pushArgumentOnOpCodeMap(const XToken &theXToken)
Push a token onto the token queue and its index onto the operations code map.
const XToken * getToken(TokenQueuePositionType thePosition) const
Retrieve a token at the specified position in the token queue.
MemoryManager & getMemoryManager()
const XToken * getRelativeToken(TokenQueuePositionType theOffset, eRelativeDirection theDirection) const
Retrieve a token at the specified offset relative to the current position in the token queue...
void pushCurrentTokenOnOpCodeMap()
Push the current position in the token queue onto the operations code map.
OpCodeMapSizeType appendOpCode(eOpCodes theOpCode)
Add an operation code to the list.
OpCodeMapType::difference_type OpCodeMapDifferenceType
void pushToken(const XalanDOMString &theToken)
Push a token onto the token queue.
eDummy
The length is always the opcode position + 1.
TokenQueueType::value_type TokenQueueValueType
double getNumberLiteral(int theIndex) const
Get a number literal from the vector of number literals.
eOpCodes
List of operations codes.
XalanVector< int > OpCodeMapType
XalanVector< OpCodeMapValueType > OpCodeMapValueVectorType
OpCodeMapValueType getOpCodeMapValue(OpCodeMapPositionType opPos) const
Retrieve the value of an operation code at a specified position in the list.
void replaceOpCode(OpCodeMapSizeType theIndex, eOpCodes theOldOpCode, eOpCodes theNewOpCode)
Replace an operation code with supplied code.
const XalanDOMString & getCurrentPattern() const
Retrieve the current pattern in the pattern map.
void setOpCodeMapValue(OpCodeMapSizeType theOpCodeMapIndex, const OpCodeMapValueType &theValue)
Set the value of an operation code at a specified index in the OpCode map.
bool hasMoreTokens() const
Whether there are any more tokens in the token queue.
OpCodeMapSizeType getNextOpCodePosition(OpCodeMapSizeType theIndex) const
Retrieve the position of the next operation code at a specified index in the list.
OpCodeMapValueType getOpCodeArgumentLength(OpCodeMapPositionType opPos) const
void insertToken(double theNumber, const XalanDOMString &theString)
Insert a token onto the token queue at the current position.
void setCurrentPattern(const XalanDOMString &thePattern)
Change the current pattern in the pattern map.
OpCodeMapValueType OpCodeMapSizeType
OpCodeMapValueType getOpCodeMapValue(OpCodeMapSizeType theIndex) const
Retrieve the value of an operation code at a specified index in the op code map.
static bool isNodeTestOpCode(OpCodeMapValueType theOpCode)
Whether the operation code is one of the node test types, for example, "ancestor::" or "child::"...
static double toDouble(const XalanDOMString &theString, MemoryManager &theManager)
Convert a string to a double value.
bool isValidTokenQueuePosition(TokenQueueSizeType thePosition) const
void replaceRelativeToken(TokenQueuePositionType theOffset, eRelativeDirection theDirection, const XalanDOMString &theString)
Replace a token in the token queue.
Exception class thrown when an invalid XPath operation code is encountered.
XALAN_CPP_NAMESPACE_BEGIN XALAN_USING_XERCES(Locator)
OpCodeMapValueType getOpCodeLengthFromOpMap(OpCodeMapPositionType opPos, MemoryManager &theManager) const
Retrieve the length of an operation code at a specified position in the op map.
#define XALAN_XPATH_EXPORT
OpCodeMapType::const_iterator OpCodeMapPositionType
void insertToken(const XalanDOMString &theToken)
Insert a token onto the token queue at the current position.
OpCodeMapType::value_type OpCodeMapValueType
OpCodeMapPositionType getInitialOpCodePosition() const
OpCodeMapPositionType getNextOpCodePosition(OpCodeMapPositionType opPos) const
Retrieve the position of the next operation code at a specified position in the list.