source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/validators/datatype/ListDatatypeValidator.hpp @ 2674

Revision 2674, 7.1 KB checked in by mattausch, 16 years ago (diff)
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: ListDatatypeValidator.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22#if !defined(LIST_DATATYPEVALIDATOR_HPP)
23#define LIST_DATATYPEVALIDATOR_HPP
24
25#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
26#include <xercesc/validators/schema/SchemaSymbols.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class VALIDATORS_EXPORT ListDatatypeValidator : public AbstractStringValidator
31{
32public:
33
34    // -----------------------------------------------------------------------
35    //  Public ctor/dtor
36    // -----------------------------------------------------------------------
37        /** @name Constructors and Destructor */
38    //@{
39
40    ListDatatypeValidator
41    (
42        MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
43    );
44    ListDatatypeValidator
45    (
46        DatatypeValidator* const baseValidator
47        , RefHashTableOf<KVStringPair>* const facets
48        , RefArrayVectorOf<XMLCh>* const enums
49        , const int finalSet
50        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
51    );
52    virtual ~ListDatatypeValidator();
53
54        //@}
55
56    /** @name Getter Functions */
57    //@{
58    /**
59      * Returns whether the type is atomic or not
60      */
61    virtual bool isAtomic() const;
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    // -----------------------------------------------------------------------
73    // Validation methods
74    // -----------------------------------------------------------------------
75    /** @name Validation Function */
76    //@{
77
78    /**
79     * validate that a string matches the boolean datatype
80     * @param content A string containing the content to be validated
81     *
82     * @exception throws InvalidDatatypeException if the content is
83     * is not valid.
84     */
85
86        virtual void validate
87                 (
88                  const XMLCh*             const content
89                ,       ValidationContext* const context = 0
90                ,       MemoryManager*     const manager = XMLPlatformUtils::fgMemoryManager
91                  );
92
93    //@}
94
95    // -----------------------------------------------------------------------
96    // Compare methods
97    // -----------------------------------------------------------------------
98    /** @name Compare Function */
99    //@{
100
101    /**
102     * Compare two boolean data types
103     *
104     * @param content1
105     * @param content2
106     * @return
107     */
108    int compare(const XMLCh* const, const XMLCh* const
109        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
110        );
111
112    //@}
113
114    /**
115      * Returns an instance of the base datatype validator class
116          * Used by the DatatypeValidatorFactory.
117      */
118    virtual DatatypeValidator* newInstance
119    (
120        RefHashTableOf<KVStringPair>* const facets
121        , RefArrayVectorOf<XMLCh>* const enums
122        , const int finalSet
123        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
124    );
125
126    DatatypeValidator* getItemTypeDTV() const;
127
128    /***
129     * Support for Serialization/De-serialization
130     ***/
131    DECL_XSERIALIZABLE(ListDatatypeValidator)
132
133protected:
134
135    //
136    // ctor provided to be used by derived classes: No
137    //
138
139    virtual void checkValueSpace(const XMLCh* const content
140                                , MemoryManager* const manager);
141
142    virtual int  getLength(const XMLCh* const content
143            , MemoryManager* const manager) const;
144
145    //
146    // Overwrite AbstractStringValidator's
147    //
148    virtual void inspectFacetBase(MemoryManager* const manager);
149
150    virtual void inheritFacet();
151
152    virtual void checkContent(const XMLCh*             const content
153                            ,       ValidationContext* const context
154                            , bool                           asBase
155                            ,       MemoryManager*     const manager);
156
157private:
158
159    void checkContent(      BaseRefVectorOf<XMLCh>*        tokenVector
160                    , const XMLCh*                  const  content
161                    ,       ValidationContext*      const  context
162                    ,       bool                           asBase
163                    ,       MemoryManager*          const  manager
164                    );
165
166    bool valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector
167                       , const XMLCh*   const enumStr
168                       , MemoryManager* const manager) const;
169
170// -----------------------------------------------------------------------
171// Getter methods
172// -----------------------------------------------------------------------
173
174    inline const XMLCh* const   getContent() const;
175
176// -----------------------------------------------------------------------
177// Setter methods
178// -----------------------------------------------------------------------
179
180    inline void                 setContent(const XMLCh* const content);
181
182    // -----------------------------------------------------------------------
183    //  Unimplemented constructors and operators
184    // -----------------------------------------------------------------------
185    ListDatatypeValidator(const ListDatatypeValidator&);
186    ListDatatypeValidator& operator=(const ListDatatypeValidator&);
187
188    // -----------------------------------------------------------------------
189    //  Private data members
190    //
191    //  fContent
192    //      temporary var referenceing the content to be validated,
193    //      for error reporting purpose.
194    //
195    // -----------------------------------------------------------------------
196     const XMLCh*         fContent;
197};
198
199// -----------------------------------------------------------------------
200// Getter methods
201// -----------------------------------------------------------------------
202inline const XMLCh* const ListDatatypeValidator::getContent() const
203{
204    return fContent;
205}
206
207inline bool ListDatatypeValidator::isAtomic() const
208{
209    return false;
210}
211
212// -----------------------------------------------------------------------
213// Setter methods
214// -----------------------------------------------------------------------
215inline void ListDatatypeValidator::setContent(const XMLCh* const content)
216{
217    fContent = content;
218}
219
220XERCES_CPP_NAMESPACE_END
221
222#endif
223
224/**
225  * End of file ListDatatypeValidator.hpp
226  */
Note: See TracBrowser for help on using the repository browser.