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
32namespace 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{
42public:
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 */
60 const XalanDOMString& uri,
61 MemoryManager& theManager) :
62 m_prefix(prefix, theManager),
63 m_uri(uri, theManager)
64 {
65 }
66
67 static NameSpace*
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,
82
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
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
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
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
194 {
195 return equals(m_prefix, theRHS.m_prefix) &&
196 equals(m_uri, theRHS.m_uri);
197 }
198
199private:
200 NameSpace(const NameSpace&);
201
202 XalanDOMString m_prefix;
203
204 XalanDOMString m_uri;
205};
206
208
209}
210
211
212
213#endif // NAMESPACE_HEADER_GUARD_1357924680
#define XALAN_XPATH_EXPORT
#define XALAN_USES_MEMORY_MANAGER(Type)
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
A representation of a namespace.
Definition NameSpace.hpp:41
bool operator==(const NameSpace &theRHS) const
Equality operator.
NameSpace(const NameSpace &other, MemoryManager &theManager)
Definition NameSpace.hpp:88
static NameSpace * create(const XalanDOMString &prefix, const XalanDOMString &uri, MemoryManager &theManager)
Definition NameSpace.hpp:68
NameSpace(MemoryManager &theManager)
Definition NameSpace.hpp:45
void setURI(const XalanDOMChar *uri)
Set the URI for 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
const XalanDOMString & getPrefix() const
Retrieve the prefix for namespace.
const XalanDOMString & getURI() const
Retrieve the URI for namespace.
void setURI(const XalanDOMString &uri)
Set the URI for namespace.
void setURI(const XalanDOMChar *uri, XalanDOMString::size_type len)
Set the URI for namespace.
bool empty() const
void setPrefix(const XalanDOMString &prefix)
Set the prefix for namespace.
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.