Xerces-C++ 3.2.4

QName.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_QNAME_HPP)
23#define XERCESC_INCLUDE_GUARD_QNAME_HPP
24
25#include <xercesc/util/XMLString.hpp>
26#include <xercesc/util/XMLUniDefs.hpp>
27#include <xercesc/util/XMemory.hpp>
28#include <xercesc/util/PlatformUtils.hpp>
29
30#include <xercesc/internal/XSerializable.hpp>
31
32 XERCES_CPP_NAMESPACE_BEGIN
33
34 class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
35{
36public :
37 // -----------------------------------------------------------------------
38 // Constructors and Destructor
39 // -----------------------------------------------------------------------
41 QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
42
44 QName
45 (
46 const XMLCh* const prefix
47 , const XMLCh* const localPart
48 , const unsigned int uriId
49 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
50 );
51
53 QName
54 (
55 const XMLCh* const rawName
56 , const unsigned int uriId
57 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
58 );
59
61 QName(const QName& qname);
62
63 ~QName();
64
65 // -----------------------------------------------------------------------
66 // Getters
67 // -----------------------------------------------------------------------
68 const XMLCh* getPrefix() const;
69 XMLCh* getPrefix();
70
71 const XMLCh* getLocalPart() const;
72 XMLCh* getLocalPart();
73
74 unsigned int getURI() const;
75
76 const XMLCh* getRawName() const;
77 XMLCh* getRawName();
78
79 MemoryManager* getMemoryManager() const;
80
81 // -----------------------------------------------------------------------
82 // Setters
83 // -----------------------------------------------------------------------
84 void setName
85 (
86 const XMLCh* const prefix
87 , const XMLCh* const localPart
88 , const unsigned int uriId
89 );
90
91 void setName
92 (
93 const XMLCh* const rawName
94 , const unsigned int uriId
95 );
96
97 void setPrefix(const XMLCh*) ;
98 void setLocalPart(const XMLCh*) ;
99 void setNPrefix(const XMLCh*, const XMLSize_t ) ;
100 void setNLocalPart(const XMLCh*, const XMLSize_t ) ;
101 void setURI(const unsigned int) ;
102
103 void setValues(const QName& qname);
104
105 // -----------------------------------------------------------------------
106 // comparison
107 // -----------------------------------------------------------------------
108 bool operator==(const QName&) const;
109
110 // -----------------------------------------------------------------------
111 // Misc
112 // -----------------------------------------------------------------------
113 void cleanUp();
114
115 /***
116 * Support for Serialization/De-serialization
117 ***/
118 DECL_XSERIALIZABLE(QName)
119
120private :
121 // -----------------------------------------------------------------------
122 // Unimplemented constructors and operators
123 // -----------------------------------------------------------------------
124 QName& operator=(const QName&);
125
126 // -----------------------------------------------------------------------
127 // Private instance variables
128 //
129 // We copy the followings from XMLAttr.hpp, but stick to Java version's
130 // naming convention
131 //
132 // fPrefix
133 // fPrefixBufSz
134 // The prefix that was applied to this attribute's name, and the
135 // current size of the buffer (minus one for the null.) Prefixes
136 // really don't matter technically but it might be required for
137 // practical reasons, to recreate the original document for instance.
138 //
139 // fLocalPart
140 // fLocalPartBufSz
141 // The base part of the name of the attribute, and the current size
142 // of the buffer (minus one, where the null is.)
143 //
144 // fRawName
145 // fRawNameBufSz
146 // This is the QName form of the name, which is faulted in (from the
147 // prefix and name) upon request. The size field indicates the
148 // current size of the buffer (minus one for the null.) It will be
149 // zero until filled in.
150 //
151 // fURIId
152 // The id of the URI that this attribute belongs to.
153 // -----------------------------------------------------------------------
154 XMLSize_t fPrefixBufSz;
155 XMLSize_t fLocalPartBufSz;
156 XMLSize_t fRawNameBufSz;
157 unsigned int fURIId;
158 XMLCh* fPrefix;
159 XMLCh* fLocalPart;
160 XMLCh* fRawName;
161 MemoryManager* fMemoryManager;
162};
163
164// ---------------------------------------------------------------------------
165// QName: Getter methods
166// ---------------------------------------------------------------------------
167 inline const XMLCh* QName::getPrefix() const
168{
169 return fPrefix;
170}
171
172 inline XMLCh* QName::getPrefix()
173{
174 return fPrefix;
175}
176
177 inline const XMLCh* QName::getLocalPart() const
178{
179 return fLocalPart;
180}
181
182 inline XMLCh* QName::getLocalPart()
183{
184 return fLocalPart;
185}
186
187 inline unsigned int QName::getURI() const
188{
189 return fURIId;
190}
191
192 inline MemoryManager* QName::getMemoryManager() const
193{
194 return fMemoryManager;
195}
196
197// ---------------------------------------------------------------------------
198// QName: Setter methods
199// ---------------------------------------------------------------------------
200 inline void QName::setURI(const unsigned int uriId)
201{
202 fURIId = uriId;
203}
204
205 inline void QName::setPrefix(const XMLCh* prefix)
206{
207 setNPrefix(prefix, XMLString::stringLen(prefix));
208}
209
210 inline void QName::setLocalPart(const XMLCh* localPart)
211{
212 setNLocalPart(localPart, XMLString::stringLen(localPart));
213}
214
215 XERCES_CPP_NAMESPACE_END
216
217#endif
PlatformUtils.hpp
XMLString.hpp
XMLUniDefs.hpp
XMemory.hpp
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLUTIL_EXPORT
#define XMLUTIL_EXPORT
Definition: XercesDefs.hpp:162
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:40
QName
Definition: QName.hpp:35
QName::setValues
void setValues(const QName &qname)
QName::QName
QName(const XMLCh *const prefix, const XMLCh *const localPart, const unsigned int uriId, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructs a specified qname using prefix, and localpart.
QName::QName
QName(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Default constructor.
QName::setName
void setName(const XMLCh *const rawName, const unsigned int uriId)
QName::getMemoryManager
MemoryManager * getMemoryManager() const
Definition: QName.hpp:192
QName::getLocalPart
const XMLCh * getLocalPart() const
Definition: QName.hpp:177
QName::getRawName
XMLCh * getRawName()
QName::setLocalPart
void setLocalPart(const XMLCh *)
Definition: QName.hpp:210
QName::getRawName
const XMLCh * getRawName() const
QName::cleanUp
void cleanUp()
QName::setName
void setName(const XMLCh *const prefix, const XMLCh *const localPart, const unsigned int uriId)
QName::QName
QName(const QName &qname)
Copy constructor.
QName::~QName
~QName()
QName::getURI
unsigned int getURI() const
Definition: QName.hpp:187
QName::setURI
void setURI(const unsigned int)
Definition: QName.hpp:200
QName::setPrefix
void setPrefix(const XMLCh *)
Definition: QName.hpp:205
QName::operator==
bool operator==(const QName &) const
QName::setNPrefix
void setNPrefix(const XMLCh *, const XMLSize_t)
QName::getPrefix
const XMLCh * getPrefix() const
Definition: QName.hpp:167
QName::QName
QName(const XMLCh *const rawName, const unsigned int uriId, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructs a specified qname using rawName.
QName::setNLocalPart
void setNLocalPart(const XMLCh *, const XMLSize_t)
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLString::stringLen
static XMLSize_t stringLen(const char *const src)
Get the length of the string.
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:41