1 | /*
|
---|
2 | * Copyright 2001,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Log: QName.hpp,v $
|
---|
19 | * Revision 1.11 2004/09/08 13:56:22 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.10 2004/01/29 11:48:46 cargilld
|
---|
23 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
24 | *
|
---|
25 | * Revision 1.9 2003/09/25 15:22:34 peiyongz
|
---|
26 | * Implementation of Serialization
|
---|
27 | *
|
---|
28 | * Revision 1.8 2003/05/16 21:36:59 knoaman
|
---|
29 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
30 | *
|
---|
31 | * Revision 1.7 2003/05/16 06:01:52 knoaman
|
---|
32 | * Partial implementation of the configurable memory manager.
|
---|
33 | *
|
---|
34 | * Revision 1.6 2003/05/15 19:04:35 knoaman
|
---|
35 | * Partial implementation of the configurable memory manager.
|
---|
36 | *
|
---|
37 | * Revision 1.5 2002/11/04 15:22:04 tng
|
---|
38 | * C++ Namespace Support.
|
---|
39 | *
|
---|
40 | * Revision 1.4 2002/10/30 21:52:00 tng
|
---|
41 | * [Bug 13641] compiler-generated copy-constructor for QName doesn't do the right thing.
|
---|
42 | *
|
---|
43 | * Revision 1.3 2002/09/05 16:06:41 tng
|
---|
44 | * [Bug 12232] Make operator to be constant.
|
---|
45 | *
|
---|
46 | * Revision 1.2 2002/08/20 16:54:25 tng
|
---|
47 | * [Bug 6251] Info during compilation.
|
---|
48 | *
|
---|
49 | * Revision 1.1.1.1 2002/02/01 22:22:11 peiyongz
|
---|
50 | * sane_include
|
---|
51 | *
|
---|
52 | * Revision 1.8 2001/12/06 17:48:36 tng
|
---|
53 | * Performance Enhancement. Added setNPrefix and setNLocalPart methods that allow code to take advantage of the fact that it knows the length of the prefix and local name, when possible. That can avoid a copy of the prefix into a null-terminated temporary variable before copying into the fPrefix.
|
---|
54 | * Also changed the getRawName method so that it would simply return the local part when there is no prefix, instead of allocating another buffer to copy the local part into the fRawName.
|
---|
55 | * When there is a prefix, changed the getRawName to copy the prefix and local part into the fRawName using XMLString::moveChars instead of using XMLString::copyString and XMLString::catString. The catString method has to loop past the prefix portion of the fRawName, which seems like a waste.
|
---|
56 | * By Henry Zongaro.
|
---|
57 | *
|
---|
58 | * Revision 1.7 2001/07/24 18:31:47 knoaman
|
---|
59 | * Added support for <group> + extra constraint checking for complexType
|
---|
60 | *
|
---|
61 | * Revision 1.6 2001/05/11 13:26:28 tng
|
---|
62 | * Copyright update.
|
---|
63 | *
|
---|
64 | * Revision 1.5 2001/04/19 18:17:10 tng
|
---|
65 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
66 | *
|
---|
67 | * Revision 1.4 2001/03/21 21:56:12 tng
|
---|
68 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
69 | *
|
---|
70 | * Revision 1.3 2001/02/27 14:48:39 tng
|
---|
71 | * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
|
---|
72 | *
|
---|
73 | * Revision 1.2 2001/02/26 21:56:16 tng
|
---|
74 | * Schema: QName can also be constructed with rawName.
|
---|
75 | *
|
---|
76 | * Revision 1.1 2001/02/26 19:44:25 tng
|
---|
77 | * Schema: add utility class QName, by Pei Yong Zhang.
|
---|
78 | *
|
---|
79 | */
|
---|
80 |
|
---|
81 | #if !defined(QNAME_HPP)
|
---|
82 | #define QNAME_HPP
|
---|
83 |
|
---|
84 | #include <xercesc/util/XMLString.hpp>
|
---|
85 | #include <xercesc/util/XMLUniDefs.hpp>
|
---|
86 | #include <xercesc/util/XMemory.hpp>
|
---|
87 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
88 |
|
---|
89 | #include <xercesc/internal/XSerializable.hpp>
|
---|
90 |
|
---|
91 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
92 |
|
---|
93 | class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
|
---|
94 | {
|
---|
95 | public :
|
---|
96 | // -----------------------------------------------------------------------
|
---|
97 | // Contructors and Destructor
|
---|
98 | // -----------------------------------------------------------------------
|
---|
99 | /** Default constructor. */
|
---|
100 | QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
101 |
|
---|
102 | /** Constructs a specified qname using prefix, and localpart. */
|
---|
103 | QName
|
---|
104 | (
|
---|
105 | const XMLCh* const prefix
|
---|
106 | , const XMLCh* const localPart
|
---|
107 | , const unsigned int uriId
|
---|
108 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
109 | );
|
---|
110 |
|
---|
111 | /** Constructs a specified qname using rawName. */
|
---|
112 | QName
|
---|
113 | (
|
---|
114 | const XMLCh* const rawName
|
---|
115 | , const unsigned int uriId
|
---|
116 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
117 | );
|
---|
118 |
|
---|
119 | /** Copy constructor. */
|
---|
120 | QName(const QName& qname);
|
---|
121 |
|
---|
122 | ~QName();
|
---|
123 |
|
---|
124 | // -----------------------------------------------------------------------
|
---|
125 | // Getters
|
---|
126 | // -----------------------------------------------------------------------
|
---|
127 | const XMLCh* getPrefix() const;
|
---|
128 | XMLCh* getPrefix();
|
---|
129 |
|
---|
130 | const XMLCh* getLocalPart() const;
|
---|
131 | XMLCh* getLocalPart();
|
---|
132 |
|
---|
133 | unsigned int getURI() const;
|
---|
134 |
|
---|
135 | const XMLCh* getRawName() const;
|
---|
136 | XMLCh* getRawName();
|
---|
137 |
|
---|
138 | MemoryManager* getMemoryManager() const;
|
---|
139 |
|
---|
140 | // -----------------------------------------------------------------------
|
---|
141 | // Setters
|
---|
142 | // -----------------------------------------------------------------------
|
---|
143 | void setName
|
---|
144 | (
|
---|
145 | const XMLCh* const prefix
|
---|
146 | , const XMLCh* const localPart
|
---|
147 | , const unsigned int uriId
|
---|
148 | );
|
---|
149 |
|
---|
150 | void setName
|
---|
151 | (
|
---|
152 | const XMLCh* const rawName
|
---|
153 | , const unsigned int uriId
|
---|
154 | );
|
---|
155 |
|
---|
156 | void setPrefix(const XMLCh*) ;
|
---|
157 | void setLocalPart(const XMLCh*) ;
|
---|
158 | void setNPrefix(const XMLCh*, const unsigned int) ;
|
---|
159 | void setNLocalPart(const XMLCh*, const unsigned int) ;
|
---|
160 | void setURI(const unsigned int) ;
|
---|
161 |
|
---|
162 | void setValues(const QName& qname);
|
---|
163 |
|
---|
164 | // -----------------------------------------------------------------------
|
---|
165 | // comparison
|
---|
166 | // -----------------------------------------------------------------------
|
---|
167 | bool operator==(const QName&) const;
|
---|
168 |
|
---|
169 | // -----------------------------------------------------------------------
|
---|
170 | // Misc
|
---|
171 | // -----------------------------------------------------------------------
|
---|
172 | void cleanUp();
|
---|
173 |
|
---|
174 | /***
|
---|
175 | * Support for Serialization/De-serialization
|
---|
176 | ***/
|
---|
177 | DECL_XSERIALIZABLE(QName)
|
---|
178 |
|
---|
179 | private :
|
---|
180 | // -----------------------------------------------------------------------
|
---|
181 | // Unimplemented constructors and operators
|
---|
182 | // -----------------------------------------------------------------------
|
---|
183 | QName& operator=(const QName&);
|
---|
184 |
|
---|
185 | // -----------------------------------------------------------------------
|
---|
186 | // Private instance variables
|
---|
187 | //
|
---|
188 | // We copy the followings from XMLAttr.hpp, but stick to Java version's
|
---|
189 | // naming convention
|
---|
190 | //
|
---|
191 | // fPrefix
|
---|
192 | // fPrefixBufSz
|
---|
193 | // The prefix that was applied to this attribute's name, and the
|
---|
194 | // current size of the buffer (minus one for the null.) Prefixes
|
---|
195 | // really don't matter technically but it might be required for
|
---|
196 | // pratical reasons, to recreate the original document for instance.
|
---|
197 | //
|
---|
198 | // fLocalPart
|
---|
199 | // fLocalPartBufSz
|
---|
200 | // The base part of the name of the attribute, and the current size
|
---|
201 | // of the buffer (minus one, where the null is.)
|
---|
202 | //
|
---|
203 | // fRawName
|
---|
204 | // fRawNameBufSz
|
---|
205 | // This is the QName form of the name, which is faulted in (from the
|
---|
206 | // prefix and name) upon request. The size field indicates the
|
---|
207 | // current size of the buffer (minus one for the null.) It will be
|
---|
208 | // zero until fauled in.
|
---|
209 | //
|
---|
210 | // fURIId
|
---|
211 | // The id of the URI that this attribute belongs to.
|
---|
212 | // -----------------------------------------------------------------------
|
---|
213 | MemoryManager* fMemoryManager;
|
---|
214 | XMLCh* fPrefix;
|
---|
215 | unsigned int fPrefixBufSz;
|
---|
216 | XMLCh* fLocalPart;
|
---|
217 | unsigned int fLocalPartBufSz;
|
---|
218 | XMLCh* fRawName;
|
---|
219 | unsigned int fRawNameBufSz;
|
---|
220 | unsigned int fURIId;
|
---|
221 | };
|
---|
222 |
|
---|
223 | // ---------------------------------------------------------------------------
|
---|
224 | // QName: Getter methods
|
---|
225 | // ---------------------------------------------------------------------------
|
---|
226 | inline const XMLCh* QName::getPrefix() const
|
---|
227 | {
|
---|
228 | return fPrefix;
|
---|
229 | }
|
---|
230 |
|
---|
231 | inline XMLCh* QName::getPrefix()
|
---|
232 | {
|
---|
233 | return fPrefix;
|
---|
234 | }
|
---|
235 |
|
---|
236 | inline const XMLCh* QName::getLocalPart() const
|
---|
237 | {
|
---|
238 | return fLocalPart;
|
---|
239 | }
|
---|
240 |
|
---|
241 | inline XMLCh* QName::getLocalPart()
|
---|
242 | {
|
---|
243 | return fLocalPart;
|
---|
244 | }
|
---|
245 |
|
---|
246 | inline unsigned int QName::getURI() const
|
---|
247 | {
|
---|
248 | return fURIId;
|
---|
249 | }
|
---|
250 |
|
---|
251 | inline MemoryManager* QName::getMemoryManager() const
|
---|
252 | {
|
---|
253 | return fMemoryManager;
|
---|
254 | }
|
---|
255 |
|
---|
256 | // ---------------------------------------------------------------------------
|
---|
257 | // QName: Setter methods
|
---|
258 | // ---------------------------------------------------------------------------
|
---|
259 | inline void QName::setURI(const unsigned int uriId)
|
---|
260 | {
|
---|
261 | fURIId = uriId;
|
---|
262 | }
|
---|
263 |
|
---|
264 | XERCES_CPP_NAMESPACE_END
|
---|
265 |
|
---|
266 | #endif
|
---|