1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2000 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) 1999, 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: DTDAttDefList.hpp,v $
|
---|
59 | * Revision 1.7 2004/01/29 11:52:30 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:24:51 peiyongz
|
---|
69 | * Implementation of Serialization/Deserialization
|
---|
70 | *
|
---|
71 | * Revision 1.3 2002/12/06 13:27:22 tng
|
---|
72 | * [Bug 9083] Make some classes be exportable.
|
---|
73 | *
|
---|
74 | * Revision 1.2 2002/11/04 14:50:40 tng
|
---|
75 | * C++ Namespace Support.
|
---|
76 | *
|
---|
77 | * Revision 1.1.1.1 2002/02/01 22:22:43 peiyongz
|
---|
78 | * sane_include
|
---|
79 | *
|
---|
80 | * Revision 1.3 2000/02/24 20:16:48 abagchi
|
---|
81 | * Swat for removing Log from API docs
|
---|
82 | *
|
---|
83 | * Revision 1.2 2000/02/09 21:42:37 abagchi
|
---|
84 | * Copyright swat
|
---|
85 | *
|
---|
86 | * Revision 1.1.1.1 1999/11/09 01:03:28 twl
|
---|
87 | * Initial checkin
|
---|
88 | *
|
---|
89 | * Revision 1.2 1999/11/08 20:45:39 rahul
|
---|
90 | * Swat for adding in Product name and CVS comment log variable.
|
---|
91 | *
|
---|
92 | */
|
---|
93 |
|
---|
94 |
|
---|
95 | #if !defined(DTDATTDEFLIST_HPP)
|
---|
96 | #define DTDATTDEFLIST_HPP
|
---|
97 |
|
---|
98 | #include <xercesc/util/RefHashTableOf.hpp>
|
---|
99 | #include <xercesc/validators/DTD/DTDElementDecl.hpp>
|
---|
100 |
|
---|
101 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
102 |
|
---|
103 | //
|
---|
104 | // This is a derivative of the framework abstract class which defines the
|
---|
105 | // interface to a list of attribute defs that belong to a particular
|
---|
106 | // element. The scanner needs to be able to get a list of the attributes
|
---|
107 | // that an element supports, for use during the validation process and for
|
---|
108 | // fixed/default attribute processing.
|
---|
109 | //
|
---|
110 | // Since each validator can store attributes differently, this abstract
|
---|
111 | // interface allows each validator to provide an implementation of this
|
---|
112 | // data strucure that works best for it.
|
---|
113 | //
|
---|
114 | // For us, we just wrap the RefHashTableOf collection that the DTDElementDecl
|
---|
115 | // class uses to store the attributes that belong to it.
|
---|
116 | //
|
---|
117 | // This clss does not adopt the hash table, it just references it. The
|
---|
118 | // hash table is owned by the element decl it is a member of.
|
---|
119 | //
|
---|
120 | class VALIDATORS_EXPORT DTDAttDefList : public XMLAttDefList
|
---|
121 | {
|
---|
122 | public :
|
---|
123 | // -----------------------------------------------------------------------
|
---|
124 | // Constructors and Destructor
|
---|
125 | // -----------------------------------------------------------------------
|
---|
126 | DTDAttDefList
|
---|
127 | (
|
---|
128 | RefHashTableOf<DTDAttDef>* const listToUse,
|
---|
129 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
130 | );
|
---|
131 |
|
---|
132 | ~DTDAttDefList();
|
---|
133 |
|
---|
134 |
|
---|
135 | // -----------------------------------------------------------------------
|
---|
136 | // Implementation of the virtual interface
|
---|
137 | // -----------------------------------------------------------------------
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * @deprecated This method is not thread-safe.
|
---|
141 | */
|
---|
142 | virtual bool hasMoreElements() const;
|
---|
143 | virtual bool isEmpty() const;
|
---|
144 | virtual XMLAttDef* findAttDef
|
---|
145 | (
|
---|
146 | const unsigned long uriID
|
---|
147 | , const XMLCh* const attName
|
---|
148 | );
|
---|
149 | virtual const XMLAttDef* findAttDef
|
---|
150 | (
|
---|
151 | const unsigned long uriID
|
---|
152 | , const XMLCh* const attName
|
---|
153 | ) const;
|
---|
154 | virtual XMLAttDef* findAttDef
|
---|
155 | (
|
---|
156 | const XMLCh* const attURI
|
---|
157 | , const XMLCh* const attName
|
---|
158 | );
|
---|
159 | virtual const XMLAttDef* findAttDef
|
---|
160 | (
|
---|
161 | const XMLCh* const attURI
|
---|
162 | , const XMLCh* const attName
|
---|
163 | ) const;
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * @deprecated This method is not thread-safe.
|
---|
167 | */
|
---|
168 | virtual XMLAttDef& nextElement();
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * @deprecated This method is not thread-safe.
|
---|
172 | */
|
---|
173 | virtual void Reset();
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * return total number of attributes in this list
|
---|
177 | */
|
---|
178 | virtual unsigned int getAttDefCount() const ;
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * return attribute at the index-th position in the list.
|
---|
182 | */
|
---|
183 | virtual XMLAttDef &getAttDef(unsigned int index) ;
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * return attribute at the index-th position in the list.
|
---|
187 | */
|
---|
188 | virtual const XMLAttDef &getAttDef(unsigned int index) const ;
|
---|
189 |
|
---|
190 | /***
|
---|
191 | * Support for Serialization/De-serialization
|
---|
192 | ***/
|
---|
193 | DECL_XSERIALIZABLE(DTDAttDefList)
|
---|
194 |
|
---|
195 | DTDAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
196 |
|
---|
197 | private :
|
---|
198 |
|
---|
199 | void addAttDef(DTDAttDef *toAdd);
|
---|
200 | // -----------------------------------------------------------------------
|
---|
201 | // Unimplemented constructors and operators
|
---|
202 | // -----------------------------------------------------------------------
|
---|
203 | DTDAttDefList(const DTDAttDefList &);
|
---|
204 | DTDAttDefList& operator = (const DTDAttDefList&);
|
---|
205 |
|
---|
206 | // -----------------------------------------------------------------------
|
---|
207 | // Private data members
|
---|
208 | //
|
---|
209 | // fEnum
|
---|
210 | // This is an enerator for the list that we use to do the enumerator
|
---|
211 | // type methods of this class.
|
---|
212 | //
|
---|
213 | // fList
|
---|
214 | // The list of DTDAttDef objects that represent the attributes that
|
---|
215 | // a particular element supports.
|
---|
216 | // fArray
|
---|
217 | // vector of pointers to the DTDAttDef objects contained in this list
|
---|
218 | // fSize
|
---|
219 | // size of fArray
|
---|
220 | // fCount
|
---|
221 | // number of DTDAttDef objects currently stored in this list
|
---|
222 | // -----------------------------------------------------------------------
|
---|
223 | RefHashTableOfEnumerator<DTDAttDef>* fEnum;
|
---|
224 | RefHashTableOf<DTDAttDef>* fList;
|
---|
225 | DTDAttDef** fArray;
|
---|
226 | unsigned int fSize;
|
---|
227 | unsigned int fCount;
|
---|
228 |
|
---|
229 | friend class DTDElementDecl;
|
---|
230 | };
|
---|
231 |
|
---|
232 | inline void DTDAttDefList::addAttDef(DTDAttDef *toAdd)
|
---|
233 | {
|
---|
234 | if(fCount == fSize)
|
---|
235 | {
|
---|
236 | // need to grow fArray
|
---|
237 | fSize <<= 1;
|
---|
238 | DTDAttDef** newArray = (DTDAttDef **)((getMemoryManager())->allocate( sizeof(DTDAttDef*) * fSize ));
|
---|
239 | memcpy(newArray, fArray, fCount * sizeof(DTDAttDef *));
|
---|
240 | (getMemoryManager())->deallocate(fArray);
|
---|
241 | fArray = newArray;
|
---|
242 | }
|
---|
243 | fArray[fCount++] = toAdd;
|
---|
244 | }
|
---|
245 |
|
---|
246 | XERCES_CPP_NAMESPACE_END
|
---|
247 |
|
---|
248 | #endif
|
---|