source: obsolete/tags/VUT/0.4/GtpVisibilityPreprocessor/support/xerces/include/xercesc/validators/schema/SchemaAttDefList.hpp @ 358

Revision 358, 7.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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 * $Log: SchemaAttDefList.hpp,v $
19 * Revision 1.9  2004/09/10 18:42:06  cargilld
20 * Performance improvement fix to more efficiently findattdef.  Fix from Dave Bertoni.
21 *
22 * Revision 1.8  2004/09/08 13:56:56  peiyongz
23 * Apache License Version 2.0
24 *
25 * Revision 1.7  2004/01/29 11:52:31  cargilld
26 * Code cleanup changes to get rid of various compiler diagnostic messages.
27 *
28 * Revision 1.6  2003/11/10 21:54:51  neilg
29 * implementation for new stateless means of traversing attribute definition lists
30 *
31 * Revision 1.5  2003/10/20 11:46:28  gareth
32 * Pass in memory manager to constructors and use for creation of enumerators.
33 *
34 * Revision 1.4  2003/10/10 16:25:40  peiyongz
35 * Implementation of Serialization/Deserialization
36 *
37 * Revision 1.3  2002/12/06 13:27:14  tng
38 * [Bug 9083] Make some classes be exportable.
39 *
40 * Revision 1.2  2002/11/04 14:49:41  tng
41 * C++ Namespace Support.
42 *
43 * Revision 1.1.1.1  2002/02/01 22:22:46  peiyongz
44 * sane_include
45 *
46 * Revision 1.2  2001/05/11 13:27:34  tng
47 * Copyright update.
48 *
49 * Revision 1.1  2001/02/27 18:48:22  tng
50 * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
51 *
52 */
53
54
55#if !defined(SCHEMAATTDEFLIST_HPP)
56#define SCHEMAATTDEFLIST_HPP
57
58#include <xercesc/util/RefHash2KeysTableOf.hpp>
59#include <xercesc/validators/schema/SchemaElementDecl.hpp>
60
61XERCES_CPP_NAMESPACE_BEGIN
62
63//
64//  This is a derivative of the framework abstract class which defines the
65//  interface to a list of attribute defs that belong to a particular
66//  element. The scanner needs to be able to get a list of the attributes
67//  that an element supports, for use during the validation process and for
68//  fixed/default attribute processing.
69//
70//  For us, we just wrap the RefHash2KeysTableOf collection that the SchemaElementDecl
71//  class uses to store the attributes that belong to it.
72//
73//  This class does not adopt the hash table, it just references it. The
74//  hash table is owned by the element decl it is a member of.
75//
76class VALIDATORS_EXPORT SchemaAttDefList : public XMLAttDefList
77{
78public :
79    // -----------------------------------------------------------------------
80    //  Constructors and Destructor
81    // -----------------------------------------------------------------------
82    SchemaAttDefList
83    (
84         RefHash2KeysTableOf<SchemaAttDef>* const    listToUse,
85         MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
86    );
87
88    ~SchemaAttDefList();
89
90
91    // -----------------------------------------------------------------------
92    //  Implementation of the virtual interface
93    // -----------------------------------------------------------------------
94
95    /**
96     * @deprecated This method is not thread-safe.
97     */
98    virtual bool hasMoreElements() const;
99
100    virtual bool isEmpty() const;
101    virtual XMLAttDef* findAttDef
102    (
103        const   unsigned long       uriID
104        , const XMLCh* const        attName
105    );
106    virtual const XMLAttDef* findAttDef
107    (
108        const   unsigned long       uriID
109        , const XMLCh* const        attName
110    )   const;
111    virtual XMLAttDef* findAttDef
112    (
113        const   XMLCh* const        attURI
114        , const XMLCh* const        attName
115    );
116    virtual const XMLAttDef* findAttDef
117    (
118        const   XMLCh* const        attURI
119        , const XMLCh* const        attName
120    )   const;
121
122    virtual XMLAttDef* findAttDefLocalPart
123    (
124        const   unsigned long       uriID
125        , const XMLCh* const        attLocalPart
126    );
127
128    virtual const XMLAttDef* findAttDefLocalPart
129    (
130        const   unsigned long       uriID
131        , const XMLCh* const        attLocalPart
132    )   const;
133
134    /**
135     * @deprecated This method is not thread-safe.
136     */
137    virtual XMLAttDef& nextElement();
138
139    /**
140     * @deprecated This method is not thread-safe.
141     */
142    virtual void Reset();
143
144    /**
145     * return total number of attributes in this list
146     */
147    virtual unsigned int getAttDefCount() const ;
148
149    /**
150     * return attribute at the index-th position in the list.
151     */
152    virtual XMLAttDef &getAttDef(unsigned int index) ;
153
154    /**
155     * return attribute at the index-th position in the list.
156     */
157    virtual const XMLAttDef &getAttDef(unsigned int index) const ;
158
159    /***
160     * Support for Serialization/De-serialization
161     ***/
162    DECL_XSERIALIZABLE(SchemaAttDefList)
163
164        SchemaAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
165
166private :
167    // -----------------------------------------------------------------------
168    //  Unimplemented constructors and operators
169    // -----------------------------------------------------------------------
170    SchemaAttDefList(const SchemaAttDefList&);
171    SchemaAttDefList& operator=(const SchemaAttDefList&);
172
173    void addAttDef(SchemaAttDef *toAdd);
174
175    // -----------------------------------------------------------------------
176    //  Private data members
177    //
178    //  fEnum
179    //      This is an enumerator for the list that we use to do the enumerator
180    //      type methods of this class.
181    //
182    //  fList
183    //      The list of SchemaAttDef objects that represent the attributes that
184    //      a particular element supports.
185    //  fArray
186    //      vector of pointers to the DTDAttDef objects contained in this list
187    //  fSize
188    //      size of fArray
189    //  fCount
190    //      number of DTDAttDef objects currently stored in this list
191    // -----------------------------------------------------------------------
192    RefHash2KeysTableOfEnumerator<SchemaAttDef>*    fEnum;
193    RefHash2KeysTableOf<SchemaAttDef>*              fList;
194    SchemaAttDef**                          fArray;
195    unsigned int                            fSize;
196    unsigned int                            fCount;
197
198    friend class ComplexTypeInfo;
199};
200
201inline void SchemaAttDefList::addAttDef(SchemaAttDef *toAdd)
202{
203    if(fCount == fSize)
204    {
205        // need to grow fArray
206        fSize <<= 1;
207        SchemaAttDef** newArray = (SchemaAttDef **)((getMemoryManager())->allocate( sizeof(SchemaAttDef*) * fSize ));
208        memcpy(newArray, fArray, fCount * sizeof(SchemaAttDef *));
209        (getMemoryManager())->deallocate(fArray);
210        fArray = newArray;
211    }
212    fArray[fCount++] = toAdd;
213}
214
215inline XMLAttDef* SchemaAttDefList::findAttDefLocalPart(const   unsigned long       uriID
216                                                      , const XMLCh* const        attLocalPart)
217{
218    return fList->get((void*)attLocalPart, uriID);
219}
220
221inline const XMLAttDef* SchemaAttDefList::findAttDefLocalPart(const   unsigned long       uriID
222                                                            , const XMLCh* const        attLocalPart)   const
223{
224    return fList->get((void*)attLocalPart, uriID);
225}
226
227XERCES_CPP_NAMESPACE_END
228
229#endif
Note: See TracBrowser for help on using the repository browser.