Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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 
00028 
00029 
00030 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00031 
00032 
00033 
00034 #include <xalanc/Include/XalanVector.hpp>
00035 #include <xalanc/Include/XalanMap.hpp>
00036 
00037 
00038 
00039 #include "xalanc/PlatformSupport/XalanMessageLoader.hpp"
00040 
00041 
00042 
00043 // Base class header file...
00044 #include <xalanc/XPath/XPathProcessor.hpp>
00045 
00046 
00047 
00048 #include <xalanc/XPath/XPath.hpp>
00049 
00050 
00051 
00052 XALAN_CPP_NAMESPACE_BEGIN
00053 
00054 
00055 
00056 class XalanNode;
00057 
00058 
00059 
00064 class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor
00065 {
00066 public:
00067 
00068     typedef XalanMap<XalanDOMString,
00069                 const XalanDOMString*>  StringToStringMapType;
00070 
00071     typedef XalanVector<bool>               BoolVectorType;
00072 
00073     XPathProcessorImpl(MemoryManagerType& theManager XALAN_DEFAULT_MEMMGR);
00074 
00075     virtual
00076     ~XPathProcessorImpl();
00077 
00078 
00079     static XPathProcessorImpl*
00080     create(MemoryManagerType& theManager);
00081     // These are inherited from XPathProcessor...
00082 
00083     virtual void
00084     initXPath(
00085             XPath&                      pathObj,
00086             XPathConstructionContext&   constructionContext,
00087             const XalanDOMString&       expression,
00088             const PrefixResolver&       resolver,
00089             const LocatorType*          locator = 0,
00090             bool                        allowVariableReferences = true,
00091             bool                        allowKeyFunction = true);
00092 
00093     virtual void
00094     initMatchPattern(
00095             XPath&                      pathObj,
00096             XPathConstructionContext&   constructionContext,
00097             const XalanDOMString&       expression,
00098             const PrefixResolver&       resolver,
00099             const LocatorType*          locator = 0,
00100             bool                        allowVariableReferences = true,
00101             bool                        allowKeyFunction = true);
00102 
00103 private:
00104 
00111     void
00112     tokenize(const XalanDOMString&  pat);
00113   
00114     void
00115     addToTokenQueue(const XalanDOMString&   s) const;
00116 
00117     void
00118     replaceTokenWithNamespaceToken() const;
00119 
00124     int
00125     mapNSTokens(
00126             const XalanDOMString&   pat,
00127             int                     startSubstring,
00128             int                     posOfNSSep,
00129             int                     posOfScan);
00130 
00136     bool
00137     tokenIs(const XalanDOMString&   s) const;
00138 
00144     bool
00145     tokenIs(const XalanDOMChar*     s) const;
00146 
00152     bool
00153     tokenIs(XalanDOMChar    c) const;
00154 
00162     bool
00163     lookahead(
00164             XalanDOMChar    c,
00165             int             n) const;
00166 
00174     bool
00175     lookahead(
00176             const XalanDOMChar*     s,
00177             int                     n) const;
00178 
00186     bool
00187     lookahead(
00188             const XalanDOMString&   s,
00189             int                     n) const;
00190 
00201     bool
00202     lookbehind( 
00203             char    c,
00204             int     n) const;
00205 
00216     bool
00217     lookbehindHasToken(int  n) const;
00218 
00223     bool
00224     nextToken();
00225 
00230     const XalanDOMString&
00231     getTokenRelative(int    theOffset) const;
00232 
00237     void
00238     prevToken();
00239 
00244     void
00245     consumeExpected(XalanDOMChar    expected);
00246 
00247     bool
00248     isCurrentLiteral() const;
00249 
00256     static bool
00257     isAxis(const XalanDOMString&    theToken);
00258 
00265     static bool
00266     isNodeTest(const XalanDOMString&    theToken);
00267 
00271     void
00272     error(const XalanDOMString&     msg) const;
00273 
00277     void
00278     error(XalanMessages::Codes  theCode) const;
00279 
00280     void
00281     error(
00282             XalanMessages::Codes    theCode,
00283             const XalanDOMString&   theToken) const;
00284 
00285     void
00286     error(
00287             XalanMessages::Codes    theCode,
00288             const XalanDOMChar*     theToken) const;
00289 
00290     void
00291     error(
00292             XalanMessages::Codes    theCode,
00293             XalanDOMChar            theToken1,
00294             const XalanDOMString&   theToken2) const;
00295 
00299     static XPathExpression::eOpCodes
00300     getFunctionToken(const XalanDOMString&  key)
00301     {
00302         return searchTable(s_functionTable, s_functionTableSize, key).m_opCode;
00303     }
00304 
00308     static XPathExpression::eOpCodes
00309     getNodeTypeToken(const XalanDOMString&  key)
00310     {
00311         return searchTable(s_nodeTypeTable, s_nodeTypeTableSize, key).m_opCode;
00312     }
00313 
00317     static XPathExpression::eOpCodes
00318     getAxisToken(const XalanDOMString&  key)
00319     {
00320         return searchTable(s_axisTable, s_axisTableSize, key).m_opCode;
00321     }
00322 
00329     void
00330     Expr();
00331 
00332 
00340     void
00341     OrExpr();
00342 
00350     void
00351     AndExpr() ;
00352   
00362     int
00363     EqualityExpr(int    opCodePos = -1);
00364 
00377     int
00378     RelationalExpr(int  opCodePos = -1);
00379 
00390     int
00391     AdditiveExpr(int    opCodePos = -1);
00392 
00405     int
00406     MultiplicativeExpr(int  opCodePos = -1);
00407 
00417     void
00418     UnaryExpr();
00419 
00431     void
00432     UnionExpr();
00433 
00445     void
00446     PathExpr();
00447 
00457     void
00458     FilterExpr();
00459   
00469     void
00470     PrimaryExpr();
00471 
00472 
00478     void
00479     Argument();
00480   
00486     void
00487     FunctionCall();
00488 
00489     void
00490     FunctionPosition();
00491 
00492     void
00493     FunctionLast();
00494 
00495     void
00496     FunctionCount();
00497 
00498     void
00499     FunctionNot();
00500 
00501     void
00502     FunctionTrue();
00503 
00504     void
00505     FunctionFalse();
00506 
00507     void
00508     FunctionBoolean();
00509 
00510     void
00511     FunctionName(int    opPos);
00512 
00513     void
00514     FunctionLocalName(int   opPos);
00515 
00516     void
00517     FunctionNumber(int  opPos);
00518 
00519     void
00520     FunctionFloor();
00521 
00522     void
00523     FunctionCeiling();
00524 
00525     void
00526     FunctionRound();
00527 
00528     void
00529     FunctionString(int  opPos);
00530 
00531     void
00532     FunctionStringLength(int    opPos);
00533 
00534     void
00535     FunctionSum();
00536 
00537     void
00538     FunctionNamespaceURI(int    opPos);
00539 
00546     void
00547     LocationPath();
00548   
00556     void
00557     RelativeLocationPath();
00558   
00564     void
00565     Step();
00566   
00572     void
00573     Basis();
00574   
00580     XPathExpression::eOpCodes
00581     AxisName();
00582   
00589     int
00590     NodeTest();
00591 
00597     void
00598     Predicate();
00599 
00605     void
00606     PredicateExpr();
00607   
00613     void
00614     QName();
00615 
00620     void
00621     NCName();
00622   
00631     void
00632     Literal();
00633   
00639     void
00640     Number();
00641 
00648     void
00649     Pattern();
00650 
00659     void
00660     LocationPathPattern();
00661 
00669     void
00670     IdKeyPattern();
00671 
00679     void
00680     RelativePathPattern();
00681 
00687     void
00688     StepPattern();
00689 
00695     void
00696     AbbreviatedNodeTestStep();
00697 
00698     static bool
00699     isValidFunction(const XalanDOMString&   key);
00700 
00701 private:
00702 
00703     int
00704     FunctionCallArguments();
00705 
00706     struct TableEntry
00707     {
00708         const XalanDOMChar*         m_string;
00709 
00710         XPathExpression::eOpCodes   m_opCode;
00711     };
00712 
00713 #if defined(XALAN_STRICT_ANSI_HEADERS)
00714     typedef std::size_t             size_type;
00715 #else
00716     typedef size_t                  size_type;
00717 #endif
00718 
00719     static const TableEntry&
00720     searchTable(
00721         const TableEntry        theTable[],
00722         size_type               theTableSize,
00723         const XalanDOMString&   theString);
00724 
00728     XalanDOMString                  m_token;
00729   
00735     XalanDOMChar                    m_tokenChar;
00736 
00740     XPath*                          m_xpath;
00741 
00745     XPathConstructionContext*       m_constructionContext;
00746 
00750     XPathExpression*                m_expression;
00751 
00755     const PrefixResolver*           m_prefixResolver;
00756 
00757     bool                            m_requireLiterals;
00758 
00759     bool                            m_isMatchPattern;
00760 
00761     const LocatorType*              m_locator;
00762 
00763     BoolVectorType                  m_positionPredicateStack;
00764 
00765     StringToStringMapType           m_namespaces;
00766 
00767     bool                            m_allowVariableReferences;
00768 
00769     bool                            m_allowKeyFunction;
00770 
00771     // Static stuff here...
00772     static const XalanDOMString     s_emptyString;
00773 
00774     static const XalanDOMChar       s_functionIDString[];
00775 
00776     // This shouldn't really be here, since it's not part of the XPath standard,
00777     // but rather a part ofthe XSLT standard.
00778     static const XalanDOMChar       s_functionKeyString[];
00779 
00780     static const XalanDOMChar       s_orString[];
00781 
00782     static const XalanDOMChar       s_andString[];
00783 
00784     static const XalanDOMChar       s_divString[];
00785 
00786     static const XalanDOMChar       s_modString[];
00787 
00788     static const XalanDOMChar       s_dotString[];
00789 
00790     static const XalanDOMChar       s_dotDotString[];
00791 
00792     static const XalanDOMChar       s_axisString[];
00793 
00794     static const XalanDOMChar       s_attributeString[];
00795 
00796     static const XalanDOMChar       s_childString[];
00797 
00798     static const XalanDOMChar       s_lastString[];
00799 
00800     static const XalanDOMChar       s_positionString[];
00801 
00802     static const XalanDOMChar       s_asteriskString[];
00803 
00804     static const XalanDOMChar       s_commentString[];
00805 
00806     static const XalanDOMChar       s_piString[];
00807 
00808     static const XalanDOMChar       s_nodeString[];
00809 
00810     static const XalanDOMChar       s_textString[];
00811 
00812     static const XalanDOMChar       s_ancestorString[];
00813 
00814     static const XalanDOMChar       s_ancestorOrSelfString[];
00815 
00816     static const XalanDOMChar       s_descendantString[];
00817 
00818     static const XalanDOMChar       s_descendantOrSelfString[];
00819 
00820     static const XalanDOMChar       s_followingString[];
00821 
00822     static const XalanDOMChar       s_followingSiblingString[];
00823 
00824     static const XalanDOMChar       s_parentString[];
00825 
00826     static const XalanDOMChar       s_precedingString[];
00827 
00828     static const XalanDOMChar       s_precedingSiblingString[];
00829 
00830     static const XalanDOMChar       s_selfString[];
00831 
00832     static const XalanDOMChar       s_namespaceString[];
00833 
00834     static const TableEntry         s_functionTable[];
00835 
00836     static const size_type          s_functionTableSize;
00837 
00838     static const TableEntry         s_nodeTypeTable[];
00839 
00840     static const size_type          s_nodeTypeTableSize;
00841 
00842     static const TableEntry         s_axisTable[];
00843 
00844     static const size_type          s_axisTableSize;
00845 
00846     static const TableEntry         s_dummyEntry;
00847 };
00848 
00849 
00850 
00851 XALAN_CPP_NAMESPACE_END
00852 
00853 
00854 
00855 #endif  // XPATHPROCESSORIMPL_HEADER_GUARD_1357924680

Interpreting class diagrams

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

dot

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

Apache Logo