source: icXML/icXML-devel/src/xercesc/framework/psvi/XSTypeDefinition.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: 6.3 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: XSTypeDefinition.hpp 527149 2007-04-10 14:56:39Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XSTYPEDEFINITION_HPP)
23#define XERCESC_INCLUDE_GUARD_XSTYPEDEFINITION_HPP
24
25#include <xercesc/framework/psvi/XSObject.hpp>
26
27XERCES_CPP_NAMESPACE_BEGIN
28
29// forward declarations
30class XSNamespaceItem;
31
32/**
33 * This class represents a complexType or simpleType definition.
34 * This is *always* owned by the validator /parser object from which
35 * it is obtained. 
36 *
37 */
38
39class XMLPARSER_EXPORT XSTypeDefinition : public XSObject
40{
41public:
42
43    enum TYPE_CATEGORY {
44        /**
45        * This constant value signifies a complex type.
46        */
47        COMPLEX_TYPE              = 15,
48            /**
49             * This constant value signifies a simple type.
50             */
51            SIMPLE_TYPE               = 16
52    };
53
54    //  Constructors and Destructor
55    // -----------------------------------------------------------------------
56    /** @name Constructors */
57    //@{
58
59    /**
60      * The default constructor
61      *
62      * @param  typeCategory
63      * @param  xsBaseType
64      * @param  xsModel
65      * @param  manager     The configurable memory manager
66      */
67    XSTypeDefinition
68    (
69        TYPE_CATEGORY             typeCategory
70        , XSTypeDefinition* const xsBaseType
71        , XSModel* const          xsModel
72        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
73    );
74
75    //@};
76
77    /** @name Destructor */
78    //@{
79    virtual ~XSTypeDefinition();
80    //@}
81
82    //---------------------
83    /** @name overloaded XSObject methods */
84    //@{
85
86    /**
87     * The name of type <code>NCName</code> of this declaration as defined in
88     * XML Namespaces.
89     */
90    virtual const XMLCh* getName() const = 0;
91
92    /**
93     *  The [target namespace] of this object, or <code>null</code> if it is
94     * unspecified.
95     */
96    virtual const XMLCh* getNamespace() = 0;
97
98    /**
99     * A namespace schema information item corresponding to the target
100     * namespace of the component, if it's globally declared; or null
101     * otherwise.
102     */
103    virtual XSNamespaceItem *getNamespaceItem() = 0;
104
105    //@}
106
107    //---------------------
108    /** @name XSTypeDefinition methods */
109
110    //@{
111
112    /**
113     * Return whether this type definition is a simple type or complex type.
114     */
115    TYPE_CATEGORY getTypeCategory() const;
116
117    /**
118     * {base type definition}: either a simple type definition or a complex
119     * type definition.
120     */
121    virtual XSTypeDefinition *getBaseType() = 0;
122
123    /**
124     * {final}. For complex type definition it is a subset of {extension,
125     * restriction}. For simple type definition it is a subset of
126     * {extension, list, restriction, union}.
127     * @param toTest       Extension, restriction, list, union constants
128     *   (defined in <code>XSObject</code>).
129     * @return True if toTest is in the final set, otherwise false.
130     */
131    bool isFinal(short toTest);
132
133    /**
134     * For complex types the returned value is a bit combination of the subset
135     * of {<code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>}
136     * corresponding to <code>final</code> set of this type or
137     * <code>DERIVATION_NONE</code>. For simple types the returned value is
138     * a bit combination of the subset of {
139     * <code>DERIVATION_RESTRICTION, DERIVATION_EXTENSION, DERIVATION_UNION, DERIVATION_LIST</code>
140     * } corresponding to <code>final</code> set of this type or
141     * <code>DERIVATION_NONE</code>.
142     */
143    short getFinal() const;
144
145    /**
146     *  A boolean that specifies if the type definition is
147     * anonymous. Convenience attribute.
148     */
149    virtual bool getAnonymous() const = 0;
150
151    /**
152     * Convenience method: check if this type is derived from the given
153     * <code>ancestorType</code>.
154     * @param ancestorType  An ancestor type definition.
155     * @return  Return true if this type is derived from
156     *   <code>ancestorType</code>.
157     */
158    virtual bool derivedFromType(const XSTypeDefinition* const ancestorType) = 0;
159
160    /**
161     * Convenience method: check if this type is derived from the given
162     * ancestor type.
163     * @param typeNamespace  An ancestor type namespace.
164     * @param name  An ancestor type name.
165     * @return  Return true if this type is derived from
166     *   the ancestor defined by <code>typeNamespace</code> and <code>name</code>.
167     */
168    bool derivedFrom(const XMLCh* typeNamespace, 
169                               const XMLCh* name);
170
171    //@}
172
173    //----------------------------------
174    /** methods needed by implementation */
175
176    //@{
177
178    //@}
179private:
180
181    // -----------------------------------------------------------------------
182    //  Unimplemented constructors and operators
183    // -----------------------------------------------------------------------
184    XSTypeDefinition(const XSTypeDefinition&);
185    XSTypeDefinition & operator=(const XSTypeDefinition &);
186
187protected:
188
189    // -----------------------------------------------------------------------
190    //  data members
191    // -----------------------------------------------------------------------
192    // fTypeCategory
193    //  whether this is a simpleType or complexType
194    // fFinal
195    //  the final properties which is set by the derived class.
196    TYPE_CATEGORY     fTypeCategory;
197    short             fFinal;
198    XSTypeDefinition* fBaseType; // owned by XSModel
199};
200
201inline XSTypeDefinition::TYPE_CATEGORY XSTypeDefinition::getTypeCategory() const
202{
203    return fTypeCategory;
204}
205
206inline short XSTypeDefinition::getFinal() const
207{
208    return fFinal;
209}
210
211
212XERCES_CPP_NAMESPACE_END
213
214#endif
Note: See TracBrowser for help on using the repository browser.