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 | * $Id: ListDatatypeValidator.hpp,v 1.12 2004/01/29 11:51:22 cargilld Exp $
|
---|
59 | * $Log: ListDatatypeValidator.hpp,v $
|
---|
60 | * Revision 1.12 2004/01/29 11:51:22 cargilld
|
---|
61 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
62 | *
|
---|
63 | * Revision 1.11 2003/12/23 21:50:36 peiyongz
|
---|
64 | * Absorb exception thrown in getCanonicalRepresentation and return 0,
|
---|
65 | * only validate when required
|
---|
66 | *
|
---|
67 | * Revision 1.10 2003/12/17 00:18:39 cargilld
|
---|
68 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
69 | *
|
---|
70 | * Revision 1.9 2003/11/28 18:53:07 peiyongz
|
---|
71 | * Support for getCanonicalRepresentation
|
---|
72 | *
|
---|
73 | * Revision 1.8 2003/11/12 20:32:03 peiyongz
|
---|
74 | * Statless Grammar: ValidationContext
|
---|
75 | *
|
---|
76 | * Revision 1.7 2003/09/30 21:31:30 peiyongz
|
---|
77 | * Implementation of Serialization/Deserialization
|
---|
78 | *
|
---|
79 | * Revision 1.6 2003/05/15 18:53:26 knoaman
|
---|
80 | * Partial implementation of the configurable memory manager.
|
---|
81 | *
|
---|
82 | * Revision 1.5 2002/12/18 14:17:55 gareth
|
---|
83 | * Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
|
---|
84 | *
|
---|
85 | * Revision 1.4 2002/12/16 22:28:25 knoaman
|
---|
86 | * Make isAtomic inline.
|
---|
87 | *
|
---|
88 | * Revision 1.3 2002/11/20 19:57:44 peiyongz
|
---|
89 | * validate content as a whole against pattern.
|
---|
90 | *
|
---|
91 | * Revision 1.2 2002/11/04 14:53:28 tng
|
---|
92 | * C++ Namespace Support.
|
---|
93 | *
|
---|
94 | * Revision 1.1.1.1 2002/02/01 22:22:42 peiyongz
|
---|
95 | * sane_include
|
---|
96 | *
|
---|
97 | * Revision 1.11 2001/11/22 20:23:20 peiyongz
|
---|
98 | * _declspec(dllimport) and inline warning C4273
|
---|
99 | *
|
---|
100 | * Revision 1.10 2001/11/15 16:08:15 peiyongz
|
---|
101 | * checkContent() made virtual to allow ListDTV participate in the building of
|
---|
102 | * its own (in AbstractStringValidator's init())
|
---|
103 | *
|
---|
104 | * Revision 1.9 2001/10/11 19:32:27 peiyongz
|
---|
105 | * To overwrite inheritFacet()
|
---|
106 | *
|
---|
107 | * Revision 1.8 2001/10/09 20:56:21 peiyongz
|
---|
108 | * inherit from AbstractStringValidator instead of DatatypeValidator to reuse
|
---|
109 | * the code.
|
---|
110 | *
|
---|
111 | * Revision 1.7 2001/08/29 19:03:40 peiyongz
|
---|
112 | * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method
|
---|
113 | *
|
---|
114 | * Revision 1.6 2001/08/24 17:12:01 knoaman
|
---|
115 | * Add support for anySimpleType.
|
---|
116 | * Remove parameter 'baseValidator' from the virtual method 'newInstance'.
|
---|
117 | *
|
---|
118 | * Revision 1.5 2001/08/21 20:05:41 peiyongz
|
---|
119 | * put back changes introduced in 1.3
|
---|
120 | *
|
---|
121 | * Revision 1.3 2001/08/16 14:41:38 knoaman
|
---|
122 | * implementation of virtual methods.
|
---|
123 | *
|
---|
124 | * Revision 1.2 2001/07/24 21:23:40 tng
|
---|
125 | * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION.
|
---|
126 | *
|
---|
127 | * Revision 1.1 2001/07/11 21:37:17 peiyongz
|
---|
128 | * ListDatatypeDTV
|
---|
129 | *
|
---|
130 | */
|
---|
131 |
|
---|
132 | #if !defined(LIST_DATATYPEVALIDATOR_HPP)
|
---|
133 | #define LIST_DATATYPEVALIDATOR_HPP
|
---|
134 |
|
---|
135 | #include <xercesc/validators/datatype/AbstractStringValidator.hpp>
|
---|
136 | #include <xercesc/validators/schema/SchemaSymbols.hpp>
|
---|
137 |
|
---|
138 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
139 |
|
---|
140 | class VALIDATORS_EXPORT ListDatatypeValidator : public AbstractStringValidator
|
---|
141 | {
|
---|
142 | public:
|
---|
143 |
|
---|
144 | // -----------------------------------------------------------------------
|
---|
145 | // Public ctor/dtor
|
---|
146 | // -----------------------------------------------------------------------
|
---|
147 | /** @name Constructors and Destructor */
|
---|
148 | //@{
|
---|
149 |
|
---|
150 | ListDatatypeValidator
|
---|
151 | (
|
---|
152 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
153 | );
|
---|
154 | ListDatatypeValidator
|
---|
155 | (
|
---|
156 | DatatypeValidator* const baseValidator
|
---|
157 | , RefHashTableOf<KVStringPair>* const facets
|
---|
158 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
159 | , const int finalSet
|
---|
160 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
161 | );
|
---|
162 | virtual ~ListDatatypeValidator();
|
---|
163 |
|
---|
164 | //@}
|
---|
165 |
|
---|
166 | /** @name Getter Functions */
|
---|
167 | //@{
|
---|
168 | /**
|
---|
169 | * Returns whether the type is atomic or not
|
---|
170 | */
|
---|
171 | virtual bool isAtomic() const;
|
---|
172 |
|
---|
173 | virtual const XMLCh* getCanonicalRepresentation
|
---|
174 | (
|
---|
175 | const XMLCh* const rawData
|
---|
176 | , MemoryManager* const memMgr = 0
|
---|
177 | , bool toValidate = false
|
---|
178 | ) const;
|
---|
179 |
|
---|
180 | //@}
|
---|
181 |
|
---|
182 | // -----------------------------------------------------------------------
|
---|
183 | // Validation methods
|
---|
184 | // -----------------------------------------------------------------------
|
---|
185 | /** @name Validation Function */
|
---|
186 | //@{
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * validate that a string matches the boolean datatype
|
---|
190 | * @param content A string containing the content to be validated
|
---|
191 | *
|
---|
192 | * @exception throws InvalidDatatypeException if the content is
|
---|
193 | * is not valid.
|
---|
194 | */
|
---|
195 |
|
---|
196 | virtual void validate
|
---|
197 | (
|
---|
198 | const XMLCh* const content
|
---|
199 | , ValidationContext* const context = 0
|
---|
200 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
201 | );
|
---|
202 |
|
---|
203 | //@}
|
---|
204 |
|
---|
205 | // -----------------------------------------------------------------------
|
---|
206 | // Compare methods
|
---|
207 | // -----------------------------------------------------------------------
|
---|
208 | /** @name Compare Function */
|
---|
209 | //@{
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Compare two boolean data types
|
---|
213 | *
|
---|
214 | * @param content1
|
---|
215 | * @param content2
|
---|
216 | * @return
|
---|
217 | */
|
---|
218 | int compare(const XMLCh* const, const XMLCh* const
|
---|
219 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
220 | );
|
---|
221 |
|
---|
222 | //@}
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * Returns an instance of the base datatype validator class
|
---|
226 | * Used by the DatatypeValidatorFactory.
|
---|
227 | */
|
---|
228 | virtual DatatypeValidator* newInstance
|
---|
229 | (
|
---|
230 | RefHashTableOf<KVStringPair>* const facets
|
---|
231 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
232 | , const int finalSet
|
---|
233 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
234 | );
|
---|
235 |
|
---|
236 | DatatypeValidator* getItemTypeDTV() const;
|
---|
237 |
|
---|
238 | /***
|
---|
239 | * Support for Serialization/De-serialization
|
---|
240 | ***/
|
---|
241 | DECL_XSERIALIZABLE(ListDatatypeValidator)
|
---|
242 |
|
---|
243 | protected:
|
---|
244 |
|
---|
245 | //
|
---|
246 | // ctor provided to be used by derived classes: No
|
---|
247 | //
|
---|
248 |
|
---|
249 | virtual void checkValueSpace(const XMLCh* const content
|
---|
250 | , MemoryManager* const manager);
|
---|
251 |
|
---|
252 | virtual int getLength(const XMLCh* const content
|
---|
253 | , MemoryManager* const manager) const;
|
---|
254 |
|
---|
255 | //
|
---|
256 | // Overwrite AbstractStringValidator's
|
---|
257 | //
|
---|
258 | virtual void inspectFacetBase(MemoryManager* const manager);
|
---|
259 |
|
---|
260 | virtual void inheritFacet();
|
---|
261 |
|
---|
262 | virtual void checkContent(const XMLCh* const content
|
---|
263 | , ValidationContext* const context
|
---|
264 | , bool asBase
|
---|
265 | , MemoryManager* const manager);
|
---|
266 |
|
---|
267 | private:
|
---|
268 |
|
---|
269 | void checkContent( BaseRefVectorOf<XMLCh>* tokenVector
|
---|
270 | , const XMLCh* const content
|
---|
271 | , ValidationContext* const context
|
---|
272 | , bool asBase
|
---|
273 | , MemoryManager* const manager
|
---|
274 | );
|
---|
275 |
|
---|
276 | bool valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector
|
---|
277 | , const XMLCh* const enumStr
|
---|
278 | , MemoryManager* const manager) const;
|
---|
279 |
|
---|
280 | // -----------------------------------------------------------------------
|
---|
281 | // Getter methods
|
---|
282 | // -----------------------------------------------------------------------
|
---|
283 |
|
---|
284 | inline const XMLCh* const getContent() const;
|
---|
285 |
|
---|
286 | // -----------------------------------------------------------------------
|
---|
287 | // Setter methods
|
---|
288 | // -----------------------------------------------------------------------
|
---|
289 |
|
---|
290 | inline void setContent(const XMLCh* const content);
|
---|
291 |
|
---|
292 | // -----------------------------------------------------------------------
|
---|
293 | // Unimplemented constructors and operators
|
---|
294 | // -----------------------------------------------------------------------
|
---|
295 | ListDatatypeValidator(const ListDatatypeValidator&);
|
---|
296 | ListDatatypeValidator& operator=(const ListDatatypeValidator&);
|
---|
297 |
|
---|
298 | // -----------------------------------------------------------------------
|
---|
299 | // Private data members
|
---|
300 | //
|
---|
301 | // fContent
|
---|
302 | // temporary var referenceing the content to be validated,
|
---|
303 | // for error reporting purpose.
|
---|
304 | //
|
---|
305 | // -----------------------------------------------------------------------
|
---|
306 | const XMLCh* fContent;
|
---|
307 | };
|
---|
308 |
|
---|
309 | // -----------------------------------------------------------------------
|
---|
310 | // Getter methods
|
---|
311 | // -----------------------------------------------------------------------
|
---|
312 | inline const XMLCh* const ListDatatypeValidator::getContent() const
|
---|
313 | {
|
---|
314 | return fContent;
|
---|
315 | }
|
---|
316 |
|
---|
317 | inline bool ListDatatypeValidator::isAtomic() const
|
---|
318 | {
|
---|
319 | return false;
|
---|
320 | }
|
---|
321 |
|
---|
322 | // -----------------------------------------------------------------------
|
---|
323 | // Setter methods
|
---|
324 | // -----------------------------------------------------------------------
|
---|
325 | inline void ListDatatypeValidator::setContent(const XMLCh* const content)
|
---|
326 | {
|
---|
327 | fContent = content;
|
---|
328 | }
|
---|
329 |
|
---|
330 | XERCES_CPP_NAMESPACE_END
|
---|
331 |
|
---|
332 | #endif
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * End of file ListDatatypeValidator.hpp
|
---|
336 | */
|
---|