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)
608 MemoryManager& theManager);
611 XPathExpressionException();
631 InvalidOpCodeException();
663 InvalidArgumentCountException();
694 InvalidArgumentException();
725 return m_opMap.getMemoryManager();
780 OpCodeMapPositionType
783#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
784 return m_opMap.begin();
796 return theDifference >= 0 &&
800#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
819 return m_opMap[theIndex];
835#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
839 return m_opMap[opPos];
857 m_opMap[theOpCodeMapIndex] = theValue;
875 MemoryManager& theManager)
const;
877#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
887 MemoryManager& theManager)
const;
890#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
915#if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
1097 return m_currentPosition;
1106 m_currentPosition = 0;
1120 return &m_tokenQueue[thePosition];
1133 return getToken(m_currentPosition++);
1149 if (m_currentPosition > 0)
1151 return getToken(--m_currentPosition);
1179 calculateRelativePosition(theOffset, theDirection);
1199 m_tokenQueue.push_back(
1218 m_tokenQueue.push_back(
1234 m_tokenQueue.insert(
1235 m_tokenQueue.begin() + (m_currentPosition - 1),
1254 m_tokenQueue.insert(
1255 m_tokenQueue.begin() + (m_currentPosition - 1),
1275 calculateRelativePosition(theOffset, theDirection);
1278 m_tokenQueue[thePosition].set(
1344 MemoryManager& theMemoryManager)
const;
1356 m_opMap.push_back(theValue);
1409 assert(theIndex >= 0 &&
1430 m_currentPattern = &thePattern;
1441 assert(m_currentPattern != 0);
1443 return *m_currentPattern;
1457 TokenQueuePositionType
1458 calculateRelativePosition(
1459 TokenQueuePositionType theOffset,
1460 eRelativeDirection theDirection)
const
1462 if (theDirection == eRelativeBackward &&
1463 theOffset <= m_currentPosition)
1465 return m_currentPosition - theOffset;
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
static double toDouble(const XalanDOMString &theString, MemoryManager &theManager)
Convert a string to a double value.
InvalidArgumentCountException(OpCodeMapValueType theOpCode, OpCodeMapValueType theExpectedCount, OpCodeMapValueType theSuppliedCount, XalanDOMString &theBuffer)
Construct an InvalidArgumentCountException object.
InvalidArgumentException(OpCodeMapValueType theOpCode, OpCodeMapValueType theValue, XalanDOMString &theBuffer)
Construct an InvalidArgumentException object.
InvalidOpCodeException(OpCodeMapValueType theOpCode, XalanDOMString &theBuffer)
Construct an InvalidOpCodeException object.
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.
@ eOP_MOD
[OP_MOD] [length] {number expression} {number expression}
@ eOP_XPATH
[OP_XPATH] [length] {expression}
@ eOP_EXTFUNCTION
[OP_EXTFUNCTION] (Extension function.) [length] [index to namespace token] [index to function name to...
@ eOP_NOTEQUALS
[OP_NOTEQUALS] [length] {expression} {expression}
@ eNODETYPE_PI
[NODETYPE_PI] [index to token]
@ eOP_UNION
[OP_UNION] [length] {PathExpr}+
@ eENDOP
[ENDOP] Some operators may like to have a terminator.
@ eFROM_PRECEDING_SIBLINGS
@ eOP_MATCHPATTERN
[OP_UNION] [length] {PathExpr}+
@ eOP_FUNCTION_LOCALNAME_1
@ eOP_MULT
[OP_MULT] [length] {number expression} {number expression}
@ eMATCH_IMMEDIATE_ANCESTOR
@ eFROM_DESCENDANTS_OR_SELF
@ eEMPTY
[EMPTY] Empty slot to indicate NULL.
@ eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL
@ eOP_OR
[OP_OR] [length] {boolean expression} {boolean expression}
@ eOP_PREDICATE_WITH_POSITION
[OP_PREDICATE_WITH_POSITION] [length] {expression} [ENDOP] (For safety)
@ eMATCH_ANY_ANCESTOR_WITH_PREDICATE
@ eFROM_ANCESTORS
[FROM_stepType] [length, including predicates] [length of just the step, without the predicates] {nod...
@ eOP_NEG
[OP_NEG] [length] {number expression}
@ eOP_FUNCTION_POSITION
These are values for intrinsic functions which have been compiled directly into the op map.
@ eOP_NUMBERLIT
[OP_NUMBERLIT] (Number literal.) [3] [index to token]
@ eOP_MINUS
[OP_MINUS] [length] {number expression} {number expression}
@ eNODETYPE_NODE
[NODETYPE_NODE] No size or arguments.
@ eOP_GROUP
[OP_GROUP] [length] {expression}
@ eOP_LOCATIONPATH
[OP_LOCATIONPATH] [length] {FROM_stepType} | {function}{predicate}* [ENDOP]
@ eOP_ARGUMENT
[OP_ARGUMENT] (Function argument.) [length] {expression}
@ eELEMWILDCARD
[ELEMWILDCARD] Means ELEMWILDCARD ("*"), used instead of string index in some places.
@ eOP_FUNCTION_STRINGLENGTH_1
@ eOP_LOCATIONPATHPATTERN
[OP_UNION] [length] {PathExpr}+
@ eNODETYPE_TEXT
[NODETYPE_TEXT] No size or arguments.
@ eOP_PLUS
[OP_PLUS] [length] {number expression} {number expression}
@ eOP_PREDICATE
[OP_PREDICATE] [length] {expression} [ENDOP] (For safety)
@ eNODETYPE_ANYELEMENT
[NODETYPE_ANY] No size or arguments.
@ eOP_BOOL
[OP_BOOL] (cast operation) [length] {expression}
@ eOP_FUNCTION_STRINGLENGTH_0
@ eNODETYPE_COMMENT
[NODETYPE_COMMENT] No size or arguments.
@ eOP_GTE
[OP_GTE] (greater-than-or-equals) [length] {number expression} {number expression}
@ eOP_LT
[OP_LT] (less-than) [length] {number expression} {number expression}
@ eOP_FUNCTION_NAMESPACEURI_0
@ eOP_LITERAL
[OP_LITERAL] [3] [index to token]
@ eNODETYPE_ROOT
[NODETYPE_ROOT] No size or arguments.
@ eOP_LTE
[OP_LTE] (less-than-or-equals) [length] {number expression} {number expression}
@ eOP_DIV
[OP_DIV] [length] {number expression} {number expression}
@ eOP_AND
[OP_AND] [length] {boolean expression} {boolean expression}
@ eOP_FUNCTION_NAMESPACEURI_1
@ eFROM_FOLLOWING_SIBLINGS
@ eNODENAME
[NODENAME] [index to ns token or EMPTY] [index to name token]
@ eOP_GT
[OP_GT] (greater-than) [length] {number expression} {number expression}
@ eOP_FUNCTION_LOCALNAME_0
@ eOP_VARIABLE
[OP_VARIABLE] [3] [index to token]
@ eOP_FUNCTION
[OP_FUNCTION] [length] [FUNC_ID] [arg count] {OP_ARGUMENT}* [ENDOP]
@ eOP_EQUALS
[OP_EQUALS] [length] {expression} {expression}
@ eFROM_ANCESTORS_OR_SELF
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
const value_type * const_iterator
ptrdiff_t difference_type
XalanXPathException(const XalanDOMString &theMessage, MemoryManager &theManager)
Construct an XPath exeption object.