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