Xalan-C++ API Reference  1.12.0
ResultNamespacesStack.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_RESULTNAMESPACESSTACK_HEADER_GUARD)
19 #define XALAN_RESULTNAMESPACESSTACK_HEADER_GUARD
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
33 
34 
35 
37 
38 
39 
40 namespace XALAN_CPP_NAMESPACE {
41 
42 
43 
45 {
46 public:
47 
48 
49 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
50  typedef std::deque<bool> BoolVectorType;
51 #else
53 #endif
54 
57 
59 
60 
61  explicit
62  ResultNamespacesStack(MemoryManager& theManager);
63 
65 
66  void
68  const XalanDOMString& thePrefix,
69  const XalanDOMString& theNamespaceURI)
70  {
71  addDeclaration(
72  thePrefix,
73  theNamespaceURI.c_str(),
74  theNamespaceURI.length());
75  }
76 
77  void
79  const XalanDOMString& thePrefix,
80  const XalanDOMChar* theNamespaceURI)
81  {
82  addDeclaration(
83  thePrefix,
84  theNamespaceURI,
85  length(theNamespaceURI));
86  }
87 
88  void
89  addDeclaration(
90  const XalanDOMString& thePrefix,
91  const XalanDOMChar* theNamespaceURI,
92  XalanDOMString::size_type theLength);
93 
94  void
95  pushContext();
96 
97  void
98  popContext();
99 
100  const XalanDOMString*
101  getNamespaceForPrefix(const XalanDOMString& thePrefix) const;
102 
103  const XalanDOMString*
104  getPrefixForNamespace(const XalanDOMString& theNamespaceURI) const;
105 
106  /**
107  * See if the prefix has been mapped to a namespace in the current
108  * context, without looking down the stack of namespaces.
109  */
110  bool
111  prefixIsPresentLocal(const XalanDOMString& thePrefix);
112 
113  void
114  clear();
115 
116  size_type
117  size() const
118  {
119  return m_resultNamespaces.size() - 1;
120  }
121 
122  bool
123  empty() const
124  {
125  return NamespacesStackType::const_iterator(m_stackPosition) == m_resultNamespaces.begin() ? true : false;
126  }
127 
128 private:
129 
130  // not implemented
132 
133  bool
134  operator==(const ResultNamespacesStack&) const;
135 
137  operator=(const ResultNamespacesStack&);
138 
139  enum { eDefaultCreateNewContextStackSize = 25 };
140 
141  /**
142  * A stack to keep track of the result tree namespaces.
143  */
144  NamespacesStackType m_resultNamespaces;
145 
146  NamespacesStackType::iterator m_stackBegin;
147 
148  NamespacesStackType::iterator m_stackPosition;
149 
150  BoolVectorType m_createNewContextStack;
151 };
152 
153 
154 
155 }
156 
157 
158 
159 #endif // XALAN_RESULTNAMESPACESSTACK_HEADER_GUARD
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanDequeIterator
Definition: XalanDeque.hpp:57
xalanc::clear
void clear(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2475
XalanDOMString.hpp
xalanc::XalanVector< bool >
xalanc::ResultNamespacesStack::addDeclaration
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMChar *theNamespaceURI)
Definition: ResultNamespacesStack.hpp:78
xalanc::ResultNamespacesStack::NamespacesStackType
XalanQName::NamespacesStackType NamespacesStackType
Definition: ResultNamespacesStack.hpp:56
XALAN_XSLT_EXPORT
#define XALAN_XSLT_EXPORT
Definition: XSLTDefinitions.hpp:27
xalanc::ResultNamespacesStack
Definition: ResultNamespacesStack.hpp:44
xalanc::size_type
size_t size_type
Definition: XalanMap.hpp:46
XalanVector.hpp
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
XalanQName.hpp
xalanc::ResultNamespacesStack::size
size_type size() const
Definition: ResultNamespacesStack.hpp:117
xalanc::XalanDeque
Xalan implementation of deque.
Definition: XalanDeque.hpp:200
xalanc::ResultNamespacesStack::BoolVectorType
XalanVector< bool > BoolVectorType
Definition: ResultNamespacesStack.hpp:52
xalanc::XalanDOMString::length
size_type length() const
Definition: XalanDOMString.hpp:209
xalanc::ResultNamespacesStack::NamespaceVectorType
XalanQName::NamespaceVectorType NamespaceVectorType
Definition: ResultNamespacesStack.hpp:55
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
xalanc::XalanDeque::size_type
size_t size_type
Definition: XalanDeque.hpp:204
xalanc::XalanDOMString::c_str
const XalanDOMChar * c_str() const
Definition: XalanDOMString.hpp:344
XSLTDefinitions.hpp
xalanc::ResultNamespacesStack::empty
bool empty() const
Definition: ResultNamespacesStack.hpp:123
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::ResultNamespacesStack::addDeclaration
void addDeclaration(const XalanDOMString &thePrefix, const XalanDOMString &theNamespaceURI)
Definition: ResultNamespacesStack.hpp:67
xalanc::ResultNamespacesStack::size_type
NamespacesStackType::size_type size_type
Definition: ResultNamespacesStack.hpp:58