1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2001 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 2001, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: QName.hpp,v $
|
---|
59 | * Revision 1.10 2004/01/29 11:48:46 cargilld
|
---|
60 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
61 | *
|
---|
62 | * Revision 1.9 2003/09/25 15:22:34 peiyongz
|
---|
63 | * Implementation of Serialization
|
---|
64 | *
|
---|
65 | * Revision 1.8 2003/05/16 21:36:59 knoaman
|
---|
66 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
67 | *
|
---|
68 | * Revision 1.7 2003/05/16 06:01:52 knoaman
|
---|
69 | * Partial implementation of the configurable memory manager.
|
---|
70 | *
|
---|
71 | * Revision 1.6 2003/05/15 19:04:35 knoaman
|
---|
72 | * Partial implementation of the configurable memory manager.
|
---|
73 | *
|
---|
74 | * Revision 1.5 2002/11/04 15:22:04 tng
|
---|
75 | * C++ Namespace Support.
|
---|
76 | *
|
---|
77 | * Revision 1.4 2002/10/30 21:52:00 tng
|
---|
78 | * [Bug 13641] compiler-generated copy-constructor for QName doesn't do the right thing.
|
---|
79 | *
|
---|
80 | * Revision 1.3 2002/09/05 16:06:41 tng
|
---|
81 | * [Bug 12232] Make operator to be constant.
|
---|
82 | *
|
---|
83 | * Revision 1.2 2002/08/20 16:54:25 tng
|
---|
84 | * [Bug 6251] Info during compilation.
|
---|
85 | *
|
---|
86 | * Revision 1.1.1.1 2002/02/01 22:22:11 peiyongz
|
---|
87 | * sane_include
|
---|
88 | *
|
---|
89 | * Revision 1.8 2001/12/06 17:48:36 tng
|
---|
90 | * 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.
|
---|
91 | * 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.
|
---|
92 | * 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.
|
---|
93 | * By Henry Zongaro.
|
---|
94 | *
|
---|
95 | * Revision 1.7 2001/07/24 18:31:47 knoaman
|
---|
96 | * Added support for <group> + extra constraint checking for complexType
|
---|
97 | *
|
---|
98 | * Revision 1.6 2001/05/11 13:26:28 tng
|
---|
99 | * Copyright update.
|
---|
100 | *
|
---|
101 | * Revision 1.5 2001/04/19 18:17:10 tng
|
---|
102 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
103 | *
|
---|
104 | * Revision 1.4 2001/03/21 21:56:12 tng
|
---|
105 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
106 | *
|
---|
107 | * Revision 1.3 2001/02/27 14:48:39 tng
|
---|
108 | * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
|
---|
109 | *
|
---|
110 | * Revision 1.2 2001/02/26 21:56:16 tng
|
---|
111 | * Schema: QName can also be constructed with rawName.
|
---|
112 | *
|
---|
113 | * Revision 1.1 2001/02/26 19:44:25 tng
|
---|
114 | * Schema: add utility class QName, by Pei Yong Zhang.
|
---|
115 | *
|
---|
116 | */
|
---|
117 |
|
---|
118 | #if !defined(QNAME_HPP)
|
---|
119 | #define QNAME_HPP
|
---|
120 |
|
---|
121 | #include <xercesc/util/XMLString.hpp>
|
---|
122 | #include <xercesc/util/XMLUniDefs.hpp>
|
---|
123 | #include <xercesc/util/XMemory.hpp>
|
---|
124 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
125 |
|
---|
126 | #include <xercesc/internal/XSerializable.hpp>
|
---|
127 |
|
---|
128 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
129 |
|
---|
130 | class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
|
---|
131 | {
|
---|
132 | public :
|
---|
133 | // -----------------------------------------------------------------------
|
---|
134 | // Contructors and Destructor
|
---|
135 | // -----------------------------------------------------------------------
|
---|
136 | /** Default constructor. */
|
---|
137 | QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
138 |
|
---|
139 | /** Constructs a specified qname using prefix, and localpart. */
|
---|
140 | QName
|
---|
141 | (
|
---|
142 | const XMLCh* const prefix
|
---|
143 | , const XMLCh* const localPart
|
---|
144 | , const unsigned int uriId
|
---|
145 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
146 | );
|
---|
147 |
|
---|
148 | /** Constructs a specified qname using rawName. */
|
---|
149 | QName
|
---|
150 | (
|
---|
151 | const XMLCh* const rawName
|
---|
152 | , const unsigned int uriId
|
---|
153 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
154 | );
|
---|
155 |
|
---|
156 | /** Copy constructor. */
|
---|
157 | QName(const QName& qname);
|
---|
158 |
|
---|
159 | ~QName();
|
---|
160 |
|
---|
161 | // -----------------------------------------------------------------------
|
---|
162 | // Getters
|
---|
163 | // -----------------------------------------------------------------------
|
---|
164 | const XMLCh* getPrefix() const;
|
---|
165 | XMLCh* getPrefix();
|
---|
166 |
|
---|
167 | const XMLCh* getLocalPart() const;
|
---|
168 | XMLCh* getLocalPart();
|
---|
169 |
|
---|
170 | unsigned int getURI() const;
|
---|
171 |
|
---|
172 | const XMLCh* getRawName() const;
|
---|
173 | XMLCh* getRawName();
|
---|
174 |
|
---|
175 | MemoryManager* getMemoryManager() const;
|
---|
176 |
|
---|
177 | // -----------------------------------------------------------------------
|
---|
178 | // Setters
|
---|
179 | // -----------------------------------------------------------------------
|
---|
180 | void setName
|
---|
181 | (
|
---|
182 | const XMLCh* const prefix
|
---|
183 | , const XMLCh* const localPart
|
---|
184 | , const unsigned int uriId
|
---|
185 | );
|
---|
186 |
|
---|
187 | void setName
|
---|
188 | (
|
---|
189 | const XMLCh* const rawName
|
---|
190 | , const unsigned int uriId
|
---|
191 | );
|
---|
192 |
|
---|
193 | void setPrefix(const XMLCh*) ;
|
---|
194 | void setLocalPart(const XMLCh*) ;
|
---|
195 | void setNPrefix(const XMLCh*, const unsigned int) ;
|
---|
196 | void setNLocalPart(const XMLCh*, const unsigned int) ;
|
---|
197 | void setURI(const unsigned int) ;
|
---|
198 |
|
---|
199 | void setValues(const QName& qname);
|
---|
200 |
|
---|
201 | // -----------------------------------------------------------------------
|
---|
202 | // comparison
|
---|
203 | // -----------------------------------------------------------------------
|
---|
204 | bool operator==(const QName&) const;
|
---|
205 |
|
---|
206 | // -----------------------------------------------------------------------
|
---|
207 | // Misc
|
---|
208 | // -----------------------------------------------------------------------
|
---|
209 | void cleanUp();
|
---|
210 |
|
---|
211 | /***
|
---|
212 | * Support for Serialization/De-serialization
|
---|
213 | ***/
|
---|
214 | DECL_XSERIALIZABLE(QName)
|
---|
215 |
|
---|
216 | private :
|
---|
217 | // -----------------------------------------------------------------------
|
---|
218 | // Unimplemented constructors and operators
|
---|
219 | // -----------------------------------------------------------------------
|
---|
220 | QName& operator=(const QName&);
|
---|
221 |
|
---|
222 | // -----------------------------------------------------------------------
|
---|
223 | // Private instance variables
|
---|
224 | //
|
---|
225 | // We copy the followings from XMLAttr.hpp, but stick to Java version's
|
---|
226 | // naming convention
|
---|
227 | //
|
---|
228 | // fPrefix
|
---|
229 | // fPrefixBufSz
|
---|
230 | // The prefix that was applied to this attribute's name, and the
|
---|
231 | // current size of the buffer (minus one for the null.) Prefixes
|
---|
232 | // really don't matter technically but it might be required for
|
---|
233 | // pratical reasons, to recreate the original document for instance.
|
---|
234 | //
|
---|
235 | // fLocalPart
|
---|
236 | // fLocalPartBufSz
|
---|
237 | // The base part of the name of the attribute, and the current size
|
---|
238 | // of the buffer (minus one, where the null is.)
|
---|
239 | //
|
---|
240 | // fRawName
|
---|
241 | // fRawNameBufSz
|
---|
242 | // This is the QName form of the name, which is faulted in (from the
|
---|
243 | // prefix and name) upon request. The size field indicates the
|
---|
244 | // current size of the buffer (minus one for the null.) It will be
|
---|
245 | // zero until fauled in.
|
---|
246 | //
|
---|
247 | // fURIId
|
---|
248 | // The id of the URI that this attribute belongs to.
|
---|
249 | // -----------------------------------------------------------------------
|
---|
250 | MemoryManager* fMemoryManager;
|
---|
251 | XMLCh* fPrefix;
|
---|
252 | unsigned int fPrefixBufSz;
|
---|
253 | XMLCh* fLocalPart;
|
---|
254 | unsigned int fLocalPartBufSz;
|
---|
255 | XMLCh* fRawName;
|
---|
256 | unsigned int fRawNameBufSz;
|
---|
257 | unsigned int fURIId;
|
---|
258 | };
|
---|
259 |
|
---|
260 | // ---------------------------------------------------------------------------
|
---|
261 | // QName: Getter methods
|
---|
262 | // ---------------------------------------------------------------------------
|
---|
263 | inline const XMLCh* QName::getPrefix() const
|
---|
264 | {
|
---|
265 | return fPrefix;
|
---|
266 | }
|
---|
267 |
|
---|
268 | inline XMLCh* QName::getPrefix()
|
---|
269 | {
|
---|
270 | return fPrefix;
|
---|
271 | }
|
---|
272 |
|
---|
273 | inline const XMLCh* QName::getLocalPart() const
|
---|
274 | {
|
---|
275 | return fLocalPart;
|
---|
276 | }
|
---|
277 |
|
---|
278 | inline XMLCh* QName::getLocalPart()
|
---|
279 | {
|
---|
280 | return fLocalPart;
|
---|
281 | }
|
---|
282 |
|
---|
283 | inline unsigned int QName::getURI() const
|
---|
284 | {
|
---|
285 | return fURIId;
|
---|
286 | }
|
---|
287 |
|
---|
288 | inline MemoryManager* QName::getMemoryManager() const
|
---|
289 | {
|
---|
290 | return fMemoryManager;
|
---|
291 | }
|
---|
292 |
|
---|
293 | // ---------------------------------------------------------------------------
|
---|
294 | // QName: Setter methods
|
---|
295 | // ---------------------------------------------------------------------------
|
---|
296 | inline void QName::setURI(const unsigned int uriId)
|
---|
297 | {
|
---|
298 | fURIId = uriId;
|
---|
299 | }
|
---|
300 |
|
---|
301 | XERCES_CPP_NAMESPACE_END
|
---|
302 |
|
---|
303 | #endif
|
---|