Xalan-C++ API Reference  1.12.0
NameSpace.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(NAMESPACE_HEADER_GUARD_1357924680)
19 #define NAMESPACE_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base header file. Must be first.
25 
27 
29 
30 
31 
32 namespace XALAN_CPP_NAMESPACE {
33 
34 
35 
36 /**
37  * A representation of a namespace. One of these will be pushed on the
38  * namespace stack for each element.
39  */
41 {
42 public:
43 
44  explicit
45  NameSpace(MemoryManager& theManager) :
46  m_prefix(theManager),
47  m_uri(theManager)
48  {
49  }
50 
51  /**
52  * Construct a namespace for placement on the
53  * result tree namespace stack.
54  *
55  * @param prefix namespace prefix
56  * @param uri URI of namespace
57  */
59  const XalanDOMString& prefix,
60  const XalanDOMString& uri,
61  MemoryManager& theManager) :
62  m_prefix(prefix, theManager),
63  m_uri(uri, theManager)
64  {
65  }
66 
67  static NameSpace*
69  const XalanDOMString& prefix,
70  const XalanDOMString& uri,
71  MemoryManager& theManager)
72  {
73  typedef NameSpace ThisType;
74 
75  XalanAllocationGuard theGuard(theManager, theManager.allocate(sizeof(ThisType)));
76 
77  ThisType* const theResult =
78  new (theGuard.get()) ThisType(
79  prefix,
80  uri,
81  theManager);
82 
83  theGuard.release();
84 
85  return theResult;
86  }
87 
89  const NameSpace& other,
90  MemoryManager& theManager) :
91  m_prefix(other.m_prefix, theManager),
92  m_uri(other.m_uri, theManager)
93  {
94  }
95 
97  {
98  }
99 
100  /**
101  * Retrieve the prefix for namespace
102  *
103  * @return prefix string
104  */
105  const XalanDOMString&
106  getPrefix() const
107  {
108  return m_prefix;
109  }
110 
111  /**
112  * Set the prefix for namespace
113  *
114  * @param prefix The new prefix value
115  */
116  void
117  setPrefix(const XalanDOMString& prefix)
118  {
119  m_prefix = prefix;
120  }
121 
122  /**
123  * Retrieve the URI for namespace
124  *
125  * @return URI string
126  */
127  const XalanDOMString&
128  getURI() const
129  {
130  return m_uri;
131  }
132 
133  /**
134  * Set the URI for namespace
135  *
136  * @param uri The new uri value
137  */
138  void
139  setURI(const XalanDOMString& uri)
140  {
141  m_uri = uri;
142  }
143 
144  /**
145  * Set the URI for namespace
146  *
147  * @param uri The new uri value
148  */
149  void
150  setURI(const XalanDOMChar* uri)
151  {
152  assert(uri != 0);
153 
154  m_uri = uri;
155  }
156 
157  /**
158  * Set the URI for namespace
159  *
160  * @param uri The new uri value
161  * @param len The length of the uri
162  */
163  void
165  const XalanDOMChar* uri,
167  {
168  assert(uri != 0);
169 
170  m_uri.assign(uri, len);
171  }
172 
173  bool
174  empty() const
175  {
176  return m_prefix.empty() && m_uri.empty();
177  }
178 
179  void
181  {
182  m_prefix.clear();
183 
184  m_uri.clear();
185  }
186 
187  /**
188  * Equality operator
189  *
190  * @param theRHS namespace to compare
191  */
192  bool
193  operator==(const NameSpace& theRHS) const
194  {
195  return equals(m_prefix, theRHS.m_prefix) &&
196  equals(m_uri, theRHS.m_uri);
197  }
198 
199 private:
200  NameSpace(const NameSpace&);
201 
202  XalanDOMString m_prefix;
203 
204  XalanDOMString m_uri;
205 };
206 
207 XALAN_USES_MEMORY_MANAGER(NameSpace)
208 
209 }
210 
211 
212 
213 #endif // NAMESPACE_HEADER_GUARD_1357924680
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanAllocationGuard::release
void release()
Definition: XalanMemoryManagement.hpp:133
xalanc::NameSpace::setURI
void setURI(const XalanDOMString &uri)
Set the URI for namespace.
Definition: NameSpace.hpp:139
xalanc::NameSpace::create
static NameSpace * create(const XalanDOMString &prefix, const XalanDOMString &uri, MemoryManager &theManager)
Definition: NameSpace.hpp:68
XALAN_USES_MEMORY_MANAGER
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:589
xalanc::NameSpace::operator==
bool operator==(const NameSpace &theRHS) const
Equality operator.
Definition: NameSpace.hpp:193
xalanc::NameSpace::setURI
void setURI(const XalanDOMChar *uri, XalanDOMString::size_type len)
Set the URI for namespace.
Definition: NameSpace.hpp:164
xalanc::equals
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.
xalanc::NameSpace::setPrefix
void setPrefix(const XalanDOMString &prefix)
Set the prefix for namespace.
Definition: NameSpace.hpp:117
XALAN_XPATH_EXPORT
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:35
xalanc::NameSpace::NameSpace
NameSpace(MemoryManager &theManager)
Definition: NameSpace.hpp:45
DOMStringHelper.hpp
xalanc::XalanAllocationGuard
Definition: XalanMemoryManagement.hpp:96
xalanc::NameSpace::getPrefix
const XalanDOMString & getPrefix() const
Retrieve the prefix for namespace.
Definition: NameSpace.hpp:106
xalanc::NameSpace::setURI
void setURI(const XalanDOMChar *uri)
Set the URI for namespace.
Definition: NameSpace.hpp:150
xalanc::NameSpace::NameSpace
NameSpace(const XalanDOMString &prefix, const XalanDOMString &uri, MemoryManager &theManager)
Construct a namespace for placement on the result tree namespace stack.
Definition: NameSpace.hpp:58
xalanc::NameSpace::~NameSpace
~NameSpace()
Definition: NameSpace.hpp:96
xalanc::XalanAllocationGuard::get
void * get() const
Definition: XalanMemoryManagement.hpp:127
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::NameSpace::getURI
const XalanDOMString & getURI() const
Retrieve the URI for namespace.
Definition: NameSpace.hpp:128
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::NameSpace
A representation of a namespace.
Definition: NameSpace.hpp:40
xalanc::NameSpace::clear
void clear()
Definition: NameSpace.hpp:180
xalanc::NameSpace::empty
bool empty() const
Definition: NameSpace.hpp:174
XPathDefinitions.hpp
XalanMemMgrAutoPtr.hpp
xalanc::NameSpace::NameSpace
NameSpace(const NameSpace &other, MemoryManager &theManager)
Definition: NameSpace.hpp:88