Xerces-C++  3.1.2
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: QName.hpp 932887 2010-04-11 13:04:59Z borisk $
20  */
21 
22 #if !defined(XERCESC_INCLUDE_GUARD_QNAME_HPP)
23 #define XERCESC_INCLUDE_GUARD_QNAME_HPP
24 
27 #include <xercesc/util/XMemory.hpp>
29 
30 #include <xercesc/internal/XSerializable.hpp>
31 
33 
34 class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
35 {
36 public :
37  // -----------------------------------------------------------------------
38  // Constructors and Destructor
39  // -----------------------------------------------------------------------
42 
44  QName
45  (
46  const XMLCh* const prefix
47  , const XMLCh* const localPart
48  , const unsigned int uriId
50  );
51 
53  QName
54  (
55  const XMLCh* const rawName
56  , const unsigned int uriId
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 
120 private :
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 
173 {
174  return fPrefix;
175 }
176 
177 inline const XMLCh* QName::getLocalPart() const
178 {
179  return fLocalPart;
180 }
181 
183 {
184  return fLocalPart;
185 }
186 
187 inline unsigned int QName::getURI() const
188 {
189  return fURIId;
190 }
191 
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 
216 
217 #endif
void setNLocalPart(const XMLCh *, const XMLSize_t)
MemoryManager * getMemoryManager() const
Definition: QName.hpp:192
const XMLCh * getPrefix() const
Definition: QName.hpp:167
void setLocalPart(const XMLCh *)
Definition: QName.hpp:210
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
const XMLCh * getLocalPart() const
Definition: QName.hpp:177
void setURI(const unsigned int)
Definition: QName.hpp:200
unsigned int getURI() const
Definition: QName.hpp:187
Configurable memory manager.
Definition: MemoryManager.hpp:39
void setNPrefix(const XMLCh *, const XMLSize_t)
static XMLSize_t stringLen(const char *const src)
Get the length of the string.
SIZE_T XMLSize_t
Definition: Xerces_autoconf_config.borland.hpp:86
Definition: QName.hpp:34
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
wchar_t XMLCh
Definition: Xerces_autoconf_config.borland.hpp:92
#define XMLUTIL_EXPORT
Definition: XercesDefs.hpp:162
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
void setPrefix(const XMLCh *)
Definition: QName.hpp:205