source: icXML/icXML-devel/src/xercesc/validators/schema/SchemaAttDef.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 8.2 KB
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: SchemaAttDef.hpp 676911 2008-07-15 13:27:32Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAATTDEF_HPP)
23#define XERCESC_INCLUDE_GUARD_SCHEMAATTDEF_HPP
24
25#include <icxercesc/util/XMLString.hpp>
26#include <icxercesc/framework/XMLAttDef.hpp>
27#include <xercesc/util/ValueVectorOf.hpp>
28#include <xercesc/validators/datatype/DatatypeValidator.hpp>
29#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
30#include <xercesc/validators/schema/PSVIDefs.hpp>
31
32XERCES_CPP_NAMESPACE_BEGIN
33
34class DatatypeValidator;
35class QName;
36class ComplexTypeInfo;
37//
38//  This class is a derivative of the core XMLAttDef class. This class adds
39//  any Schema specific data members and provides Schema specific implementations
40//  of any underlying attribute def virtual methods.
41//
42class VALIDATORS_EXPORT SchemaAttDef : public XMLAttDef
43{
44public :
45    // -----------------------------------------------------------------------
46    //  Constructors and Destructors
47    // -----------------------------------------------------------------------
48    SchemaAttDef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
49    SchemaAttDef
50    (
51          const XMLCh* const           prefix
52        , const XMLCh* const           localPart
53        , const int                    uriId
54        , const XMLAttDef::AttTypes    type = CData
55        , const XMLAttDef::DefAttTypes defType = Implied
56        , MemoryManager* const         manager = XMLPlatformUtils::fgMemoryManager
57    );
58    SchemaAttDef
59    (
60          const XMLCh* const           prefix
61        , const XMLCh* const           localPart
62        , const int                    uriId
63        , const XMLCh* const           attValue
64        , const XMLAttDef::AttTypes    type
65        , const XMLAttDef::DefAttTypes defType
66        , const XMLCh* const           enumValues = 0
67        , MemoryManager* const         manager = XMLPlatformUtils::fgMemoryManager
68    );
69    SchemaAttDef
70    (
71          const SchemaAttDef*                   other
72    );
73    virtual ~SchemaAttDef();
74
75    // -----------------------------------------------------------------------
76    //  Implementation of the XMLAttDef interface
77    // -----------------------------------------------------------------------
78    virtual const XMLCh* getFullName() const;
79    virtual void reset();
80
81    // -----------------------------------------------------------------------
82    //  Getter methods
83    // -----------------------------------------------------------------------
84    XMLSize_t getElemId() const;
85    QName* getAttName() const;
86    DatatypeValidator* getDatatypeValidator() const;
87    ValueVectorOf<unsigned int>* getNamespaceList() const;
88    const SchemaAttDef* getBaseAttDecl() const;
89    SchemaAttDef* getBaseAttDecl();
90    PSVIDefs::PSVIScope getPSVIScope() const;
91
92    // -----------------------------------------------------------------------
93    //  Setter methods
94    // -----------------------------------------------------------------------
95    void setElemId(const XMLSize_t newId);
96    void setAttName
97    (
98        const XMLCh* const        prefix
99       ,const XMLCh* const        localPart
100       ,const int                 uriId = -1
101    );
102    void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);   
103    void setBaseAttDecl(SchemaAttDef* const attDef);
104    void setPSVIScope(const PSVIDefs::PSVIScope toSet);
105   
106    void setNamespaceList(const ValueVectorOf<unsigned int>* const toSet);
107    void resetNamespaceList();
108    void setEnclosingCT(ComplexTypeInfo* complexTypeInfo);
109    /***
110     * Support for Serialization/De-serialization
111     ***/
112    DECL_XSERIALIZABLE(SchemaAttDef)
113
114private :
115    // -----------------------------------------------------------------------
116    //  Unimplemented constructors and operators
117    // -----------------------------------------------------------------------
118    SchemaAttDef(const SchemaAttDef&);
119    SchemaAttDef& operator=(const SchemaAttDef&);
120
121    // -----------------------------------------------------------------------
122    //  Private data members
123    //
124    //  fElemId
125    //      This is the id of the element (the id is into the element decl
126    //      pool) of the element this attribute def said it belonged to.
127    //      This is used later to link back to the element, mostly for
128    //      validation purposes.
129    //
130    //  fAttName
131    //      This is the name of the attribute.
132    //
133    //  fDatatypeValidator
134    //      The DatatypeValidator used to validate this attribute type.       
135    //   
136    //  fNamespaceList
137    //      The list of namespace values for a wildcard attribute
138    //   
139    //  fBaseAttDecl
140    //      The base attribute declaration that this attribute is based on
141    //      NOTE: we do not have a notion of attribute use, so in the case
142    //      of ref'd attributes and inherited attributes, we make a copy
143    //      of the actual attribute declaration. The fBaseAttDecl stores that
144    //      declaration, and will be helpful when we build the XSModel (i.e
145    //      easy access the XSAnnotation object).
146    // -----------------------------------------------------------------------
147    XMLSize_t                    fElemId;
148
149    PSVIDefs::PSVIScope          fPSVIScope;
150
151    QName*                       fAttName;
152    DatatypeValidator*           fDatatypeValidator;   
153    ValueVectorOf<unsigned int>* fNamespaceList;
154    SchemaAttDef*                fBaseAttDecl;
155};
156
157
158// ---------------------------------------------------------------------------
159//  SchemaAttDef: Getter methods
160// ---------------------------------------------------------------------------
161inline XMLSize_t SchemaAttDef::getElemId() const
162{
163    return fElemId;
164}
165
166
167inline QName* SchemaAttDef::getAttName() const
168{
169    return fAttName;
170}
171
172inline DatatypeValidator* SchemaAttDef::getDatatypeValidator() const
173{
174    return fDatatypeValidator;
175}
176
177inline ValueVectorOf<unsigned int>*
178SchemaAttDef::getNamespaceList() const {
179    return fNamespaceList;
180}
181
182inline SchemaAttDef* SchemaAttDef::getBaseAttDecl()
183{
184    return fBaseAttDecl;
185}
186
187inline const SchemaAttDef* SchemaAttDef::getBaseAttDecl() const
188{
189    return fBaseAttDecl;
190}
191
192inline PSVIDefs::PSVIScope SchemaAttDef::getPSVIScope() const
193{
194    return fPSVIScope;
195}
196
197// ---------------------------------------------------------------------------
198//  SchemaAttDef: Setter methods
199// ---------------------------------------------------------------------------
200inline void SchemaAttDef::setElemId(const XMLSize_t newId)
201{
202    fElemId = newId;
203}
204
205inline void SchemaAttDef::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
206{
207    fDatatypeValidator = newDatatypeValidator;
208}
209
210inline void SchemaAttDef::resetNamespaceList() {
211
212    if (fNamespaceList && fNamespaceList->size()) {
213        fNamespaceList->removeAllElements();
214    }
215}
216
217inline void SchemaAttDef::setNamespaceList(const ValueVectorOf<unsigned int>* const toSet) {
218
219    if (toSet && toSet->size()) {
220
221        if (fNamespaceList) {
222            *fNamespaceList = *toSet;
223        }
224        else {
225            fNamespaceList = new (getMemoryManager()) ValueVectorOf<unsigned int>(*toSet);
226        }
227    }
228    else  {
229        resetNamespaceList();
230    }
231}
232
233inline void SchemaAttDef::reset() {   
234}
235
236inline void SchemaAttDef::setEnclosingCT(ComplexTypeInfo*)
237{
238}
239
240inline void SchemaAttDef::setBaseAttDecl(SchemaAttDef* const attDef)
241{
242    fBaseAttDecl = attDef;
243}
244
245inline void SchemaAttDef::setPSVIScope(const PSVIDefs::PSVIScope toSet)
246{
247    fPSVIScope = toSet;
248}
249
250XERCES_CPP_NAMESPACE_END
251
252#endif
Note: See TracBrowser for help on using the repository browser.