source: NonGTP/Xerces/xerces/include/xercesc/validators/schema/identity/XPathMatcherStack.hpp @ 358

Revision 358, 4.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Id: XPathMatcherStack.hpp,v 1.5 2004/09/08 13:56:59 peiyongz Exp $
19 */
20
21#if !defined(XPATHMATCHERSTACK_HPP)
22#define XPATHMATCHERSTACK_HPP
23
24
25// ---------------------------------------------------------------------------
26//  Includes
27// ---------------------------------------------------------------------------
28#include <xercesc/validators/schema/identity/XPathMatcher.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32class VALIDATORS_EXPORT XPathMatcherStack : public XMemory
33{
34public:
35    // -----------------------------------------------------------------------
36    //  Constructors/Destructor
37    // -----------------------------------------------------------------------
38    XPathMatcherStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
39        ~XPathMatcherStack();
40
41        // -----------------------------------------------------------------------
42    //  Getter methods
43    // -----------------------------------------------------------------------
44    XPathMatcher* getMatcherAt(const unsigned int index) const;
45    unsigned int  getMatcherCount() const;
46    unsigned int  size() const;
47
48        // -----------------------------------------------------------------------
49    //  Access methods
50    // -----------------------------------------------------------------------
51    void addMatcher(XPathMatcher* const matcher);
52
53        // -----------------------------------------------------------------------
54    //  Stack methods
55    // -----------------------------------------------------------------------
56    void pushContext();
57    void popContext();
58
59        // -----------------------------------------------------------------------
60    //  Reset methods
61    // -----------------------------------------------------------------------
62    void clear();
63
64private:
65    // -----------------------------------------------------------------------
66    //  Unimplemented contstructors and operators
67    // -----------------------------------------------------------------------
68    XPathMatcherStack(const XPathMatcherStack& other);
69    XPathMatcherStack& operator= (const XPathMatcherStack& other);
70
71    // -----------------------------------------------------------------------
72    //  Data members
73    // -----------------------------------------------------------------------
74    unsigned int                fMatchersCount;
75    ValueStackOf<int>*          fContextStack;
76    RefVectorOf<XPathMatcher>*  fMatchers;
77};
78
79// ---------------------------------------------------------------------------
80//  XPathMatcherStack: Getter methods
81// ---------------------------------------------------------------------------
82inline unsigned int XPathMatcherStack::size() const {
83
84    return fContextStack->size();
85}
86
87inline unsigned int XPathMatcherStack::getMatcherCount() const {
88
89    return fMatchersCount;
90}
91
92inline XPathMatcher*
93XPathMatcherStack::getMatcherAt(const unsigned int index) const {
94
95    return fMatchers->elementAt(index);
96}
97
98// ---------------------------------------------------------------------------
99//  XPathMatcherStack: Stack methods
100// ---------------------------------------------------------------------------
101inline void XPathMatcherStack::pushContext() {
102
103    fContextStack->push(fMatchersCount);
104}
105
106inline void XPathMatcherStack::popContext() {
107
108    fMatchersCount = fContextStack->pop();
109}
110
111// ---------------------------------------------------------------------------
112//  XPathMatcherStack: Access methods
113// ---------------------------------------------------------------------------
114inline void XPathMatcherStack::addMatcher(XPathMatcher* const matcher) {
115
116    if (fMatchersCount == fMatchers->size()) {
117
118        fMatchers->addElement(matcher);
119        fMatchersCount++;
120    }
121    else {
122        fMatchers->setElementAt(matcher, fMatchersCount++);
123    }
124}
125
126XERCES_CPP_NAMESPACE_END
127
128#endif
129
130/**
131  * End of file XPathMatcherStack.hpp
132  */
133
Note: See TracBrowser for help on using the repository browser.