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