[2674] | 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: XPathMatcherStack.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(XPATHMATCHERSTACK_HPP) |
---|
| 23 | #define XPATHMATCHERSTACK_HPP |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | // --------------------------------------------------------------------------- |
---|
| 27 | // Includes |
---|
| 28 | // --------------------------------------------------------------------------- |
---|
| 29 | #include <xercesc/validators/schema/identity/XPathMatcher.hpp> |
---|
| 30 | |
---|
| 31 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 32 | |
---|
| 33 | class VALIDATORS_EXPORT XPathMatcherStack : public XMemory |
---|
| 34 | { |
---|
| 35 | public: |
---|
| 36 | // ----------------------------------------------------------------------- |
---|
| 37 | // Constructors/Destructor |
---|
| 38 | // ----------------------------------------------------------------------- |
---|
| 39 | XPathMatcherStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 40 | ~XPathMatcherStack(); |
---|
| 41 | |
---|
| 42 | // ----------------------------------------------------------------------- |
---|
| 43 | // Getter methods |
---|
| 44 | // ----------------------------------------------------------------------- |
---|
| 45 | XPathMatcher* getMatcherAt(const unsigned int index) const; |
---|
| 46 | unsigned int getMatcherCount() const; |
---|
| 47 | unsigned int size() const; |
---|
| 48 | |
---|
| 49 | // ----------------------------------------------------------------------- |
---|
| 50 | // Access methods |
---|
| 51 | // ----------------------------------------------------------------------- |
---|
| 52 | void addMatcher(XPathMatcher* const matcher); |
---|
| 53 | |
---|
| 54 | // ----------------------------------------------------------------------- |
---|
| 55 | // Stack methods |
---|
| 56 | // ----------------------------------------------------------------------- |
---|
| 57 | void pushContext(); |
---|
| 58 | void popContext(); |
---|
| 59 | |
---|
| 60 | // ----------------------------------------------------------------------- |
---|
| 61 | // Reset methods |
---|
| 62 | // ----------------------------------------------------------------------- |
---|
| 63 | void clear(); |
---|
| 64 | |
---|
| 65 | private: |
---|
| 66 | // ----------------------------------------------------------------------- |
---|
| 67 | // Private helper methods |
---|
| 68 | // ----------------------------------------------------------------------- |
---|
| 69 | void cleanUp(); |
---|
| 70 | |
---|
| 71 | // ----------------------------------------------------------------------- |
---|
| 72 | // Unimplemented contstructors and operators |
---|
| 73 | // ----------------------------------------------------------------------- |
---|
| 74 | XPathMatcherStack(const XPathMatcherStack& other); |
---|
| 75 | XPathMatcherStack& operator= (const XPathMatcherStack& other); |
---|
| 76 | |
---|
| 77 | // ----------------------------------------------------------------------- |
---|
| 78 | // Data members |
---|
| 79 | // ----------------------------------------------------------------------- |
---|
| 80 | unsigned int fMatchersCount; |
---|
| 81 | ValueStackOf<int>* fContextStack; |
---|
| 82 | RefVectorOf<XPathMatcher>* fMatchers; |
---|
| 83 | }; |
---|
| 84 | |
---|
| 85 | // --------------------------------------------------------------------------- |
---|
| 86 | // XPathMatcherStack: Getter methods |
---|
| 87 | // --------------------------------------------------------------------------- |
---|
| 88 | inline unsigned int XPathMatcherStack::size() const { |
---|
| 89 | |
---|
| 90 | return fContextStack->size(); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | inline unsigned int XPathMatcherStack::getMatcherCount() const { |
---|
| 94 | |
---|
| 95 | return fMatchersCount; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | inline XPathMatcher* |
---|
| 99 | XPathMatcherStack::getMatcherAt(const unsigned int index) const { |
---|
| 100 | |
---|
| 101 | return fMatchers->elementAt(index); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // --------------------------------------------------------------------------- |
---|
| 105 | // XPathMatcherStack: Stack methods |
---|
| 106 | // --------------------------------------------------------------------------- |
---|
| 107 | inline void XPathMatcherStack::pushContext() { |
---|
| 108 | |
---|
| 109 | fContextStack->push(fMatchersCount); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | inline void XPathMatcherStack::popContext() { |
---|
| 113 | |
---|
| 114 | fMatchersCount = fContextStack->pop(); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | // --------------------------------------------------------------------------- |
---|
| 118 | // XPathMatcherStack: Access methods |
---|
| 119 | // --------------------------------------------------------------------------- |
---|
| 120 | inline void XPathMatcherStack::addMatcher(XPathMatcher* const matcher) { |
---|
| 121 | |
---|
| 122 | if (fMatchersCount == fMatchers->size()) { |
---|
| 123 | |
---|
| 124 | fMatchers->addElement(matcher); |
---|
| 125 | fMatchersCount++; |
---|
| 126 | } |
---|
| 127 | else { |
---|
| 128 | fMatchers->setElementAt(matcher, fMatchersCount++); |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | XERCES_CPP_NAMESPACE_END |
---|
| 133 | |
---|
| 134 | #endif |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | * End of file XPathMatcherStack.hpp |
---|
| 138 | */ |
---|
| 139 | |
---|