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