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 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(QNAME_HPP) |
---|
23 | #define 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 | { |
---|
36 | public : |
---|
37 | // ----------------------------------------------------------------------- |
---|
38 | // Contructors and Destructor |
---|
39 | // ----------------------------------------------------------------------- |
---|
40 | /** Default constructor. */ |
---|
41 | QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
42 | |
---|
43 | /** Constructs a specified qname using prefix, and localpart. */ |
---|
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 | |
---|
52 | /** Constructs a specified qname using rawName. */ |
---|
53 | QName |
---|
54 | ( |
---|
55 | const XMLCh* const rawName |
---|
56 | , const unsigned int uriId |
---|
57 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
58 | ); |
---|
59 | |
---|
60 | /** Copy constructor. */ |
---|
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 unsigned int) ; |
---|
100 | void setNLocalPart(const XMLCh*, const unsigned int) ; |
---|
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 | // pratical 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 fauled in. |
---|
150 | // |
---|
151 | // fURIId |
---|
152 | // The id of the URI that this attribute belongs to. |
---|
153 | // ----------------------------------------------------------------------- |
---|
154 | unsigned int fPrefixBufSz; |
---|
155 | unsigned int fLocalPartBufSz; |
---|
156 | unsigned int 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 | XERCES_CPP_NAMESPACE_END |
---|
206 | |
---|
207 | #endif |
---|