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