source: NonGTP/Xerces/xercesc/validators/schema/XercesAttGroupInfo.hpp @ 188

Revision 188, 9.8 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 2001-2003 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 * $Id: XercesAttGroupInfo.hpp,v 1.8 2003/12/17 20:50:35 knoaman Exp $
59 */
60
61#if !defined(XERCESATTGROUPINFO_HPP)
62#define XERCESATTGROUPINFO_HPP
63
64
65/**
66  * The class act as a place holder to store attributeGroup information.
67  *
68  * The class is intended for internal use.
69  */
70
71// ---------------------------------------------------------------------------
72//  Includes
73// ---------------------------------------------------------------------------
74#include <xercesc/util/RefVectorOf.hpp>
75#include <xercesc/validators/schema/SchemaAttDef.hpp>
76
77#include <xercesc/internal/XSerializable.hpp>
78
79XERCES_CPP_NAMESPACE_BEGIN
80
81class VALIDATORS_EXPORT XercesAttGroupInfo : public XSerializable, public XMemory
82{
83public:
84    // -----------------------------------------------------------------------
85    //  Public Constructors/Destructor
86    // -----------------------------------------------------------------------
87    XercesAttGroupInfo
88    (
89        unsigned int           attGroupNameId
90        , unsigned int         attGroupNamespaceId
91        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
92    );
93    ~XercesAttGroupInfo();
94
95    // -----------------------------------------------------------------------
96    //  Getter methods
97    // -----------------------------------------------------------------------
98    bool                containsTypeWithId() const;
99    unsigned int        attributeCount() const;
100    unsigned int        anyAttributeCount() const;
101    unsigned int        getNameId() const;
102    unsigned int        getNamespaceId() const;
103    SchemaAttDef*       attributeAt(const unsigned int index);
104    const SchemaAttDef* attributeAt(const unsigned int index) const;
105    SchemaAttDef*       anyAttributeAt(const unsigned int index);
106    const SchemaAttDef* anyAttributeAt(const unsigned int index) const;
107    SchemaAttDef*       getCompleteWildCard() const;
108    const SchemaAttDef* getAttDef(const XMLCh* const baseName,
109                                  const int uriId) const;
110
111        // -----------------------------------------------------------------------
112    //  Setter methods
113    // -----------------------------------------------------------------------
114    void setTypeWithId(const bool other);
115    void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
116    void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
117    void setCompleteWildCard(SchemaAttDef* const toSet);
118
119        // -----------------------------------------------------------------------
120    //  Query methods
121    // -----------------------------------------------------------------------
122    bool containsAttribute(const XMLCh* const name, const unsigned int uri);
123
124    /***
125     * Support for Serialization/De-serialization
126     ***/
127    DECL_XSERIALIZABLE(XercesAttGroupInfo)
128    XercesAttGroupInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
129
130private:
131    // -----------------------------------------------------------------------
132    //  Unimplemented contstructors and operators
133    // -----------------------------------------------------------------------
134    XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo);
135    XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other);
136
137    // -----------------------------------------------------------------------
138    //  Private data members
139    // -----------------------------------------------------------------------
140    bool                       fTypeWithId;
141    unsigned int               fNameId;
142    unsigned int               fNamespaceId;
143    RefVectorOf<SchemaAttDef>* fAttributes;
144    RefVectorOf<SchemaAttDef>* fAnyAttributes;
145    SchemaAttDef*              fCompleteWildCard;
146    MemoryManager*             fMemoryManager;
147};
148
149// ---------------------------------------------------------------------------
150//  XercesAttGroupInfo: Getter methods
151// ---------------------------------------------------------------------------
152inline bool XercesAttGroupInfo::containsTypeWithId() const {
153
154    return fTypeWithId;
155}
156
157inline unsigned int XercesAttGroupInfo::attributeCount() const {
158
159    if (fAttributes) {
160        return fAttributes->size();
161    }
162
163    return 0;
164}
165
166inline unsigned int XercesAttGroupInfo::anyAttributeCount() const {
167
168    if (fAnyAttributes) {
169        return fAnyAttributes->size();
170    }
171
172    return 0;
173}
174
175inline unsigned int XercesAttGroupInfo::getNameId() const
176{
177    return fNameId;
178}
179
180inline unsigned int XercesAttGroupInfo::getNamespaceId() const
181{
182    return fNamespaceId;
183}
184
185inline SchemaAttDef*
186XercesAttGroupInfo::attributeAt(const unsigned int index) {
187
188    if (fAttributes) {
189        return fAttributes->elementAt(index);
190    }
191
192    return 0;
193}
194
195inline const SchemaAttDef*
196XercesAttGroupInfo::attributeAt(const unsigned int index) const {
197
198    if (fAttributes) {
199        return fAttributes->elementAt(index);
200    }
201
202    return 0;
203}
204
205inline SchemaAttDef*
206XercesAttGroupInfo::anyAttributeAt(const unsigned int index) {
207
208    if (fAnyAttributes) {
209        return fAnyAttributes->elementAt(index);
210    }
211
212    return 0;
213}
214
215inline const SchemaAttDef*
216XercesAttGroupInfo::anyAttributeAt(const unsigned int index) const {
217
218    if (fAnyAttributes) {
219        return fAnyAttributes->elementAt(index);
220    }
221
222    return 0;
223}
224
225inline SchemaAttDef*
226XercesAttGroupInfo::getCompleteWildCard() const {
227
228    return fCompleteWildCard;
229}
230
231// ---------------------------------------------------------------------------
232//  XercesAttGroupInfo: Setter methods
233// ---------------------------------------------------------------------------
234inline void XercesAttGroupInfo::setTypeWithId(const bool other) {
235
236    fTypeWithId = other;
237}
238
239inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd,
240                                             const bool toClone) {
241
242    if (!fAttributes) {
243        fAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(4, true, fMemoryManager);
244    }
245
246    if (toClone) {
247        SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd);
248
249        if (!clonedAttDef->getBaseAttDecl())
250            clonedAttDef->setBaseAttDecl(toAdd);
251
252        fAttributes->addElement(clonedAttDef);
253    }
254    else {
255        fAttributes->addElement(toAdd);
256    }
257}
258
259inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd,
260                                             const bool toClone) {
261
262    if (!fAnyAttributes) {
263        fAnyAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(2, true, fMemoryManager);
264    }
265
266    if (toClone) {
267        SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd);
268
269        if (!clonedAttDef->getBaseAttDecl())
270            clonedAttDef->setBaseAttDecl(toAdd);
271
272        fAnyAttributes->addElement(clonedAttDef);
273    }
274    else {
275        fAnyAttributes->addElement(toAdd);
276    }
277}
278
279inline void
280XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) {
281
282    if (fCompleteWildCard) {
283        delete fCompleteWildCard;
284    }
285
286    fCompleteWildCard = toSet;
287}
288
289XERCES_CPP_NAMESPACE_END
290
291#endif
292
293/**
294  * End of file XercesAttGroupInfo.hpp
295  */
296
Note: See TracBrowser for help on using the repository browser.