source: NonGTP/Xerces/xercesc/framework/psvi/XSComplexTypeDefinition.hpp @ 188

Revision 188, 11.6 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 2003 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: XSComplexTypeDefinition.hpp,v $
59 * Revision 1.8  2003/12/24 17:42:02  knoaman
60 * Misc. PSVI updates
61 *
62 * Revision 1.7  2003/12/01 23:23:26  neilg
63 * fix for bug 25118; thanks to Jeroen Witmond
64 *
65 * Revision 1.6  2003/11/25 18:08:31  knoaman
66 * Misc. PSVI updates. Thanks to David Cargill.
67 *
68 * Revision 1.5  2003/11/21 17:19:30  knoaman
69 * PSVI update.
70 *
71 * Revision 1.4  2003/11/14 22:47:53  neilg
72 * fix bogus log message from previous commit...
73 *
74 * Revision 1.3  2003/11/14 22:33:30  neilg
75 * Second phase of schema component model implementation. 
76 * Implement XSModel, XSNamespaceItem, and the plumbing necessary
77 * to connect them to the other components.
78 * Thanks to David Cargill.
79 *
80 * Revision 1.2  2003/11/06 15:30:04  neilg
81 * 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.
82 *
83 * Revision 1.1  2003/09/16 14:33:36  neilg
84 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
85 *
86 */
87
88#if !defined(XSCOMPLEXTYPEDEFINITION_HPP)
89#define XSCOMPLEXTYPEDEFINITION_HPP
90
91#include <xercesc/framework/psvi/XSTypeDefinition.hpp>
92
93XERCES_CPP_NAMESPACE_BEGIN
94
95/**
96 * This class represents a complexType definition
97 * schema component.
98 * This is *always* owned by the validator /parser object from which
99 * it is obtained. 
100 *
101 */
102
103// forward declarations
104class XSAnnotation;
105class XSAttributeUse;
106class XSSimpleTypeDefinition;
107class XSParticle;
108class XSWildcard;
109class ComplexTypeInfo;
110
111class XMLPARSER_EXPORT XSComplexTypeDefinition : public XSTypeDefinition
112{
113public:
114
115        // Content Model Types
116    enum CONTENT_TYPE {
117            /**
118             * Represents an empty content type. A content type with the distinguished
119             * value empty validates elements with no character or element
120             * information item children.
121             */
122             CONTENTTYPE_EMPTY         = 0,
123            /**
124             * Represents a simple content type. A content type which is a simple
125             * validates elements with character-only children.
126             */
127             CONTENTTYPE_SIMPLE        = 1,
128            /**
129             * Represents an element-only content type. An element-only content type
130             * validates elements with children that conform to the supplied content
131             * model.
132             */
133             CONTENTTYPE_ELEMENT       = 2,
134            /**
135             * Represents a mixed content type.
136             */
137             CONTENTTYPE_MIXED         = 3
138        };
139
140    //  Constructors and Destructor
141    // -----------------------------------------------------------------------
142    /** @name Constructors */
143    //@{
144
145    /**
146      * The default constructor
147      *
148      * @param  complexTypeInfo
149      * @param  xsWildcard
150      * @param  xsSimpleType
151      * @param  xsAttList
152      * @param  xsBaseType
153      * @param  xsParticle
154      * @param  headAnnot
155      * @param  xsModel
156      * @param  manager     The configurable memory manager
157      */
158    XSComplexTypeDefinition
159    (
160        ComplexTypeInfo* const          complexTypeInfo
161        , XSWildcard* const             xsWildcard
162        , XSSimpleTypeDefinition* const xsSimpleType
163        , XSAttributeUseList* const     xsAttList
164        , XSTypeDefinition* const       xsBaseType
165        , XSParticle* const             xsParticle
166        , XSAnnotation* const           headAnnot
167        , XSModel* const                xsModel
168        , MemoryManager* const          manager = XMLPlatformUtils::fgMemoryManager
169    );
170
171    //@};
172
173    /** @name Destructor */
174    //@{
175    ~XSComplexTypeDefinition();
176    //@}
177
178    //---------------------
179    /** @name XSComplexTypeDefinition methods */
180
181    //@{
182
183    /**
184     * [derivation method]: either <code>DERIVATION_EXTENSION</code>,
185     * <code>DERIVATION_RESTRICTION</code>, or <code>DERIVATION_NONE</code>
186     * (see <code>XSObject</code>).
187     */
188    XSConstants::DERIVATION_TYPE getDerivationMethod() const;
189
190    /**
191     * [abstract]: a boolean. Complex types for which <code>abstract</code> is
192     * true must not be used as the type definition for the validation of
193     * element information items.
194     */
195    bool getAbstract() const;
196
197    /**
198     *  A set of attribute uses.
199     */
200    XSAttributeUseList *getAttributeUses();
201
202    /**
203     * Optional.An attribute wildcard.
204     */
205    XSWildcard *getAttributeWildcard() const;
206
207    /**
208     * [content type]: one of empty (<code>CONTENTTYPE_EMPTY</code>), a simple
209     * type definition (<code>CONTENTTYPE_SIMPLE</code>), mixed (
210     * <code>CONTENTTYPE_MIXED</code>), or element-only (
211     * <code>CONTENTTYPE_ELEMENT</code>).
212     */
213    CONTENT_TYPE getContentType() const;
214
215    /**
216     * A simple type definition corresponding to simple content model,
217     * otherwise <code>null</code>
218     */
219    XSSimpleTypeDefinition *getSimpleType() const;
220
221    /**
222     * A particle for mixed or element-only content model, otherwise
223     * <code>null</code>
224     */
225    XSParticle *getParticle() const;
226
227    /**
228     * [prohibited substitutions]: a subset of {extension, restriction}
229     * @param toTest  Extention or restriction constants (see
230     *   <code>XSObject</code>).
231     * @return True if toTest is a prohibited substitution, otherwise
232     *   false.
233     */
234    bool isProhibitedSubstitution(XSConstants::DERIVATION_TYPE toTest);
235
236    /**
237     *  [prohibited substitutions]: A subset of {extension, restriction} or
238     * <code>DERIVATION_NONE</code> represented as a bit flag (see
239     * <code>XSObject</code>).
240     */
241    short getProhibitedSubstitutions() const;
242
243    /**
244     * A set of [annotations].
245     */
246    XSAnnotationList *getAnnotations();
247   
248    /**
249     * The name of type <code>NCName</code> of this declaration as defined in
250     * XML Namespaces.
251     */
252    const XMLCh* getName();
253
254    /**
255     *  The [target namespace] of this object, or <code>null</code> if it is
256     * unspecified.
257     */
258    const XMLCh* getNamespace();
259
260    /**
261     * A namespace schema information item corresponding to the target
262     * namespace of the component, if it's globally declared; or null
263     * otherwise.
264     */
265    XSNamespaceItem *getNamespaceItem();
266
267    /**
268     *  A boolean that specifies if the type definition is
269     * anonymous. Convenience attribute.
270     */
271    bool getAnonymous() const;
272
273    /**
274     * {base type definition}: either a simple type definition or a complex
275     * type definition.
276     */
277    XSTypeDefinition *getBaseType();
278
279    /**
280     * Convenience method: check if this type is derived from the given
281     * <code>ancestorType</code>.
282     * @param ancestorType  An ancestor type definition.
283     * @return  Return true if this type is derived from
284     *   <code>ancestorType</code>.
285     */
286    bool derivedFromType(const XSTypeDefinition* const ancestorType);
287
288    //@}
289
290    //----------------------------------
291    /** methods needed by implementation */
292
293    //@{
294
295
296    //@}
297
298private:
299
300    /**
301     * Set the base type
302     */
303    void setBaseType(XSTypeDefinition* const xsBaseType);
304    friend class XSObjectFactory;
305
306    // -----------------------------------------------------------------------
307    //  Unimplemented constructors and operators
308    // -----------------------------------------------------------------------
309    XSComplexTypeDefinition(const XSComplexTypeDefinition&);
310    XSComplexTypeDefinition & operator=(const XSComplexTypeDefinition &);
311
312protected:
313
314    // -----------------------------------------------------------------------
315    //  data members
316    // -----------------------------------------------------------------------
317    ComplexTypeInfo*        fComplexTypeInfo;
318    XSWildcard*             fXSWildcard;
319    XSAttributeUseList*     fXSAttributeUseList;
320    XSSimpleTypeDefinition* fXSSimpleTypeDefinition;
321    XSAnnotationList*       fXSAnnotationList;
322    XSParticle*             fParticle;
323    short                   fProhibitedSubstitution;
324};
325
326
327inline XSAttributeUseList* XSComplexTypeDefinition::getAttributeUses()
328{
329    return fXSAttributeUseList;
330}
331
332inline XSWildcard* XSComplexTypeDefinition::getAttributeWildcard() const
333{
334    return fXSWildcard;
335}
336
337inline XSSimpleTypeDefinition* XSComplexTypeDefinition::getSimpleType() const
338{
339    return fXSSimpleTypeDefinition;
340}
341
342inline short XSComplexTypeDefinition::getProhibitedSubstitutions() const
343{
344    return fProhibitedSubstitution;
345}
346
347inline XSParticle *XSComplexTypeDefinition::getParticle() const
348{
349    return fParticle;
350}
351
352inline void
353XSComplexTypeDefinition::setBaseType(XSTypeDefinition* const xsBaseType)
354{
355    fBaseType = xsBaseType;
356}
357
358XERCES_CPP_NAMESPACE_END
359
360#endif
Note: See TracBrowser for help on using the repository browser.