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: BooleanDatatypeValidator.hpp,v 1.13 2004/09/08 13:56:52 peiyongz Exp $
|
---|
19 | */
|
---|
20 |
|
---|
21 | #if !defined(BOOLEAN_DATATYPEVALIDATOR_HPP)
|
---|
22 | #define BOOLEAN_DATATYPEVALIDATOR_HPP
|
---|
23 |
|
---|
24 | #include <xercesc/validators/datatype/DatatypeValidator.hpp>
|
---|
25 |
|
---|
26 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
27 |
|
---|
28 | class VALIDATORS_EXPORT BooleanDatatypeValidator : public DatatypeValidator
|
---|
29 | {
|
---|
30 | public:
|
---|
31 |
|
---|
32 | // -----------------------------------------------------------------------
|
---|
33 | // Public ctor/dtor
|
---|
34 | // -----------------------------------------------------------------------
|
---|
35 | /** @name Constructor. */
|
---|
36 | //@{
|
---|
37 |
|
---|
38 | BooleanDatatypeValidator
|
---|
39 | (
|
---|
40 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
41 | );
|
---|
42 | BooleanDatatypeValidator
|
---|
43 | (
|
---|
44 | DatatypeValidator* const baseValidator
|
---|
45 | , RefHashTableOf<KVStringPair>* const facets
|
---|
46 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
47 | , const int finalSet
|
---|
48 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
49 | );
|
---|
50 |
|
---|
51 | virtual ~BooleanDatatypeValidator();
|
---|
52 |
|
---|
53 | //@}
|
---|
54 |
|
---|
55 | virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
|
---|
56 |
|
---|
57 | // -----------------------------------------------------------------------
|
---|
58 | // Getter methods
|
---|
59 | // -----------------------------------------------------------------------
|
---|
60 | /** @name Getter Functions */
|
---|
61 | //@{
|
---|
62 |
|
---|
63 | virtual const XMLCh* getCanonicalRepresentation
|
---|
64 | (
|
---|
65 | const XMLCh* const rawData
|
---|
66 | , MemoryManager* const memMgr = 0
|
---|
67 | , bool toValidate = false
|
---|
68 | ) const;
|
---|
69 | //@}
|
---|
70 |
|
---|
71 | // -----------------------------------------------------------------------
|
---|
72 | // Validation methods
|
---|
73 | // -----------------------------------------------------------------------
|
---|
74 | /** @name Validation Function */
|
---|
75 | //@{
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * validate that a string matches the boolean datatype
|
---|
79 | * @param content A string containing the content to be validated
|
---|
80 | *
|
---|
81 | * @exception throws InvalidDatatypeException if the content is
|
---|
82 | * is not valid.
|
---|
83 | */
|
---|
84 |
|
---|
85 | virtual void validate
|
---|
86 | (
|
---|
87 | const XMLCh* const content
|
---|
88 | , ValidationContext* const context = 0
|
---|
89 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
90 | );
|
---|
91 |
|
---|
92 | //@}
|
---|
93 |
|
---|
94 | // -----------------------------------------------------------------------
|
---|
95 | // Compare methods
|
---|
96 | // -----------------------------------------------------------------------
|
---|
97 | /** @name Compare Function */
|
---|
98 | //@{
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Compare two boolean data types
|
---|
102 | *
|
---|
103 | * @param content1
|
---|
104 | * @param content2
|
---|
105 | * @return
|
---|
106 | */
|
---|
107 | int compare(const XMLCh* const, const XMLCh* const
|
---|
108 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
109 | );
|
---|
110 |
|
---|
111 | //@}
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Returns an instance of the base datatype validator class
|
---|
115 | * Used by the DatatypeValidatorFactory.
|
---|
116 | */
|
---|
117 | DatatypeValidator* newInstance
|
---|
118 | (
|
---|
119 | RefHashTableOf<KVStringPair>* const facets
|
---|
120 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
121 | , const int finalSet
|
---|
122 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
123 | );
|
---|
124 |
|
---|
125 | /***
|
---|
126 | * Support for Serialization/De-serialization
|
---|
127 | ***/
|
---|
128 | DECL_XSERIALIZABLE(BooleanDatatypeValidator)
|
---|
129 |
|
---|
130 | private:
|
---|
131 |
|
---|
132 | virtual void checkContent(const XMLCh* const content
|
---|
133 | , ValidationContext* const context
|
---|
134 | , bool asBase
|
---|
135 | , MemoryManager* const manager);
|
---|
136 |
|
---|
137 | // -----------------------------------------------------------------------
|
---|
138 | // Unimplemented methods.
|
---|
139 | // -----------------------------------------------------------------------
|
---|
140 | BooleanDatatypeValidator(const BooleanDatatypeValidator&);
|
---|
141 | BooleanDatatypeValidator& operator=(const BooleanDatatypeValidator&);
|
---|
142 |
|
---|
143 | };
|
---|
144 |
|
---|
145 | // ---------------------------------------------------------------------------
|
---|
146 | // Constructors and Destructor
|
---|
147 | // ---------------------------------------------------------------------------
|
---|
148 | inline BooleanDatatypeValidator::BooleanDatatypeValidator(MemoryManager* const manager)
|
---|
149 | :DatatypeValidator(0, 0, 0, DatatypeValidator::Boolean, manager)
|
---|
150 | {
|
---|
151 | setFinite(true);
|
---|
152 | }
|
---|
153 |
|
---|
154 | inline BooleanDatatypeValidator::~BooleanDatatypeValidator()
|
---|
155 | {
|
---|
156 | }
|
---|
157 |
|
---|
158 | // -----------------------------------------------------------------------
|
---|
159 | // Getter methods
|
---|
160 | // -----------------------------------------------------------------------
|
---|
161 |
|
---|
162 |
|
---|
163 | // -----------------------------------------------------------------------
|
---|
164 | // Compare methods
|
---|
165 | // -----------------------------------------------------------------------
|
---|
166 |
|
---|
167 | inline DatatypeValidator* BooleanDatatypeValidator::newInstance
|
---|
168 | (
|
---|
169 | RefHashTableOf<KVStringPair>* const facets
|
---|
170 | , RefArrayVectorOf<XMLCh>* const enums
|
---|
171 | , const int finalSet
|
---|
172 | , MemoryManager* const manager
|
---|
173 | )
|
---|
174 | {
|
---|
175 | return (DatatypeValidator*) new (manager) BooleanDatatypeValidator(this, facets, enums, finalSet, manager);
|
---|
176 | }
|
---|
177 |
|
---|
178 | inline void BooleanDatatypeValidator::validate( const XMLCh* const content
|
---|
179 | , ValidationContext* const context
|
---|
180 | , MemoryManager* const manager)
|
---|
181 | {
|
---|
182 | checkContent(content, context, false, manager);
|
---|
183 | }
|
---|
184 |
|
---|
185 | XERCES_CPP_NAMESPACE_END
|
---|
186 |
|
---|
187 | #endif
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * End of file BooleanDatatypeValidator.hpp
|
---|
191 | */
|
---|
192 |
|
---|