Xalan-C++ API Reference 1.12.0
XalanNamespacesStack.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#if !defined(XALAN_XALANNAMESPACESSTACK_HEADER_GUARD)
19#define XALAN_XALANNAMESPACESSTACK_HEADER_GUARD
20
21
22
23// Base include file. Must be first.
25
26
27
30
31
32
35
36
37
38namespace XALAN_CPP_NAMESPACE {
39
40
41class XalanDOMString;
42
43
44
46{
47public:
48
50 {
51 public:
52
53 /**
54 * Construct a PrefixResolver from a XalanNamespaceStack
55 * instance.
56 *
57 * @param theStack The stack to use for prefix resolution
58 * @param theURI The namespace URI of the resolver, if any. Only a reference is kept, so this cannot be a temporary
59 * @return pointer to the string value if found, otherwise 0.
60 */
62 const XalanNamespacesStack& theStack,
63 const XalanDOMString& theURI);
64
65 virtual
67
68 virtual const XalanDOMString*
70
71 virtual const XalanDOMString&
72 getURI() const;
73
74 private:
75
76 const XalanNamespacesStack& m_stack;
77
78 const XalanDOMString& m_uri;
79 };
80
82 {
83 public:
84
86
88
89 typedef const XalanDOMString& (value_type::*MemberFunctionType)() const;
90
95
96 XalanNamespacesStackEntry(MemoryManager& theManager);
97
99 MemoryManager& theManager);
100
102
105 MemoryManager& theManager);
106
107 void
109 const XalanDOMString& thePrefix,
110 const XalanDOMChar* theNamespaceURI,
111 XalanDOMString::size_type theLength);
112
113 /**
114 * Get the namespace for a prefix.
115 *
116 * @param thePrefix The prefix to find
117 * @return pointer to the string value if found, otherwise 0.
118 */
119 const XalanDOMString*
120 getNamespaceForPrefix(const XalanDOMString& thePrefix) const
121 {
122 return findEntry(thePrefix, &XalanNamespace::getPrefix, &XalanNamespace::getURI);
123 }
124
125 /**
126 * Get the prefix for a namespace.
127 *
128 * @param theURI The namespace URI to find
129 * @return pointer to the string value if found, otherwise 0.
130 */
131 const XalanDOMString*
133 {
134 return findEntry(theURI, &XalanNamespace::getURI, &XalanNamespace::getPrefix);
135 }
136
137 bool
138 isPrefixPresent(const XalanDOMString& thePrefix) const
139 {
140 return getNamespaceForPrefix(thePrefix) == 0 ? false : true;
141 }
142
145 {
146 return m_namespaces.begin();
147 }
148
150 begin() const
151 {
152 return m_namespaces.begin();
153 }
154
157 {
158 return m_position;
159 }
160
162 end() const
163 {
164 return const_iterator(m_position);
165 }
166
169 {
170 return reverse_iterator(end());
171 }
172
174 rbegin() const
175 {
176 return const_reverse_iterator(end());
177 }
178
181 {
182 return reverse_iterator(begin());
183 }
184
186 rend() const
187 {
188 return const_reverse_iterator(begin());
189 }
190
191 void
193
194 void
196 {
197 m_position = m_namespaces.begin();
198 }
199
200 void
202
203 private:
204 //Not implemented
207
208 const XalanDOMString*
209 findEntry(
210 const XalanDOMString& theKey,
211 MemberFunctionType theKeyFunction,
212 MemberFunctionType theValueFunction) const;
213
214 NamespaceCollectionType m_namespaces;
215
216 iterator m_position;
217 };
218
219
221
224
229
231
233
234
235 explicit
236 XalanNamespacesStack(MemoryManager& theManager);
237
239
240 void
242 const XalanDOMString& thePrefix,
243 const XalanDOMString& theURI)
244 {
245 addDeclaration(
246 thePrefix,
247 theURI.c_str(),
248 theURI.length());
249 }
250
251 void
253 const XalanDOMString& thePrefix,
254 const XalanDOMChar* theURI)
255 {
256 addDeclaration(
257 thePrefix,
258 theURI,
259 length(theURI));
260 }
261
262 void
264 const XalanDOMString& thePrefix,
265 const XalanDOMChar* theURI,
266 XalanDOMString::size_type theLength);
267
268 void
270
271 void
273
274 const XalanDOMString*
275 getNamespaceForPrefix(const XalanDOMString& thePrefix) const;
276
277 const XalanDOMString*
279 {
280 return findEntry(theURI, &value_type::getPrefixForNamespace);
281 }
282
283 /**
284 * See if the prefix has been mapped to a namespace in the current
285 * context, without looking down the stack of namespaces.
286 */
287 bool
289
290 void
292
295 {
296 return m_stackBegin + 1;
297 }
298
299 const_iterator
300 begin() const
301 {
302 return const_iterator(m_stackBegin + 1);
303 }
304
305 iterator
307 {
308 return m_stackPosition + 1;
309 }
310
311 const_iterator
312 end() const
313 {
314 return const_iterator(m_stackPosition + 1);
315 }
316
317 reverse_iterator
319 {
320 return reverse_iterator(end());
321 }
322
323 const_reverse_iterator
324 rbegin() const
325 {
326 return const_reverse_iterator(end());
327 }
328
329 reverse_iterator
331 {
332 return reverse_iterator(begin());
333 }
334
335 const_reverse_iterator
336 rend() const
337 {
338 return const_reverse_iterator(begin());
339 }
340
342 size() const
343 {
344 return m_resultNamespaces.size() - 1;
345 }
346
347 bool
348 empty() const
349 {
350 return NamespacesStackType::const_iterator(m_stackPosition) == m_resultNamespaces.begin() ? true : false;
351 }
352
353private:
354
355 // not implemented
358 XalanNamespacesStackEntry&
359 operator=(const XalanNamespacesStackEntry& theRHS);
360
361 bool
362 operator==(const XalanNamespacesStack&) const;
363
365 operator=(const XalanNamespacesStack&);
366
367 enum { eDefaultCreateNewContextStackSize = 25 };
368
369 const XalanDOMString*
370 findEntry(
371 const XalanDOMString& theKey,
372 MemberFunctionType theFunction) const;
373
374 /**
375 * A stack to keep track of the result tree namespaces.
376 */
377 NamespacesStackType m_resultNamespaces;
378
379 NamespacesStackType::iterator m_stackBegin;
380
381 NamespacesStackType::iterator m_stackPosition;
382
383 BoolVectorType m_createNewContextStack;
384};
385
386
387
388}
389
390
391
392#endif // XALAN_XALANNAMESPACESSTACK_HEADER_GUARD
#define XALAN_DOMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
This class defines an interface for classes that resolve namespace prefixes to their URIs.
const XalanDOMChar * c_str() const
size_type length() const
Xalan implementation of deque.
const_reverse_iterator_ const_reverse_iterator
virtual const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &prefix) const
Retrieve a namespace corresponding to a prefix.
virtual const XalanDOMString & getURI() const
Retrieve the base URI for the resolver.
PrefixResolverProxy(const XalanNamespacesStack &theStack, const XalanDOMString &theURI)
Construct a PrefixResolver from a XalanNamespaceStack instance.
const XalanDOMString &(value_type::* MemberFunctionType)() const
XalanNamespacesStackEntry(const XalanNamespacesStackEntry &theSource, MemoryManager &theManager)
const XalanDOMString * getPrefixForNamespace(const XalanDOMString &theURI) const
Get the prefix for a namespace.
bool isPrefixPresent(const XalanDOMString &thePrefix) const
NamespaceCollectionType::const_reverse_iterator const_reverse_iterator
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMChar *theNamespaceURI, XalanDOMString::size_type theLength)
void swap(XalanNamespacesStackEntry &theOther)
XalanNamespacesStackEntry & set(const XalanNamespacesStackEntry &theRHS, MemoryManager &theManager)
NamespaceCollectionType::reverse_iterator reverse_iterator
const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &thePrefix) const
Get the namespace for a prefix.
const_reverse_iterator rbegin() const
const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &thePrefix) const
NamespacesStackType::const_iterator const_iterator
NamespacesStackType::iterator iterator
const_reverse_iterator rend() const
const XalanDOMString *(value_type::* MemberFunctionType)(const XalanDOMString &) const
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMString &theURI)
XalanNamespacesStack(MemoryManager &theManager)
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMChar *theURI, XalanDOMString::size_type theLength)
NamespacesStackType::reverse_iterator reverse_iterator
XalanDeque< value_type, ConstructWithMemoryManagerTraits< value_type > > NamespacesStackType
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMChar *theURI)
NamespacesStackType::size_type size_type
XalanNamespacesStackEntry value_type
bool prefixIsPresentLocal(const XalanDOMString &thePrefix)
See if the prefix has been mapped to a namespace in the current context, without looking down the sta...
const XalanDOMString * getPrefixForNamespace(const XalanDOMString &theURI) const
NamespacesStackType::const_reverse_iterator const_reverse_iterator
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
size_t size_type
Definition XalanMap.hpp:46
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)