source: icXML/icXML-devel/src/xercesc/validators/schema/identity/XPathMatcher.hpp @ 3565

Last change on this file since 3565 was 3565, checked in by cameron, 6 years ago

Updates to xercesc sources

File size: 7.4 KB
RevLine 
[2722]1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: XPathMatcher.hpp 803869 2009-08-13 12:56:21Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XPATHMATCHER_HPP)
23#define XERCESC_INCLUDE_GUARD_XPATHMATCHER_HPP
24
25
26// ---------------------------------------------------------------------------
27//  Includes
28// ---------------------------------------------------------------------------
29#include <xercesc/util/ValueStackOf.hpp>
30#include <xercesc/util/RefVectorOf.hpp>
31#include <icxercesc/framework/XMLBuffer.hpp>
32
33XERCES_CPP_NAMESPACE_BEGIN
34
35// ---------------------------------------------------------------------------
36//  Forward Declaration
37// ---------------------------------------------------------------------------
38class XMLElementDecl;
39class XercesXPath;
40class IdentityConstraint;
41class DatatypeValidator;
42class XMLStringPool;
43class XercesLocationPath;
44class XMLAttr;
45class XercesNodeTest;
46class QName;
47class ValidationContext;
48
49class VALIDATORS_EXPORT XPathMatcher : public XMemory
50{
51public:
52    // -----------------------------------------------------------------------
53    //  Constructors/Destructor
54    // -----------------------------------------------------------------------
[3565]55    XPathMatcher
56    (
57        XercesXPath* const xpath
58        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
59    );
60
61    XPathMatcher
62    (
63        XercesXPath* const xpath
64        , IdentityConstraint* const ic
65        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
66    );
67
68    XPathMatcher
69    (
70        XercesXPath* const     xpath
71        , XMLStringPool* const stringPool
72        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
73    );
74
75    XPathMatcher
76    (
77        XercesXPath* const xpath
78        , IdentityConstraint* const ic
79        , XMLStringPool* const stringPool
80        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
81    );
82
83
84
[2722]85    virtual ~XPathMatcher();
86
87    // -----------------------------------------------------------------------
88    //  Getter methods
89    // -----------------------------------------------------------------------
90    IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
91    MemoryManager* getMemoryManager() const { return fMemoryManager; }
92
93    // -----------------------------------------------------------------------
94    //  Match methods
95    // -----------------------------------------------------------------------
96    /**
97      * Returns true if XPath has been matched.
98      */
99    unsigned char isMatched();
100    virtual int getInitialDepth() const;
101
102    // -----------------------------------------------------------------------
103    //  XMLDocumentHandler methods
104    // -----------------------------------------------------------------------
105    virtual void startDocumentFragment();
106    virtual void startElement(const XMLElementDecl& elemDecl,
107                              const unsigned int urlId,
108                              const XMLCh* const elemPrefix,
109                              const RefVectorOf<XMLAttr>& attrList,
110                              const XMLSize_t attrCount,
111                              ValidationContext* validationContext = 0);
112    virtual void endElement(const XMLElementDecl& elemDecl,
113                            const XMLCh* const elemContent,
114                            ValidationContext* validationContext = 0,
115                            DatatypeValidator* actualValidator = 0);
116
117    enum
118    {
119        XP_MATCHED = 1        // matched any way
120        , XP_MATCHED_A = 3    // matched on the attribute axis
121        , XP_MATCHED_D = 5    // matched on the descendant-or-self axixs
122        , XP_MATCHED_DP = 13  // matched some previous (ancestor) node on the
123                              // descendant-or-self-axis, but not this node
124    };
125
126protected:
127
128    // -----------------------------------------------------------------------
129    //  Match methods
130    // -----------------------------------------------------------------------
131    /**
132      * This method is called when the XPath handler matches the XPath
133      * expression. Subclasses can override this method to provide default
134      * handling upon a match.
135      */
136    virtual void matched(const XMLCh* const content,
137                         DatatypeValidator* const dv, const bool isNil);
138
139    bool matches(const XercesNodeTest* nodeTest, const QName* qName);
140
141private:
142    // -----------------------------------------------------------------------
143    //  Unimplemented constructors and operators
144    // -----------------------------------------------------------------------
145    XPathMatcher(const XPathMatcher&);
146    XPathMatcher& operator=(const XPathMatcher&);
147
148    // -----------------------------------------------------------------------
149    //  Helper methods
150    // -----------------------------------------------------------------------
151    void init(XercesXPath* const xpath);
152    void cleanUp();
153
[3565]154protected:
155
[2722]156    // -----------------------------------------------------------------------
157    //  Data members
158    //
159    //  fMatched
160    //      Indicates whether XPath has been matched or not
161    //
162    //  fNoMatchDepth
163    //      Indicates whether matching is successful for the given xpath
164    //      expression.
165    //
166    //  fCurrentStep
167    //      Stores current step.
168    //
169    //  fStepIndexes
170    //      Integer stack of step indexes.
171    //
172    //  fLocationPaths
173    //  fLocationPathSize
174    //      XPath location path, and its size.
175    //
176    //  fIdentityConstraint
177    //      The identity constraint we're the matcher for.  Only used for
178    //      selectors.
179    //
180    // -----------------------------------------------------------------------
181    XMLSize_t                               fLocationPathSize;
182    unsigned char*                          fMatched;
183    XMLSize_t*                              fNoMatchDepth;
184    XMLSize_t*                              fCurrentStep;
185    RefVectorOf<ValueStackOf<XMLSize_t> >*  fStepIndexes;
186    RefVectorOf<XercesLocationPath>*        fLocationPaths;
187    IdentityConstraint*                     fIdentityConstraint;
[3565]188    XMLStringPool*                          fStringPool;
[2722]189    MemoryManager*                          fMemoryManager;
190};
191
192// ---------------------------------------------------------------------------
193//  XPathMatcher: Helper methods
194// ---------------------------------------------------------------------------
195inline void XPathMatcher::cleanUp() {
196
197    fMemoryManager->deallocate(fMatched);//delete [] fMatched;
198    fMemoryManager->deallocate(fNoMatchDepth);//delete [] fNoMatchDepth;
199    fMemoryManager->deallocate(fCurrentStep);//delete [] fCurrentStep;
200    delete fStepIndexes;
201}
202
203XERCES_CPP_NAMESPACE_END
204
205#endif
206
207/**
208  * End of file XPathMatcher.hpp
209  */
210
Note: See TracBrowser for help on using the repository browser.