[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: BooleanDatatypeValidator.hpp,v 1.12 2004/01/29 11:51:22 cargilld Exp $
|
---|
| 59 | */
|
---|
| 60 |
|
---|
| 61 | #if !defined(BOOLEAN_DATATYPEVALIDATOR_HPP)
|
---|
| 62 | #define BOOLEAN_DATATYPEVALIDATOR_HPP
|
---|
| 63 |
|
---|
| 64 | #include <xercesc/validators/datatype/DatatypeValidator.hpp>
|
---|
| 65 |
|
---|
| 66 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 67 |
|
---|
| 68 | class VALIDATORS_EXPORT BooleanDatatypeValidator : public DatatypeValidator
|
---|
| 69 | {
|
---|
| 70 | public:
|
---|
| 71 |
|
---|
| 72 | // -----------------------------------------------------------------------
|
---|
| 73 | // Public ctor/dtor
|
---|
| 74 | // -----------------------------------------------------------------------
|
---|
| 75 | /** @name Constructor. */
|
---|
| 76 | //@{
|
---|
| 77 |
|
---|
| 78 | BooleanDatatypeValidator
|
---|
| 79 | (
|
---|
| 80 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 81 | );
|
---|
| 82 | BooleanDatatypeValidator
|
---|
| 83 | (
|
---|
| 84 | DatatypeValidator* const baseValidator
|
---|
| 85 | , RefHashTableOf<KVStringPair>* const facets
|
---|
| 86 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
| 87 | , const int finalSet
|
---|
| 88 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 89 | );
|
---|
| 90 |
|
---|
| 91 | virtual ~BooleanDatatypeValidator();
|
---|
| 92 |
|
---|
| 93 | //@}
|
---|
| 94 |
|
---|
| 95 | virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
|
---|
| 96 |
|
---|
| 97 | // -----------------------------------------------------------------------
|
---|
| 98 | // Getter methods
|
---|
| 99 | // -----------------------------------------------------------------------
|
---|
| 100 | /** @name Getter Functions */
|
---|
| 101 | //@{
|
---|
| 102 |
|
---|
| 103 | virtual const XMLCh* getCanonicalRepresentation
|
---|
| 104 | (
|
---|
| 105 | const XMLCh* const rawData
|
---|
| 106 | , MemoryManager* const memMgr = 0
|
---|
| 107 | , bool toValidate = false
|
---|
| 108 | ) const;
|
---|
| 109 | //@}
|
---|
| 110 |
|
---|
| 111 | // -----------------------------------------------------------------------
|
---|
| 112 | // Validation methods
|
---|
| 113 | // -----------------------------------------------------------------------
|
---|
| 114 | /** @name Validation Function */
|
---|
| 115 | //@{
|
---|
| 116 |
|
---|
| 117 | /**
|
---|
| 118 | * validate that a string matches the boolean datatype
|
---|
| 119 | * @param content A string containing the content to be validated
|
---|
| 120 | *
|
---|
| 121 | * @exception throws InvalidDatatypeException if the content is
|
---|
| 122 | * is not valid.
|
---|
| 123 | */
|
---|
| 124 |
|
---|
| 125 | virtual void validate
|
---|
| 126 | (
|
---|
| 127 | const XMLCh* const content
|
---|
| 128 | , ValidationContext* const context = 0
|
---|
| 129 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 130 | );
|
---|
| 131 |
|
---|
| 132 | //@}
|
---|
| 133 |
|
---|
| 134 | // -----------------------------------------------------------------------
|
---|
| 135 | // Compare methods
|
---|
| 136 | // -----------------------------------------------------------------------
|
---|
| 137 | /** @name Compare Function */
|
---|
| 138 | //@{
|
---|
| 139 |
|
---|
| 140 | /**
|
---|
| 141 | * Compare two boolean data types
|
---|
| 142 | *
|
---|
| 143 | * @param content1
|
---|
| 144 | * @param content2
|
---|
| 145 | * @return
|
---|
| 146 | */
|
---|
| 147 | int compare(const XMLCh* const, const XMLCh* const
|
---|
| 148 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 149 | );
|
---|
| 150 |
|
---|
| 151 | //@}
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
| 154 | * Returns an instance of the base datatype validator class
|
---|
| 155 | * Used by the DatatypeValidatorFactory.
|
---|
| 156 | */
|
---|
| 157 | DatatypeValidator* newInstance
|
---|
| 158 | (
|
---|
| 159 | RefHashTableOf<KVStringPair>* const facets
|
---|
| 160 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
| 161 | , const int finalSet
|
---|
| 162 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 163 | );
|
---|
| 164 |
|
---|
| 165 | /***
|
---|
| 166 | * Support for Serialization/De-serialization
|
---|
| 167 | ***/
|
---|
| 168 | DECL_XSERIALIZABLE(BooleanDatatypeValidator)
|
---|
| 169 |
|
---|
| 170 | private:
|
---|
| 171 |
|
---|
| 172 | virtual void checkContent(const XMLCh* const content
|
---|
| 173 | , ValidationContext* const context
|
---|
| 174 | , bool asBase
|
---|
| 175 | , MemoryManager* const manager);
|
---|
| 176 |
|
---|
| 177 | // -----------------------------------------------------------------------
|
---|
| 178 | // Unimplemented methods.
|
---|
| 179 | // -----------------------------------------------------------------------
|
---|
| 180 | BooleanDatatypeValidator(const BooleanDatatypeValidator&);
|
---|
| 181 | BooleanDatatypeValidator& operator=(const BooleanDatatypeValidator&);
|
---|
| 182 |
|
---|
| 183 | };
|
---|
| 184 |
|
---|
| 185 | // ---------------------------------------------------------------------------
|
---|
| 186 | // Constructors and Destructor
|
---|
| 187 | // ---------------------------------------------------------------------------
|
---|
| 188 | inline BooleanDatatypeValidator::BooleanDatatypeValidator(MemoryManager* const manager)
|
---|
| 189 | :DatatypeValidator(0, 0, 0, DatatypeValidator::Boolean, manager)
|
---|
| 190 | {
|
---|
| 191 | setFinite(true);
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | inline BooleanDatatypeValidator::~BooleanDatatypeValidator()
|
---|
| 195 | {
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | // -----------------------------------------------------------------------
|
---|
| 199 | // Getter methods
|
---|
| 200 | // -----------------------------------------------------------------------
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | // -----------------------------------------------------------------------
|
---|
| 204 | // Compare methods
|
---|
| 205 | // -----------------------------------------------------------------------
|
---|
| 206 |
|
---|
| 207 | inline DatatypeValidator* BooleanDatatypeValidator::newInstance
|
---|
| 208 | (
|
---|
| 209 | RefHashTableOf<KVStringPair>* const facets
|
---|
| 210 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
| 211 | , const int finalSet
|
---|
| 212 | , MemoryManager* const manager
|
---|
| 213 | )
|
---|
| 214 | {
|
---|
| 215 | return (DatatypeValidator*) new (manager) BooleanDatatypeValidator(this, facets, enums, finalSet, manager);
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | inline void BooleanDatatypeValidator::validate( const XMLCh* const content
|
---|
| 219 | , ValidationContext* const context
|
---|
| 220 | , MemoryManager* const manager)
|
---|
| 221 | {
|
---|
| 222 | checkContent(content, context, false, manager);
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | XERCES_CPP_NAMESPACE_END
|
---|
| 226 |
|
---|
| 227 | #endif
|
---|
| 228 |
|
---|
| 229 | /**
|
---|
| 230 | * End of file BooleanDatatypeValidator.hpp
|
---|
| 231 | */
|
---|
| 232 |
|
---|