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: XercesAttGroupInfo.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(XERCESATTGROUPINFO_HPP) |
---|
23 | #define XERCESATTGROUPINFO_HPP |
---|
24 | |
---|
25 | |
---|
26 | /** |
---|
27 | * The class act as a place holder to store attributeGroup information. |
---|
28 | * |
---|
29 | * The class is intended for internal use. |
---|
30 | */ |
---|
31 | |
---|
32 | // --------------------------------------------------------------------------- |
---|
33 | // Includes |
---|
34 | // --------------------------------------------------------------------------- |
---|
35 | #include <xercesc/util/RefVectorOf.hpp> |
---|
36 | #include <xercesc/validators/schema/SchemaAttDef.hpp> |
---|
37 | |
---|
38 | #include <xercesc/internal/XSerializable.hpp> |
---|
39 | |
---|
40 | XERCES_CPP_NAMESPACE_BEGIN |
---|
41 | |
---|
42 | class VALIDATORS_EXPORT XercesAttGroupInfo : public XSerializable, public XMemory |
---|
43 | { |
---|
44 | public: |
---|
45 | // ----------------------------------------------------------------------- |
---|
46 | // Public Constructors/Destructor |
---|
47 | // ----------------------------------------------------------------------- |
---|
48 | XercesAttGroupInfo |
---|
49 | ( |
---|
50 | unsigned int attGroupNameId |
---|
51 | , unsigned int attGroupNamespaceId |
---|
52 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
53 | ); |
---|
54 | ~XercesAttGroupInfo(); |
---|
55 | |
---|
56 | // ----------------------------------------------------------------------- |
---|
57 | // Getter methods |
---|
58 | // ----------------------------------------------------------------------- |
---|
59 | bool containsTypeWithId() const; |
---|
60 | unsigned int attributeCount() const; |
---|
61 | unsigned int anyAttributeCount() const; |
---|
62 | unsigned int getNameId() const; |
---|
63 | unsigned int getNamespaceId() const; |
---|
64 | SchemaAttDef* attributeAt(const unsigned int index); |
---|
65 | const SchemaAttDef* attributeAt(const unsigned int index) const; |
---|
66 | SchemaAttDef* anyAttributeAt(const unsigned int index); |
---|
67 | const SchemaAttDef* anyAttributeAt(const unsigned int index) const; |
---|
68 | SchemaAttDef* getCompleteWildCard() const; |
---|
69 | const SchemaAttDef* getAttDef(const XMLCh* const baseName, |
---|
70 | const int uriId) const; |
---|
71 | |
---|
72 | // ----------------------------------------------------------------------- |
---|
73 | // Setter methods |
---|
74 | // ----------------------------------------------------------------------- |
---|
75 | void setTypeWithId(const bool other); |
---|
76 | void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false); |
---|
77 | void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false); |
---|
78 | void setCompleteWildCard(SchemaAttDef* const toSet); |
---|
79 | |
---|
80 | // ----------------------------------------------------------------------- |
---|
81 | // Query methods |
---|
82 | // ----------------------------------------------------------------------- |
---|
83 | bool containsAttribute(const XMLCh* const name, const unsigned int uri); |
---|
84 | |
---|
85 | /*** |
---|
86 | * Support for Serialization/De-serialization |
---|
87 | ***/ |
---|
88 | DECL_XSERIALIZABLE(XercesAttGroupInfo) |
---|
89 | XercesAttGroupInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
90 | |
---|
91 | private: |
---|
92 | // ----------------------------------------------------------------------- |
---|
93 | // Unimplemented contstructors and operators |
---|
94 | // ----------------------------------------------------------------------- |
---|
95 | XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo); |
---|
96 | XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other); |
---|
97 | |
---|
98 | // ----------------------------------------------------------------------- |
---|
99 | // Private data members |
---|
100 | // ----------------------------------------------------------------------- |
---|
101 | bool fTypeWithId; |
---|
102 | unsigned int fNameId; |
---|
103 | unsigned int fNamespaceId; |
---|
104 | RefVectorOf<SchemaAttDef>* fAttributes; |
---|
105 | RefVectorOf<SchemaAttDef>* fAnyAttributes; |
---|
106 | SchemaAttDef* fCompleteWildCard; |
---|
107 | MemoryManager* fMemoryManager; |
---|
108 | }; |
---|
109 | |
---|
110 | // --------------------------------------------------------------------------- |
---|
111 | // XercesAttGroupInfo: Getter methods |
---|
112 | // --------------------------------------------------------------------------- |
---|
113 | inline bool XercesAttGroupInfo::containsTypeWithId() const { |
---|
114 | |
---|
115 | return fTypeWithId; |
---|
116 | } |
---|
117 | |
---|
118 | inline unsigned int XercesAttGroupInfo::attributeCount() const { |
---|
119 | |
---|
120 | if (fAttributes) { |
---|
121 | return fAttributes->size(); |
---|
122 | } |
---|
123 | |
---|
124 | return 0; |
---|
125 | } |
---|
126 | |
---|
127 | inline unsigned int XercesAttGroupInfo::anyAttributeCount() const { |
---|
128 | |
---|
129 | if (fAnyAttributes) { |
---|
130 | return fAnyAttributes->size(); |
---|
131 | } |
---|
132 | |
---|
133 | return 0; |
---|
134 | } |
---|
135 | |
---|
136 | inline unsigned int XercesAttGroupInfo::getNameId() const |
---|
137 | { |
---|
138 | return fNameId; |
---|
139 | } |
---|
140 | |
---|
141 | inline unsigned int XercesAttGroupInfo::getNamespaceId() const |
---|
142 | { |
---|
143 | return fNamespaceId; |
---|
144 | } |
---|
145 | |
---|
146 | inline SchemaAttDef* |
---|
147 | XercesAttGroupInfo::attributeAt(const unsigned int index) { |
---|
148 | |
---|
149 | if (fAttributes) { |
---|
150 | return fAttributes->elementAt(index); |
---|
151 | } |
---|
152 | |
---|
153 | return 0; |
---|
154 | } |
---|
155 | |
---|
156 | inline const SchemaAttDef* |
---|
157 | XercesAttGroupInfo::attributeAt(const unsigned int index) const { |
---|
158 | |
---|
159 | if (fAttributes) { |
---|
160 | return fAttributes->elementAt(index); |
---|
161 | } |
---|
162 | |
---|
163 | return 0; |
---|
164 | } |
---|
165 | |
---|
166 | inline SchemaAttDef* |
---|
167 | XercesAttGroupInfo::anyAttributeAt(const unsigned int index) { |
---|
168 | |
---|
169 | if (fAnyAttributes) { |
---|
170 | return fAnyAttributes->elementAt(index); |
---|
171 | } |
---|
172 | |
---|
173 | return 0; |
---|
174 | } |
---|
175 | |
---|
176 | inline const SchemaAttDef* |
---|
177 | XercesAttGroupInfo::anyAttributeAt(const unsigned int index) const { |
---|
178 | |
---|
179 | if (fAnyAttributes) { |
---|
180 | return fAnyAttributes->elementAt(index); |
---|
181 | } |
---|
182 | |
---|
183 | return 0; |
---|
184 | } |
---|
185 | |
---|
186 | inline SchemaAttDef* |
---|
187 | XercesAttGroupInfo::getCompleteWildCard() const { |
---|
188 | |
---|
189 | return fCompleteWildCard; |
---|
190 | } |
---|
191 | |
---|
192 | // --------------------------------------------------------------------------- |
---|
193 | // XercesAttGroupInfo: Setter methods |
---|
194 | // --------------------------------------------------------------------------- |
---|
195 | inline void XercesAttGroupInfo::setTypeWithId(const bool other) { |
---|
196 | |
---|
197 | fTypeWithId = other; |
---|
198 | } |
---|
199 | |
---|
200 | inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd, |
---|
201 | const bool toClone) { |
---|
202 | |
---|
203 | if (!fAttributes) { |
---|
204 | fAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(4, true, fMemoryManager); |
---|
205 | } |
---|
206 | |
---|
207 | if (toClone) { |
---|
208 | SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd); |
---|
209 | |
---|
210 | if (!clonedAttDef->getBaseAttDecl()) |
---|
211 | clonedAttDef->setBaseAttDecl(toAdd); |
---|
212 | |
---|
213 | fAttributes->addElement(clonedAttDef); |
---|
214 | } |
---|
215 | else { |
---|
216 | fAttributes->addElement(toAdd); |
---|
217 | } |
---|
218 | } |
---|
219 | |
---|
220 | inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd, |
---|
221 | const bool toClone) { |
---|
222 | |
---|
223 | if (!fAnyAttributes) { |
---|
224 | fAnyAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(2, true, fMemoryManager); |
---|
225 | } |
---|
226 | |
---|
227 | if (toClone) { |
---|
228 | SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd); |
---|
229 | |
---|
230 | if (!clonedAttDef->getBaseAttDecl()) |
---|
231 | clonedAttDef->setBaseAttDecl(toAdd); |
---|
232 | |
---|
233 | fAnyAttributes->addElement(clonedAttDef); |
---|
234 | } |
---|
235 | else { |
---|
236 | fAnyAttributes->addElement(toAdd); |
---|
237 | } |
---|
238 | } |
---|
239 | |
---|
240 | inline void |
---|
241 | XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) { |
---|
242 | |
---|
243 | if (fCompleteWildCard) { |
---|
244 | delete fCompleteWildCard; |
---|
245 | } |
---|
246 | |
---|
247 | fCompleteWildCard = toSet; |
---|
248 | } |
---|
249 | |
---|
250 | XERCES_CPP_NAMESPACE_END |
---|
251 | |
---|
252 | #endif |
---|
253 | |
---|
254 | /** |
---|
255 | * End of file XercesAttGroupInfo.hpp |
---|
256 | */ |
---|
257 | |
---|