[188] | 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: AbstractStringValidator.hpp,v 1.13 2004/01/29 11:51:22 cargilld Exp $
|
---|
| 59 | * $Log: AbstractStringValidator.hpp,v $
|
---|
| 60 | * Revision 1.13 2004/01/29 11:51:22 cargilld
|
---|
| 61 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
| 62 | *
|
---|
| 63 | * Revision 1.12 2003/12/31 10:38:00 amassari
|
---|
| 64 | * Made virtual function checkAdditionalFacet 'const', so that it matches the declaration in a derived class
|
---|
| 65 | *
|
---|
| 66 | * Revision 1.11 2003/12/17 00:18:38 cargilld
|
---|
| 67 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
| 68 | *
|
---|
| 69 | * Revision 1.10 2003/11/12 20:32:03 peiyongz
|
---|
| 70 | * Statless Grammar: ValidationContext
|
---|
| 71 | *
|
---|
| 72 | * Revision 1.9 2003/09/29 21:47:35 peiyongz
|
---|
| 73 | * Implementation of Serialization/Deserialization
|
---|
| 74 | *
|
---|
| 75 | * Revision 1.8 2003/05/15 18:53:26 knoaman
|
---|
| 76 | * Partial implementation of the configurable memory manager.
|
---|
| 77 | *
|
---|
| 78 | * Revision 1.7 2003/01/27 19:24:17 peiyongz
|
---|
| 79 | * normalize Base64 data before checking against enumeration.
|
---|
| 80 | *
|
---|
| 81 | * Revision 1.6 2003/01/24 23:18:34 peiyongz
|
---|
| 82 | * normalizeEnumeration() added to remove optional ws in Base64 data.
|
---|
| 83 | *
|
---|
| 84 | * Revision 1.5 2002/12/18 14:17:55 gareth
|
---|
| 85 | * Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
|
---|
| 86 | *
|
---|
| 87 | * Revision 1.4 2002/11/04 14:53:27 tng
|
---|
| 88 | * C++ Namespace Support.
|
---|
| 89 | *
|
---|
| 90 | * Revision 1.3 2002/10/18 16:52:14 peiyongz
|
---|
| 91 | * Patch to Bug#13640: Getter methods not public in
|
---|
| 92 | * DecimalDatatypeValidator
|
---|
| 93 | *
|
---|
| 94 | * Revision 1.2 2002/02/14 15:17:31 peiyongz
|
---|
| 95 | * getEnumString()
|
---|
| 96 | *
|
---|
| 97 | * Revision 1.1.1.1 2002/02/01 22:22:40 peiyongz
|
---|
| 98 | * sane_include
|
---|
| 99 | *
|
---|
| 100 | * Revision 1.9 2001/12/13 16:48:29 peiyongz
|
---|
| 101 | * Avoid dangling pointer
|
---|
| 102 | *
|
---|
| 103 | * Revision 1.8 2001/11/22 20:23:20 peiyongz
|
---|
| 104 | * _declspec(dllimport) and inline warning C4273
|
---|
| 105 | *
|
---|
| 106 | * Revision 1.7 2001/11/15 16:08:15 peiyongz
|
---|
| 107 | * checkContent() made virtual to allow ListDTV participate in the building of
|
---|
| 108 | * its own (in AbstractStringValidator's init())
|
---|
| 109 | *
|
---|
| 110 | * Revision 1.6 2001/10/11 19:32:12 peiyongz
|
---|
| 111 | * Allow derived to overwrite inheritFacet()
|
---|
| 112 | *
|
---|
| 113 | * Revision 1.5 2001/10/09 21:00:54 peiyongz
|
---|
| 114 | * . init() take 1 arg,
|
---|
| 115 | * . make inspectFacetBase() virtual to allow ListDTV provide its own method,
|
---|
| 116 | * . reorganize init() into assignFacet(), inspectFacet(), inspectFacetBase() and
|
---|
| 117 | * inheritFacet() to improve mantainability.
|
---|
| 118 | * . macro to simplify code
|
---|
| 119 | * . save get***() to temp vars
|
---|
| 120 | *
|
---|
| 121 | * Revision 1.4 2001/09/27 13:51:25 peiyongz
|
---|
| 122 | * DTV Reorganization: ctor/init created to be used by derived class
|
---|
| 123 | *
|
---|
| 124 | * Revision 1.3 2001/09/24 15:30:16 peiyongz
|
---|
| 125 | * DTV Reorganization: init() to be invoked from derived class' ctor to allow
|
---|
| 126 | * correct resolution of virtual methods like assignAdditionalFacet(),
|
---|
| 127 | * inheritAdditionalFacet(), etc.
|
---|
| 128 | *
|
---|
| 129 | * Revision 1.2 2001/09/19 18:48:27 peiyongz
|
---|
| 130 | * DTV reorganization:getLength() added, move inline to class declaration to avoid inline
|
---|
| 131 | * function interdependency.
|
---|
| 132 | *
|
---|
| 133 | * Revision 1.1 2001/09/18 14:45:04 peiyongz
|
---|
| 134 | * DTV reorganization
|
---|
| 135 | *
|
---|
| 136 | */
|
---|
| 137 |
|
---|
| 138 | #if !defined(ABSTRACT_STRING_VALIDATOR_HPP)
|
---|
| 139 | #define ABSTRACT_STRING_VALIDATOR_HPP
|
---|
| 140 |
|
---|
| 141 | #include <xercesc/validators/datatype/DatatypeValidator.hpp>
|
---|
| 142 |
|
---|
| 143 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 144 |
|
---|
| 145 | class VALIDATORS_EXPORT AbstractStringValidator : public DatatypeValidator
|
---|
| 146 | {
|
---|
| 147 | public:
|
---|
| 148 |
|
---|
| 149 | // -----------------------------------------------------------------------
|
---|
| 150 | // Public ctor/dtor
|
---|
| 151 | // -----------------------------------------------------------------------
|
---|
| 152 | /** @name Constructor. */
|
---|
| 153 | //@{
|
---|
| 154 |
|
---|
| 155 | virtual ~AbstractStringValidator();
|
---|
| 156 |
|
---|
| 157 | //@}
|
---|
| 158 |
|
---|
| 159 | virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
|
---|
| 160 |
|
---|
| 161 | // -----------------------------------------------------------------------
|
---|
| 162 | // Validation methods
|
---|
| 163 | // -----------------------------------------------------------------------
|
---|
| 164 | /** @name Validation Function */
|
---|
| 165 | //@{
|
---|
| 166 |
|
---|
| 167 | /**
|
---|
| 168 | * validate that a string matches the boolean datatype
|
---|
| 169 | * @param content A string containing the content to be validated
|
---|
| 170 | *
|
---|
| 171 | * @exception throws InvalidDatatypeException if the content is
|
---|
| 172 | * is not valid.
|
---|
| 173 | */
|
---|
| 174 |
|
---|
| 175 | virtual void validate
|
---|
| 176 | (
|
---|
| 177 | const XMLCh* const content
|
---|
| 178 | , ValidationContext* const context = 0
|
---|
| 179 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 180 | );
|
---|
| 181 |
|
---|
| 182 | //@}
|
---|
| 183 |
|
---|
| 184 | // -----------------------------------------------------------------------
|
---|
| 185 | // Compare methods
|
---|
| 186 | // -----------------------------------------------------------------------
|
---|
| 187 | /** @name Compare Function */
|
---|
| 188 | //@{
|
---|
| 189 |
|
---|
| 190 | virtual int compare(const XMLCh* const, const XMLCh* const
|
---|
| 191 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 192 | );
|
---|
| 193 |
|
---|
| 194 | //@}
|
---|
| 195 |
|
---|
| 196 | /***
|
---|
| 197 | * Support for Serialization/De-serialization
|
---|
| 198 | ***/
|
---|
| 199 | DECL_XSERIALIZABLE(AbstractStringValidator)
|
---|
| 200 |
|
---|
| 201 | protected:
|
---|
| 202 |
|
---|
| 203 | AbstractStringValidator
|
---|
| 204 | (
|
---|
| 205 | DatatypeValidator* const baseValidator
|
---|
| 206 | , RefHashTableOf<KVStringPair>* const facets
|
---|
| 207 | , const int finalSet
|
---|
| 208 | , const ValidatorType type
|
---|
| 209 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 210 | );
|
---|
| 211 |
|
---|
| 212 | void init(RefArrayVectorOf<XMLCh>* const enums
|
---|
| 213 | , MemoryManager* const manager);
|
---|
| 214 |
|
---|
| 215 | //
|
---|
| 216 | // Abstract interface
|
---|
| 217 | //
|
---|
| 218 | virtual void assignAdditionalFacet(const XMLCh* const key
|
---|
| 219 | , const XMLCh* const value
|
---|
| 220 | , MemoryManager* const manager);
|
---|
| 221 |
|
---|
| 222 | virtual void inheritAdditionalFacet();
|
---|
| 223 |
|
---|
| 224 | virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const;
|
---|
| 225 |
|
---|
| 226 | virtual void checkAdditionalFacet(const XMLCh* const content
|
---|
| 227 | , MemoryManager* const manager) const;
|
---|
| 228 |
|
---|
| 229 | virtual int getLength(const XMLCh* const content
|
---|
| 230 | , MemoryManager* const manager) const;
|
---|
| 231 |
|
---|
| 232 | virtual void checkValueSpace(const XMLCh* const content
|
---|
| 233 | , MemoryManager* const manager) = 0;
|
---|
| 234 |
|
---|
| 235 | //
|
---|
| 236 | // to Allow ListDTV to overwrite
|
---|
| 237 | //
|
---|
| 238 | virtual void inspectFacetBase(MemoryManager* const manager);
|
---|
| 239 |
|
---|
| 240 | virtual void inheritFacet();
|
---|
| 241 |
|
---|
| 242 | virtual void checkContent(const XMLCh* const content
|
---|
| 243 | , ValidationContext* const context
|
---|
| 244 | , bool asBase
|
---|
| 245 | , MemoryManager* const manager);
|
---|
| 246 |
|
---|
| 247 | /*
|
---|
| 248 | ** Base64BinaryDatatypeValidator to overwrite
|
---|
| 249 | */
|
---|
| 250 | virtual void normalizeEnumeration(MemoryManager* const manager);
|
---|
| 251 |
|
---|
| 252 | virtual void normalizeContent(XMLCh* const, MemoryManager* const manager) const;
|
---|
| 253 |
|
---|
| 254 | public:
|
---|
| 255 | // -----------------------------------------------------------------------
|
---|
| 256 | // Getter methods
|
---|
| 257 | // -----------------------------------------------------------------------
|
---|
| 258 |
|
---|
| 259 | inline unsigned int getLength() const;
|
---|
| 260 |
|
---|
| 261 | inline unsigned int getMaxLength() const;
|
---|
| 262 |
|
---|
| 263 | inline unsigned int getMinLength() const;
|
---|
| 264 |
|
---|
| 265 | inline RefArrayVectorOf<XMLCh>* getEnumeration() const;
|
---|
| 266 |
|
---|
| 267 | protected:
|
---|
| 268 | // -----------------------------------------------------------------------
|
---|
| 269 | // Setter methods
|
---|
| 270 | // -----------------------------------------------------------------------
|
---|
| 271 |
|
---|
| 272 | inline void setLength(unsigned int);
|
---|
| 273 |
|
---|
| 274 | inline void setMaxLength(unsigned int);
|
---|
| 275 |
|
---|
| 276 | inline void setMinLength(unsigned int);
|
---|
| 277 |
|
---|
| 278 | inline void setEnumeration(RefArrayVectorOf<XMLCh>*, bool);
|
---|
| 279 |
|
---|
| 280 | private:
|
---|
| 281 |
|
---|
| 282 | void assignFacet(MemoryManager* const manager);
|
---|
| 283 |
|
---|
| 284 | void inspectFacet(MemoryManager* const manager);
|
---|
| 285 |
|
---|
| 286 | // -----------------------------------------------------------------------
|
---|
| 287 | // Unimplemented constructors and operators
|
---|
| 288 | // -----------------------------------------------------------------------
|
---|
| 289 | AbstractStringValidator(const AbstractStringValidator&);
|
---|
| 290 | AbstractStringValidator& operator=(const AbstractStringValidator&);
|
---|
| 291 |
|
---|
| 292 | // -----------------------------------------------------------------------
|
---|
| 293 | // Private data members
|
---|
| 294 | //
|
---|
| 295 | // -----------------------------------------------------------------------
|
---|
| 296 | unsigned int fLength;
|
---|
| 297 | unsigned int fMaxLength;
|
---|
| 298 | unsigned int fMinLength;
|
---|
| 299 | bool fEnumerationInherited;
|
---|
| 300 | RefArrayVectorOf<XMLCh>* fEnumeration;
|
---|
| 301 | };
|
---|
| 302 |
|
---|
| 303 | // -----------------------------------------------------------------------
|
---|
| 304 | // Getter methods
|
---|
| 305 | // -----------------------------------------------------------------------
|
---|
| 306 |
|
---|
| 307 | inline unsigned int AbstractStringValidator::getLength() const
|
---|
| 308 | {
|
---|
| 309 | return fLength;
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | inline unsigned int AbstractStringValidator::getMaxLength() const
|
---|
| 313 | {
|
---|
| 314 | return fMaxLength;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | inline unsigned int AbstractStringValidator::getMinLength() const
|
---|
| 318 | {
|
---|
| 319 | return fMinLength;
|
---|
| 320 | }
|
---|
| 321 |
|
---|
| 322 | inline RefArrayVectorOf<XMLCh>* AbstractStringValidator:: getEnumeration() const
|
---|
| 323 | {
|
---|
| 324 | return fEnumeration;
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 | // -----------------------------------------------------------------------
|
---|
| 328 | // Setter methods
|
---|
| 329 | // -----------------------------------------------------------------------
|
---|
| 330 |
|
---|
| 331 | inline void AbstractStringValidator::setLength(unsigned int newLength)
|
---|
| 332 | {
|
---|
| 333 | fLength = newLength;
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | inline void AbstractStringValidator::setMaxLength(unsigned int newMaxLength)
|
---|
| 337 | {
|
---|
| 338 | fMaxLength = newMaxLength;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 | inline void AbstractStringValidator::setMinLength(unsigned int newMinLength)
|
---|
| 342 | {
|
---|
| 343 | fMinLength = newMinLength;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | inline void AbstractStringValidator::setEnumeration(RefArrayVectorOf<XMLCh>* enums
|
---|
| 347 | , bool inherited)
|
---|
| 348 | {
|
---|
| 349 | if (enums)
|
---|
| 350 | {
|
---|
| 351 | if ( !fEnumerationInherited && fEnumeration)
|
---|
| 352 | delete fEnumeration;
|
---|
| 353 |
|
---|
| 354 | fEnumeration = enums;
|
---|
| 355 | fEnumerationInherited = inherited;
|
---|
| 356 | setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
|
---|
| 357 | }
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 | XERCES_CPP_NAMESPACE_END
|
---|
| 361 |
|
---|
| 362 | #endif
|
---|
| 363 |
|
---|
| 364 | /**
|
---|
| 365 | * End of file AbstractStringValidator.hpp
|
---|
| 366 | */
|
---|