|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: XPathMatcherStack.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 #if !defined(XPATHMATCHERSTACK_HPP) |
|
39 #define XPATHMATCHERSTACK_HPP |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Includes |
|
44 // --------------------------------------------------------------------------- |
|
45 #include <xercesc/validators/schema/identity/XPathMatcher.hpp> |
|
46 |
|
47 XERCES_CPP_NAMESPACE_BEGIN |
|
48 |
|
49 class VALIDATORS_EXPORT XPathMatcherStack : public XMemory |
|
50 { |
|
51 public: |
|
52 // ----------------------------------------------------------------------- |
|
53 // Constructors/Destructor |
|
54 // ----------------------------------------------------------------------- |
|
55 XPathMatcherStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
|
56 ~XPathMatcherStack(); |
|
57 |
|
58 // ----------------------------------------------------------------------- |
|
59 // Getter methods |
|
60 // ----------------------------------------------------------------------- |
|
61 XPathMatcher* getMatcherAt(const unsigned int index) const; |
|
62 unsigned int getMatcherCount() const; |
|
63 unsigned int size() const; |
|
64 |
|
65 // ----------------------------------------------------------------------- |
|
66 // Access methods |
|
67 // ----------------------------------------------------------------------- |
|
68 void addMatcher(XPathMatcher* const matcher); |
|
69 |
|
70 // ----------------------------------------------------------------------- |
|
71 // Stack methods |
|
72 // ----------------------------------------------------------------------- |
|
73 void pushContext(); |
|
74 void popContext(); |
|
75 |
|
76 // ----------------------------------------------------------------------- |
|
77 // Reset methods |
|
78 // ----------------------------------------------------------------------- |
|
79 void clear(); |
|
80 |
|
81 private: |
|
82 // ----------------------------------------------------------------------- |
|
83 // Private helper methods |
|
84 // ----------------------------------------------------------------------- |
|
85 void cleanUp(); |
|
86 |
|
87 // ----------------------------------------------------------------------- |
|
88 // Unimplemented contstructors and operators |
|
89 // ----------------------------------------------------------------------- |
|
90 XPathMatcherStack(const XPathMatcherStack& other); |
|
91 XPathMatcherStack& operator= (const XPathMatcherStack& other); |
|
92 |
|
93 // ----------------------------------------------------------------------- |
|
94 // Data members |
|
95 // ----------------------------------------------------------------------- |
|
96 unsigned int fMatchersCount; |
|
97 ValueStackOf<int>* fContextStack; |
|
98 RefVectorOf<XPathMatcher>* fMatchers; |
|
99 }; |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // XPathMatcherStack: Getter methods |
|
103 // --------------------------------------------------------------------------- |
|
104 inline unsigned int XPathMatcherStack::size() const { |
|
105 |
|
106 return fContextStack->size(); |
|
107 } |
|
108 |
|
109 inline unsigned int XPathMatcherStack::getMatcherCount() const { |
|
110 |
|
111 return fMatchersCount; |
|
112 } |
|
113 |
|
114 inline XPathMatcher* |
|
115 XPathMatcherStack::getMatcherAt(const unsigned int index) const { |
|
116 |
|
117 return fMatchers->elementAt(index); |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // XPathMatcherStack: Stack methods |
|
122 // --------------------------------------------------------------------------- |
|
123 inline void XPathMatcherStack::pushContext() { |
|
124 |
|
125 fContextStack->push(fMatchersCount); |
|
126 } |
|
127 |
|
128 inline void XPathMatcherStack::popContext() { |
|
129 |
|
130 fMatchersCount = fContextStack->pop(); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // XPathMatcherStack: Access methods |
|
135 // --------------------------------------------------------------------------- |
|
136 inline void XPathMatcherStack::addMatcher(XPathMatcher* const matcher) { |
|
137 |
|
138 if (fMatchersCount == fMatchers->size()) { |
|
139 |
|
140 fMatchers->addElement(matcher); |
|
141 fMatchersCount++; |
|
142 } |
|
143 else { |
|
144 fMatchers->setElementAt(matcher, fMatchersCount++); |
|
145 } |
|
146 } |
|
147 |
|
148 XERCES_CPP_NAMESPACE_END |
|
149 |
|
150 #endif |
|
151 |
|
152 /** |
|
153 * End of file XPathMatcherStack.hpp |
|
154 */ |
|
155 |