Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

XPathProcessorImpl.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #if !defined(XPATHPROCESSORIMPL_HEADER_GUARD_1357924680)
00017 #define XPATHPROCESSORIMPL_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base header file.  Must be first.
00022 #include <xalanc/XPath/XPathDefinitions.hpp>
00023 
00024 
00025 
00026 #include <cstdlib>
00027 #include <map>
00028 #include <vector>
00029 
00030 
00031 
00032 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00033 
00034 
00035 
00036 // Base class header file...
00037 #include <xalanc/XPath/XPathProcessor.hpp>
00038 
00039 
00040 
00041 #include <xalanc/XPath/XPath.hpp>
00042 
00043 
00044 
00045 XALAN_CPP_NAMESPACE_BEGIN
00046 
00047 
00048 
00049 class XalanNode;
00050 
00051 
00052 
00057 class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor
00058 {
00059 public:
00060 
00061 #if defined(XALAN_NO_STD_NAMESPACE)
00062     typedef map<XalanDOMString,
00063                 const XalanDOMString*,
00064                 less<XalanDOMString> >  StringToStringMapType;
00065 
00066 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00067     typedef deque<bool>                 BoolVectorType;
00068 #else
00069     typedef vector<bool>                BoolVectorType;
00070 #endif
00071 #else
00072     typedef std::map<XalanDOMString,
00073                      const XalanDOMString*>     StringToStringMapType;
00074 
00075 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00076     typedef std::deque<bool>            BoolVectorType;
00077 #else
00078     typedef std::vector<bool>           BoolVectorType;
00079 #endif
00080 #endif
00081 
00082     XPathProcessorImpl();
00083 
00084     virtual
00085     ~XPathProcessorImpl();
00086 
00087 
00088     // These are inherited from XPathProcessor...
00089 
00090     virtual void
00091     initXPath(
00092             XPath&                      pathObj,
00093             XPathConstructionContext&   constructionContext,
00094             const XalanDOMString&       expression,
00095             const PrefixResolver&       resolver,
00096             const LocatorType*          locator = 0);
00097 
00098     virtual void
00099     initMatchPattern(
00100             XPath&                      pathObj,
00101             XPathConstructionContext&   constructionContext,
00102             const XalanDOMString&       expression,
00103             const PrefixResolver&       resolver,
00104             const LocatorType*          locator = 0);
00105 
00106 private:
00107 
00114     void
00115     tokenize(const XalanDOMString&  pat);
00116   
00117     void
00118     addToTokenQueue(const XalanDOMString&   s) const;
00119 
00120     void
00121     replaceTokenWithNamespaceToken() const;
00122 
00127     int
00128     mapNSTokens(
00129             const XalanDOMString&   pat,
00130             int                     startSubstring,
00131             int                     posOfNSSep,
00132             int                     posOfScan);
00133 
00139     bool
00140     tokenIs(const XalanDOMString&   s) const;
00141 
00147     bool
00148     tokenIs(const XalanDOMChar*     s) const;
00149 
00155     bool
00156     tokenIs(XalanDOMChar    c) const;
00157 
00165     bool
00166     lookahead(
00167             XalanDOMChar    c,
00168             int             n) const;
00169 
00177     bool
00178     lookahead(
00179             const XalanDOMChar*     s,
00180             int                     n) const;
00181 
00189     bool
00190     lookahead(
00191             const XalanDOMString&   s,
00192             int                     n) const;
00193 
00204     bool
00205     lookbehind( 
00206             char    c,
00207             int     n) const;
00208 
00219     bool
00220     lookbehindHasToken(int  n) const;
00221 
00226     void
00227     nextToken();
00228 
00233     const XalanDOMString&
00234     getTokenRelative(int    theOffset) const;
00235 
00240     void
00241     prevToken();
00242 
00247     void
00248     consumeExpected(XalanDOMChar    expected);
00249 
00250     bool
00251     isCurrentLiteral() const;
00252 
00259     static bool
00260     isAxis(const XalanDOMString&    theToken);
00261 
00268     static bool
00269     isNodeTest(const XalanDOMString&    theToken);
00270 
00274     void
00275     error(const XalanDOMString&     msg) const;
00276 
00280     void
00281     error(const char*   msg) const;
00282 
00286     static XPathExpression::eOpCodes
00287     getFunctionToken(const XalanDOMString&  key)
00288     {
00289         return searchTable(s_functionTable, s_functionTableSize, key).m_opCode;
00290     }
00291 
00295     static XPathExpression::eOpCodes
00296     getNodeTypeToken(const XalanDOMString&  key)
00297     {
00298         return searchTable(s_nodeTypeTable, s_nodeTypeTableSize, key).m_opCode;
00299     }
00300 
00304     static XPathExpression::eOpCodes
00305     getAxisToken(const XalanDOMString&  key)
00306     {
00307         return searchTable(s_axisTable, s_axisTableSize, key).m_opCode;
00308     }
00309 
00316     void
00317     Expr();
00318 
00319 
00327     void
00328     OrExpr();
00329 
00337     void
00338     AndExpr() ;
00339   
00349     int
00350     EqualityExpr(int    opCodePos = -1);
00351 
00364     int
00365     RelationalExpr(int  opCodePos = -1);
00366 
00377     int
00378     AdditiveExpr(int    opCodePos = -1);
00379 
00392     int
00393     MultiplicativeExpr(int  opCodePos = -1);
00394 
00404     void
00405     UnaryExpr();
00406 
00418     void
00419     UnionExpr();
00420 
00432     void
00433     PathExpr();
00434 
00444     void
00445     FilterExpr();
00446   
00456     void
00457     PrimaryExpr();
00458 
00459 
00465     void
00466     Argument();
00467   
00473     void
00474     FunctionCall();
00475 
00476     void
00477     FunctionPosition();
00478 
00479     void
00480     FunctionLast();
00481 
00482     void
00483     FunctionCount();
00484 
00485     void
00486     FunctionNot();
00487 
00488     void
00489     FunctionTrue();
00490 
00491     void
00492     FunctionFalse();
00493 
00494     void
00495     FunctionBoolean();
00496 
00497     void
00498     FunctionName(int    opPos);
00499 
00500     void
00501     FunctionLocalName(int   opPos);
00502 
00503     void
00504     FunctionNumber(int  opPos);
00505 
00506     void
00507     FunctionFloor();
00508 
00509     void
00510     FunctionCeiling();
00511 
00512     void
00513     FunctionRound();
00514 
00515     void
00516     FunctionString(int  opPos);
00517 
00518     void
00519     FunctionStringLength(int    opPos);
00520 
00521     void
00522     FunctionSum();
00523 
00524     void
00525     FunctionNamespaceURI(int    opPos);
00526 
00533     void
00534     LocationPath();
00535   
00543     void
00544     RelativeLocationPath();
00545   
00551     void
00552     Step();
00553   
00559     void
00560     Basis();
00561   
00567     XPathExpression::eOpCodes
00568     AxisName();
00569   
00576     int
00577     NodeTest();
00578 
00584     void
00585     Predicate();
00586 
00592     void
00593     PredicateExpr();
00594   
00600     void
00601     QName();
00602 
00607     void
00608     NCName();
00609   
00618     void
00619     Literal();
00620   
00626     void
00627     Number();
00628 
00635     void
00636     Pattern();
00637 
00646     void
00647     LocationPathPattern();
00648 
00656     void
00657     IdKeyPattern();
00658 
00666     void
00667     RelativePathPattern();
00668 
00674     void
00675     StepPattern();
00676 
00682     void
00683     AbbreviatedNodeTestStep();
00684 
00685     static bool
00686     isValidFunction(const XalanDOMString&   key);
00687 
00688 private:
00689 
00690     int
00691     FunctionCallArguments();
00692 
00693     struct TableEntry
00694     {
00695         const XalanDOMChar*         m_string;
00696 
00697         XPathExpression::eOpCodes   m_opCode;
00698     };
00699 
00700 #if defined(XALAN_STRICT_ANSI_HEADERS)
00701     typedef std::size_t             size_type;
00702 #else
00703     typedef size_t                  size_type;
00704 #endif
00705 
00706     static const TableEntry&
00707     searchTable(
00708         const TableEntry        theTable[],
00709         size_type               theTableSize,
00710         const XalanDOMString&   theString);
00711 
00715     XalanDOMString                  m_token;
00716   
00722     XalanDOMChar                    m_tokenChar;
00723 
00727     XPath*                          m_xpath;
00728 
00732     XPathConstructionContext*       m_constructionContext;
00733 
00737     XPathExpression*                m_expression;
00738 
00742     const PrefixResolver*           m_prefixResolver;
00743 
00744     bool                            m_requireLiterals;
00745 
00746     bool                            m_isMatchPattern;
00747 
00748     const LocatorType*              m_locator;
00749 
00750     BoolVectorType                  m_positionPredicateStack;
00751 
00752     StringToStringMapType           m_namespaces;
00753 
00754 
00755     // Static stuff here...
00756     static const XalanDOMString     s_emptyString;
00757 
00758     static const XalanDOMChar       s_functionIDString[];
00759 
00760     // This shouldn't really be here, since it's not part of the XPath standard,
00761     // but rather a part ofthe XSLT standard.
00762     static const XalanDOMChar       s_functionKeyString[];
00763 
00764     static const XalanDOMChar       s_orString[];
00765 
00766     static const XalanDOMChar       s_andString[];
00767 
00768     static const XalanDOMChar       s_divString[];
00769 
00770     static const XalanDOMChar       s_modString[];
00771 
00772     static const XalanDOMChar       s_dotString[];
00773 
00774     static const XalanDOMChar       s_dotDotString[];
00775 
00776     static const XalanDOMChar       s_axisString[];
00777 
00778     static const XalanDOMChar       s_attributeString[];
00779 
00780     static const XalanDOMChar       s_childString[];
00781 
00782     static const XalanDOMChar       s_lastString[];
00783 
00784     static const XalanDOMChar       s_positionString[];
00785 
00786     static const XalanDOMChar       s_asteriskString[];
00787 
00788     static const XalanDOMChar       s_commentString[];
00789 
00790     static const XalanDOMChar       s_piString[];
00791 
00792     static const XalanDOMChar       s_nodeString[];
00793 
00794     static const XalanDOMChar       s_textString[];
00795 
00796     static const XalanDOMChar       s_ancestorString[];
00797 
00798     static const XalanDOMChar       s_ancestorOrSelfString[];
00799 
00800     static const XalanDOMChar       s_descendantString[];
00801 
00802     static const XalanDOMChar       s_descendantOrSelfString[];
00803 
00804     static const XalanDOMChar       s_followingString[];
00805 
00806     static const XalanDOMChar       s_followingSiblingString[];
00807 
00808     static const XalanDOMChar       s_parentString[];
00809 
00810     static const XalanDOMChar       s_precedingString[];
00811 
00812     static const XalanDOMChar       s_precedingSiblingString[];
00813 
00814     static const XalanDOMChar       s_selfString[];
00815 
00816     static const XalanDOMChar       s_namespaceString[];
00817 
00818     static const TableEntry         s_functionTable[];
00819 
00820     static const size_type          s_functionTableSize;
00821 
00822     static const TableEntry         s_nodeTypeTable[];
00823 
00824     static const size_type          s_nodeTypeTableSize;
00825 
00826     static const TableEntry         s_axisTable[];
00827 
00828     static const size_type          s_axisTableSize;
00829 
00830     static const TableEntry         s_dummyEntry;
00831 };
00832 
00833 
00834 
00835 XALAN_CPP_NAMESPACE_END
00836 
00837 
00838 
00839 #endif  // XPATHPROCESSORIMPL_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.