source: obsolete/tags/VUT/0.4/GtpVisibilityPreprocessor/support/xerces/include/xercesc/framework/psvi/XSTypeDefinition.hpp @ 358

Revision 358, 7.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,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 * $Log: XSTypeDefinition.hpp,v $
19 * Revision 1.9  2004/09/08 13:56:09  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.8  2003/12/01 23:23:26  neilg
23 * fix for bug 25118; thanks to Jeroen Witmond
24 *
25 * Revision 1.7  2003/11/25 18:08:31  knoaman
26 * Misc. PSVI updates. Thanks to David Cargill.
27 *
28 * Revision 1.6  2003/11/21 17:34:04  knoaman
29 * PSVI update
30 *
31 * Revision 1.5  2003/11/15 21:19:01  neilg
32 * fixes for compilation under gcc
33 *
34 * Revision 1.4  2003/11/14 22:47:53  neilg
35 * fix bogus log message from previous commit...
36 *
37 * Revision 1.3  2003/11/14 22:33:30  neilg
38 * Second phase of schema component model implementation. 
39 * Implement XSModel, XSNamespaceItem, and the plumbing necessary
40 * to connect them to the other components.
41 * Thanks to David Cargill.
42 *
43 * Revision 1.2  2003/11/06 15:30:04  neilg
44 * first part of PSVI/schema component model implementation, thanks to David Cargill.  This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
45 *
46 * Revision 1.1  2003/09/16 14:33:36  neilg
47 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
48 *
49 */
50
51#if !defined(XSTYPEDEFINITION_HPP)
52#define XSTYPEDEFINITION_HPP
53
54#include <xercesc/framework/psvi/XSObject.hpp>
55
56XERCES_CPP_NAMESPACE_BEGIN
57
58// forward declarations
59class XSNamespaceItem;
60
61/**
62 * This class represents a complexType or simpleType definition.
63 * This is *always* owned by the validator /parser object from which
64 * it is obtained. 
65 *
66 */
67
68class XMLPARSER_EXPORT XSTypeDefinition : public XSObject
69{
70public:
71
72    enum TYPE_CATEGORY {
73        /**
74        * This constant value signifies a complex type.
75        */
76        COMPLEX_TYPE              = 15,
77            /**
78             * This constant value signifies a simple type.
79             */
80            SIMPLE_TYPE               = 16
81    };
82
83    //  Constructors and Destructor
84    // -----------------------------------------------------------------------
85    /** @name Constructors */
86    //@{
87
88    /**
89      * The default constructor
90      *
91      * @param  typeCategory
92      * @param  xsBaseType
93      * @param  xsModel
94      * @param  manager     The configurable memory manager
95      */
96    XSTypeDefinition
97    (
98        TYPE_CATEGORY             typeCategory
99        , XSTypeDefinition* const xsBaseType
100        , XSModel* const          xsModel
101        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
102    );
103
104    //@};
105
106    /** @name Destructor */
107    //@{
108    virtual ~XSTypeDefinition();
109    //@}
110
111    //---------------------
112    /** @name overloaded XSObject methods */
113    //@{
114
115    /**
116     * The name of type <code>NCName</code> of this declaration as defined in
117     * XML Namespaces.
118     */
119    virtual const XMLCh* getName() = 0;
120
121    /**
122     *  The [target namespace] of this object, or <code>null</code> if it is
123     * unspecified.
124     */
125    virtual const XMLCh* getNamespace() = 0;
126
127    /**
128     * A namespace schema information item corresponding to the target
129     * namespace of the component, if it's globally declared; or null
130     * otherwise.
131     */
132    virtual XSNamespaceItem *getNamespaceItem() = 0;
133
134    //@}
135
136    //---------------------
137    /** @name XSTypeDefinition methods */
138
139    //@{
140
141    /**
142     * Return whether this type definition is a simple type or complex type.
143     */
144    TYPE_CATEGORY getTypeCategory() const;
145
146    /**
147     * {base type definition}: either a simple type definition or a complex
148     * type definition.
149     */
150    virtual XSTypeDefinition *getBaseType() = 0;
151
152    /**
153     * {final}. For complex type definition it is a subset of {extension,
154     * restriction}. For simple type definition it is a subset of
155     * {extension, list, restriction, union}.
156     * @param toTest       Extension, restriction, list, union constants
157     *   (defined in <code>XSObject</code>).
158     * @return True if toTest is in the final set, otherwise false.
159     */
160    bool isFinal(short toTest);
161
162    /**
163     * For complex types the returned value is a bit combination of the subset
164     * of {<code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>}
165     * corresponding to <code>final</code> set of this type or
166     * <code>DERIVATION_NONE</code>. For simple types the returned value is
167     * a bit combination of the subset of {
168     * <code>DERIVATION_RESTRICTION, DERIVATION_EXTENSION, DERIVATION_UNION, DERIVATION_LIST</code>
169     * } corresponding to <code>final</code> set of this type or
170     * <code>DERIVATION_NONE</code>.
171     */
172    short getFinal() const;
173
174    /**
175     *  A boolean that specifies if the type definition is
176     * anonymous. Convenience attribute.
177     */
178    virtual bool getAnonymous() const = 0;
179
180    /**
181     * Convenience method: check if this type is derived from the given
182     * <code>ancestorType</code>.
183     * @param ancestorType  An ancestor type definition.
184     * @return  Return true if this type is derived from
185     *   <code>ancestorType</code>.
186     */
187    virtual bool derivedFromType(const XSTypeDefinition* const ancestorType) = 0;
188
189    /**
190     * Convenience method: check if this type is derived from the given
191     * ancestor type.
192     * @param typeNamespace  An ancestor type namespace.
193     * @param name  An ancestor type name.
194     * @return  Return true if this type is derived from
195     *   the ancestor defined by <code>typeNamespace</code> and <code>name</code>.
196     */
197    bool derivedFrom(const XMLCh* typeNamespace,
198                               const XMLCh* name);
199
200    //@}
201
202    //----------------------------------
203    /** methods needed by implementation */
204
205    //@{
206
207    //@}
208private:
209
210    // -----------------------------------------------------------------------
211    //  Unimplemented constructors and operators
212    // -----------------------------------------------------------------------
213    XSTypeDefinition(const XSTypeDefinition&);
214    XSTypeDefinition & operator=(const XSTypeDefinition &);
215
216protected:
217
218    // -----------------------------------------------------------------------
219    //  data members
220    // -----------------------------------------------------------------------
221    // fTypeCategory
222    //  whether this is a simpleType or complexType
223    // fFinal
224    //  the final properties which is set by the derived class.
225    TYPE_CATEGORY     fTypeCategory;
226    short             fFinal;
227    XSTypeDefinition* fBaseType; // owned by XSModel
228};
229
230inline XSTypeDefinition::TYPE_CATEGORY XSTypeDefinition::getTypeCategory() const
231{
232    return fTypeCategory;
233}
234
235inline short XSTypeDefinition::getFinal() const
236{
237    return fFinal;
238}
239
240
241XERCES_CPP_NAMESPACE_END
242
243#endif
Note: See TracBrowser for help on using the repository browser.