18#if !defined(XPATHEXPRESSION_HEADER_GUARD_1357924680)
19#define XPATHEXPRESSION_HEADER_GUARD_1357924680
54using xercesc::MemoryManager;
74#define XALAN_XPATH_EXPRESSION_USE_ITERATORS
76#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
388 eOP_EXTFUNCTION = 23,
421 eOP_LOCATIONPATH = 25,
441 eNODETYPE_COMMENT = 27,
496 eNODETYPE_ANYELEMENT = 33,
508 eFROM_ANCESTORS = 34,
509 eFROM_ANCESTORS_OR_SELF = 35,
510 eFROM_ATTRIBUTES = 36,
512 eFROM_DESCENDANTS = 38,
513 eFROM_DESCENDANTS_OR_SELF = 39,
514 eFROM_FOLLOWING = 40,
515 eFROM_FOLLOWING_SIBLINGS = 41,
517 eFROM_PRECEDING = 43,
518 eFROM_PRECEDING_SIBLINGS = 44,
520 eFROM_NAMESPACE = 46,
531 eOP_MATCHPATTERN = 48,
541 eOP_LOCATIONPATHPATTERN = 49,
544 eMATCH_ATTRIBUTE = 50,
545 eMATCH_ANY_ANCESTOR = 51,
546 eMATCH_IMMEDIATE_ANCESTOR = 52,
547 eMATCH_ANY_ANCESTOR_WITH_PREDICATE = 53,
548 eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL = 54,
559 eOP_PREDICATE_WITH_POSITION = 55,
565 eOP_FUNCTION_POSITION = 56,
566 eOP_FUNCTION_LAST = 57,
567 eOP_FUNCTION_COUNT = 58,
568 eOP_FUNCTION_NOT = 59,
569 eOP_FUNCTION_TRUE = 60,
570 eOP_FUNCTION_FALSE = 61,
571 eOP_FUNCTION_BOOLEAN = 62,
572 eOP_FUNCTION_NAME_0 = 63,
573 eOP_FUNCTION_NAME_1 = 64,
574 eOP_FUNCTION_LOCALNAME_0 = 65,
575 eOP_FUNCTION_LOCALNAME_1 = 66,
576 eOP_FUNCTION_FLOOR = 67,
577 eOP_FUNCTION_CEILING = 68,
578 eOP_FUNCTION_ROUND = 69,
579 eOP_FUNCTION_NUMBER_0 = 70,
580 eOP_FUNCTION_NUMBER_1 = 71,
581 eOP_FUNCTION_STRING_0 = 72,
582 eOP_FUNCTION_STRING_1 = 73,
583 eOP_FUNCTION_STRINGLENGTH_0 = 74,
584 eOP_FUNCTION_STRINGLENGTH_1 = 75,
585 eOP_FUNCTION_NAMESPACEURI_0 = 76,
586 eOP_FUNCTION_NAMESPACEURI_1 = 77,
587 eOP_FUNCTION_SUM = 78,
588 eOP_FUNCTION_CONCAT = 79,
714 s_opCodeMapLengthIndex = 1
725 return m_opMap.getMemoryManager();
766 if (
theSize > s_opCodeMapLengthIndex)
770 return m_opMap[s_opCodeMapLengthIndex];
780 OpCodeMapPositionType
783#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
784 return m_opMap.begin();
800#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
833 assert(
opPos < getInitialOpCodePosition() + opCodeMapLength());
835#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
839 return m_opMap[
opPos];
863 return getOpCodeMapValue(
opPos + XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
877#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
890#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
901 assert(
opPos < getInitialOpCodePosition() + opCodeMapLength());
903 return opPos + *(
opPos + s_opCodeMapLengthIndex);
915#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
1069 return tokenQueueSize() > m_currentPosition ?
true :
false;
1097 return m_currentPosition;
1106 m_currentPosition = 0;
1131 if (hasMoreTokens() ==
true)
1133 return getToken(m_currentPosition++);
1149 if (m_currentPosition > 0)
1151 return getToken(--m_currentPosition);
1199 m_tokenQueue.push_back(
1202 DoubleSupport::toDouble(
theToken, getMemoryManager()),
1204 getMemoryManager()));
1218 m_tokenQueue.push_back(
1222 getMemoryManager()));
1234 m_tokenQueue.insert(
1235 m_tokenQueue.begin() + (m_currentPosition - 1),
1238 DoubleSupport::toDouble(
theToken, getMemoryManager()),
1239 getMemoryManager()));
1254 m_tokenQueue.insert(
1255 m_tokenQueue.begin() + (m_currentPosition - 1),
1259 getMemoryManager()));
1280 DoubleSupport::toDouble(
theString, getMemoryManager()));
1359 ++m_opMap[s_opCodeMapLengthIndex];
1441 assert(m_currentPattern != 0);
1443 return *m_currentPattern;
1457 TokenQueuePositionType
1458 calculateRelativePosition(
1467 else if (theDirection == eRelativeForward &&
1468 m_currentPosition + theOffset < tokenQueueSize())
1470 return m_currentPosition + theOffset;
1474 return tokenQueueSize();
1484 OpCodeMapType m_opMap;
1490 OpCodeMapSizeType m_lastOpCodeIndex;
1497 TokenQueueType m_tokenQueue;
1502 TokenQueueSizeType m_currentPosition;
1507 const XalanDOMString* m_currentPattern;
1512 eDefaultOpMapSize = 100,
1513 eDefaultTokenQueueSize = 30
1516 NumberLiteralValueVectorType m_numberLiteralValues;
#define XALAN_XPATH_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Exception class thrown when an invalid number of XPath arguments is encountered.
InvalidArgumentCountException(OpCodeMapValueType theOpCode, OpCodeMapValueType theExpectedCount, OpCodeMapValueType theSuppliedCount, XalanDOMString &theBuffer)
Construct an InvalidArgumentCountException object.
Exception class thrown when an invalid XPath argument is encountered.
InvalidArgumentException(OpCodeMapValueType theOpCode, OpCodeMapValueType theValue, XalanDOMString &theBuffer)
Construct an InvalidArgumentException object.
Exception class thrown when an invalid XPath operation code is encountered.
InvalidOpCodeException(OpCodeMapValueType theOpCode, XalanDOMString &theBuffer)
Construct an InvalidOpCodeException object.
Exception class thrown when an invalid XPath expression is encountered.
XPathExpressionException(const XalanDOMString &theMessage, MemoryManager &theManager)
Construct an XPathExpressionException object.
void reset()
Reset the expression.
void dumpOpCodeMap(OstreamType &theStream, OpCodeMapSizeType theStartPosition=0) const
Diagnostic function to output the operation code map.
XPathExpression(MemoryManager &theManager)
void dumpRemainingTokenQueue(PrintWriter &thePrintWriter) const
Diagnostic function to output the remaining tokens in the token queue.
void updateOpCodeLengthAfterNodeTest(OpCodeMapSizeType theIndex)
Update the length of an operation code after a node test code.
const XToken * getNextToken()
Retrieve the next token in the token queue.
OpCodeMapValueType insertOpCode(eOpCodes theOpCode, OpCodeMapSizeType theIndex)
Insert an operation code at a specified index in the list.
void insertToken(const XalanDOMString &theToken)
Insert a token onto the token queue at the current position.
XalanVector< XToken > TokenQueueType
const XToken * getRelativeToken(TokenQueuePositionType theOffset, eRelativeDirection theDirection) const
Retrieve a token at the specified offset relative to the current position in the token queue.
eDummy
The length is always the opcode position + 1.
OpCodeMapSizeType opCodeMapSize() const
Retrieve number of elements in the operations code map.
XalanVector< OpCodeMapValueType > OpCodeMapValueVectorType
void setOpCodeMapValue(OpCodeMapSizeType theOpCodeMapIndex, const OpCodeMapValueType &theValue)
Set the value of an operation code at a specified index in the OpCode map.
static bool isNodeTestOpCode(OpCodeMapValueType theOpCode)
Whether the operation code is one of the node test types, for example, "ancestor::" or "child::".
MemoryManager & getMemoryManager()
void pushValueOnOpCodeMap(const OpCodeMapType::value_type &theValue)
Push a value onto the operations code map.
void pushToken(double theNumber, const XalanDOMString &theString)
Push a token onto the token queue.
bool isValidTokenQueuePosition(TokenQueueSizeType thePosition) const
const XToken * getToken(TokenQueuePositionType thePosition) const
Retrieve a token at the specified position in the token queue.
XalanVector< double > NumberLiteralValueVectorType
OpCodeMapType::const_iterator OpCodeMapPositionType
void dumpOpCodeMap(PrintWriter &thePrintWriter, OpCodeMapSizeType theStartPosition=0) const
Diagnostic function to output the operation code map.
void pushCurrentTokenOnOpCodeMap()
Push the current position in the token queue onto the operations code map.
double getNumberLiteral(int theIndex) const
Get a number literal from the vector of number literals.
OpCodeMapValueType getOpCodeMapValue(OpCodeMapSizeType theIndex) const
Retrieve the value of an operation code at a specified index in the op code map.
void updateOpCodeLength(OpCodeMapValueType theOpCode, OpCodeMapSizeType theIndex)
Update the length of an operation code at a specified index in the list.
void pushArgumentOnOpCodeMap(double theNumber, const XalanDOMString &theString)
Push a token onto the token queue and its index onto the operations code map.
TokenQueueSizeType getTokenPosition() const
Retrieve the current position in the token queue.
bool isValidOpCodePosition(OpCodeMapPositionType opPos) const
XalanVector< int > OpCodeMapType
void pushNumberLiteralOnOpCodeMap(double theNumber)
Push a number literal onto the vector of number literals and its index onto the operations code map.
void pushArgumentOnOpCodeMap(const XToken &theXToken)
Push a token onto the token queue and its index onto the operations code map.
OpCodeMapValueType getOpCodeArgumentLength(OpCodeMapPositionType opPos) const
OpCodeMapSizeType getNextOpCodePosition(OpCodeMapSizeType theIndex) const
Retrieve the position of the next operation code at a specified index in the list.
OpCodeMapSizeType appendOpCode(eOpCodes theOpCode)
Add an operation code to the list.
void replaceOpCode(OpCodeMapSizeType theIndex, eOpCodes theOldOpCode, eOpCodes theNewOpCode)
Replace an operation code with supplied code.
void pushArgumentOnOpCodeMap(const XalanDOMString &theString)
Push a token onto the token queue and its index onto the operations code map.
bool hasMoreTokens() const
Whether there are any more tokens in the token queue.
OpCodeMapType::value_type OpCodeMapValueType
TokenQueueSizeType tokenQueueSize() const
Retrieve number of elements in the token queue.
void updateOpCodeLength(OpCodeMapSizeType theIndex)
Update the length of an operation code at a specified index in the list.
TokenQueueSizeType TokenQueuePositionType
void dumpTokenQueue(OstreamType &theStream, TokenQueueSizeType theStartPosition=0) const
Diagnostic function to output the token queue.
void setOpCodeArgs(eOpCodes theOpCode, OpCodeMapSizeType theIndex, const OpCodeMapValueVectorType &theArgs)
Set the arguments for an operation code at a specified index in the list.
void replaceRelativeToken(TokenQueuePositionType theOffset, eRelativeDirection theDirection, const XalanDOMString &theString)
Replace a token in the token queue.
void pushToken(const XalanDOMString &theToken)
Push a token onto the token queue.
void shrink()
Shrink internal tables.
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.
OpCodeMapValueType opCodeMapLength() const
Retrieve length of the operations code map stored in the map.
OpCodeMapPositionType getInitialOpCodePosition() const
const XToken * getPreviousToken()
Retrieve the previous token in the token queue.
void dumpTokenQueue(PrintWriter &thePrintWriter, TokenQueueSizeType theStartPosition=0) const
Diagnostic function to output the token queue.
void setCurrentPattern(const XalanDOMString &thePattern)
Change the current pattern in the pattern map.
OpCodeMapSizeType appendOpCode(eOpCodes theOpCode, const OpCodeMapValueVectorType &theArgs)
Add an operation code with supplied arguments to the list.
void insertToken(double theNumber, const XalanDOMString &theString)
Insert a token onto the token queue at the current position.
TokenQueueType::value_type TokenQueueValueType
bool isValidOpCodePosition(OpCodeMapSizeType theIndex) const
OpCodeMapPositionType getNextOpCodePosition(OpCodeMapPositionType opPos) const
Retrieve the position of the next operation code at a specified position in the list.
OpCodeMapValueType getOpCodeLengthFromOpMap(OpCodeMapSizeType theIndex, MemoryManager &theManager) const
Retrieve the length of an operation code at a specified index in the op map.
eOpCodes
List of operations codes.
void resetTokenPosition()
Set the current position in the token queue to zero.
const XalanDOMString & getCurrentPattern() const
Retrieve the current pattern in the pattern map.
OpCodeMapValueType getOpCodeLengthFromOpMap(OpCodeMapPositionType opPos, MemoryManager &theManager) const
Retrieve the length of an operation code at a specified position in the op map.
OpCodeMapType::difference_type OpCodeMapDifferenceType
OpCodeMapValueType getOpCodeMapValue(OpCodeMapPositionType opPos) const
Retrieve the value of an operation code at a specified position in the list.
void dumpRemainingTokenQueue(OstreamType &theStream, MemoryManager &theMemoryManager) const
Diagnostic function to output the remaining tokens in the token queue.
OpCodeMapValueType OpCodeMapSizeType