Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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 
38 XALAN_CPP_NAMESPACE_BEGIN
39 
40 
41 class XalanDOMString;
42 
43 
44 
46 {
47 public:
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*
69  getNamespaceForPrefix(const XalanDOMString& prefix) const;
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 
104  set(const XalanNamespacesStackEntry& theRHS,
105  MemoryManager& theManager);
106 
107  void
108  addDeclaration(
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 
143  iterator
145  {
146  return m_namespaces.begin();
147  }
148 
149  const_iterator
150  begin() const
151  {
152  return m_namespaces.begin();
153  }
154 
155  iterator
156  end()
157  {
158  return m_position;
159  }
160 
161  const_iterator
162  end() const
163  {
164  return const_iterator(m_position);
165  }
166 
167  reverse_iterator
169  {
170  return reverse_iterator(end());
171  }
172 
173  const_reverse_iterator
174  rbegin() const
175  {
176  return const_reverse_iterator(end());
177  }
178 
179  reverse_iterator
181  {
182  return reverse_iterator(begin());
183  }
184 
185  const_reverse_iterator
186  rend() const
187  {
188  return const_reverse_iterator(begin());
189  }
190 
191  void
192  clear();
193 
194  void
196  {
197  m_position = m_namespaces.begin();
198  }
199 
200  void
201  swap(XalanNamespacesStackEntry& theOther);
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 
232  typedef const XalanDOMString* (value_type::*MemberFunctionType)(const XalanDOMString&) const;
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
263  addDeclaration(
264  const XalanDOMString& thePrefix,
265  const XalanDOMChar* theURI,
266  XalanDOMString::size_type theLength);
267 
268  void
269  pushContext();
270 
271  void
272  popContext();
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
288  prefixIsPresentLocal(const XalanDOMString& thePrefix);
289 
290  void
291  clear();
292 
293  iterator
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
306  end()
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 
341  size_type
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 
353 private:
354 
355  // not implemented
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 XALAN_CPP_NAMESPACE_END
389 
390 
391 
392 #endif // XALAN_XALANNAMESPACESSTACK_HEADER_GUARD
const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &thePrefix) const
Get the namespace for a prefix.
XalanDeque< value_type, ConstructWithMemoryManagerTraits< value_type > > NamespacesStackType
const XalanDOMString &(value_type::* MemberFunctionType)() const
XalanNamespacesStackEntry value_type
NamespacesStackType::const_reverse_iterator const_reverse_iterator
void clear(XalanDOMString &theString)
Remove all elements from target string.
XalanSize_t size_type
const XalanDOMChar * c_str() const
NamespaceCollectionType::const_reverse_iterator const_reverse_iterator
NamespacesStackType::reverse_iterator reverse_iterator
virtual const XalanDOMString & getURI() const =0
Retrieve the base URI for the resolver.
size_t size_type
Definition: XalanDeque.hpp:204
const_reverse_iterator rbegin() const
#define XALAN_DOMSUPPORT_EXPORT
reverse_iterator_ reverse_iterator
Definition: XalanDeque.hpp:245
size_type length() const
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
NamespacesStackType::iterator iterator
const_reverse_iterator rend() const
This class defines an interface for classes that resolve namespace prefixes to their URIs...
const_reverse_iterator_ const_reverse_iterator
Definition: XalanDeque.hpp:246
const XalanDOMString & getPrefix() const
Retrieve the thePrefix for namespace.
XalanVector< bool > BoolVectorType
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMChar *theURI)
bool isPrefixPresent(const XalanDOMString &thePrefix) const
const XalanDOMString & getURI() const
Retrieve the URI for namespace.
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
NamespacesStackType::size_type size_type
const XalanDOMString * getPrefixForNamespace(const XalanDOMString &theURI) const
const_iterator end() const
const XalanDOMString *(value_type::* MemberFunctionType)(const XalanDOMString &) const
virtual const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &prefix) const =0
Retrieve a namespace corresponding to a prefix.
NamespacesStackType::const_iterator const_iterator
const_iterator begin() const
NamespaceCollectionType::const_iterator const_iterator
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMString &theURI)
NamespaceCollectionType::reverse_iterator reverse_iterator
const XalanDOMString * getPrefixForNamespace(const XalanDOMString &theURI) const
Get the prefix for a namespace.

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo