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

Revision 188, 15.4 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: XSSimpleTypeDefinition.hpp,v $
59 * Revision 1.10  2003/12/24 17:42:02  knoaman
60 * Misc. PSVI updates
61 *
62 * Revision 1.9  2003/12/01 23:23:26  neilg
63 * fix for bug 25118; thanks to Jeroen Witmond
64 *
65 * Revision 1.8  2003/11/25 18:08:31  knoaman
66 * Misc. PSVI updates. Thanks to David Cargill.
67 *
68 * Revision 1.7  2003/11/24 15:45:36  knoaman
69 * PSVI: finish construction of XSSimpleTypeDefinition
70 *
71 * Revision 1.6  2003/11/21 17:34:04  knoaman
72 * PSVI update
73 *
74 * Revision 1.5  2003/11/14 22:47:53  neilg
75 * fix bogus log message from previous commit...
76 *
77 * Revision 1.4  2003/11/14 22:33:30  neilg
78 * Second phase of schema component model implementation. 
79 * Implement XSModel, XSNamespaceItem, and the plumbing necessary
80 * to connect them to the other components.
81 * Thanks to David Cargill.
82 *
83 * Revision 1.3  2003/11/06 21:50:33  neilg
84 * fix compilation errors under gcc 3.3.
85 *
86 * Revision 1.2  2003/11/06 15:30:04  neilg
87 * 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.
88 *
89 * Revision 1.1  2003/09/16 14:33:36  neilg
90 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
91 *
92 */
93
94#if !defined(XSSIMPLETYPEDEFINITION_HPP)
95#define XSSIMPLETYPEDEFINITION_HPP
96
97#include <xercesc/framework/psvi/XSTypeDefinition.hpp>
98
99XERCES_CPP_NAMESPACE_BEGIN
100
101/**
102 * This class represents a simpleType definition
103 * schema component.
104 * This is *always* owned by the validator /parser object from which
105 * it is obtained. 
106 *
107 */
108
109// forward declarations
110class XSAnnotation;
111class XSFacet;
112class XSMultiValueFacet;
113class DatatypeValidator;
114
115class XMLPARSER_EXPORT XSSimpleTypeDefinition : public XSTypeDefinition
116{
117public:
118
119    // Variety definitions
120    enum VARIETY {
121            /**
122             * The variety is absent for the anySimpleType definition.
123             */
124            VARIETY_ABSENT            = 0,
125            /**
126             * <code>Atomic</code> type.
127             */
128            VARIETY_ATOMIC            = 1,
129            /**
130             * <code>List</code> type.
131             */
132            VARIETY_LIST              = 2,
133            /**
134             * <code>Union</code> type.
135             */
136            VARIETY_UNION             = 3
137    };
138
139    // Facets
140    enum FACET {
141            /**
142             * No facets defined.
143             */
144            FACET_NONE                = 0,
145            /**
146             * 4.3.1 Length
147             */
148            FACET_LENGTH              = 1,
149            /**
150             * 4.3.2 minLength.
151             */
152            FACET_MINLENGTH           = 2,
153            /**
154             * 4.3.3 maxLength.
155             */
156            FACET_MAXLENGTH           = 4,
157            /**
158             * 4.3.4 pattern.
159             */
160            FACET_PATTERN             = 8,
161            /**
162             * 4.3.5 whitespace.
163             */
164            FACET_WHITESPACE          = 16,
165            /**
166             * 4.3.7 maxInclusive.
167             */
168            FACET_MAXINCLUSIVE        = 32,
169            /**
170             * 4.3.9 maxExclusive.
171             */
172            FACET_MAXEXCLUSIVE        = 64,
173            /**
174             * 4.3.9 minExclusive.
175             */
176            FACET_MINEXCLUSIVE        = 128,
177            /**
178             * 4.3.10 minInclusive.
179             */
180            FACET_MININCLUSIVE        = 256,
181            /**
182             * 4.3.11 totalDigits .
183             */
184            FACET_TOTALDIGITS         = 512,
185            /**
186             * 4.3.12 fractionDigits.
187             */
188            FACET_FRACTIONDIGITS      = 1024,
189            /**
190             * 4.3.5 enumeration.
191             */
192            FACET_ENUMERATION         = 2048
193    };
194
195    // possible order relations
196    enum ORDERING {
197            /**
198             * A constant defined for the 'ordered' fundamental facet: Not ordered.
199             */
200            ORDERED_FALSE             = 0,
201            /**
202             * A constant defined for the 'ordered' fundamental facet: partially
203             * ordered.
204             */
205            ORDERED_PARTIAL           = 1,
206            /**
207             * A constant defined for the 'ordered' fundamental facet: total ordered.
208             */
209        ORDERED_TOTAL             = 2
210    };
211
212        //  Constructors and Destructor
213    // -----------------------------------------------------------------------
214    /** @name Constructors */
215    //@{
216
217    /**
218      * The default constructor
219      *
220      * @param  datatypeValidator
221      * @param  stVariety
222      * @param  xsBaseType
223      * @param  primitiveOrItemType
224      * @param  memberTypes
225      * @param  headAnnot
226      * @param  xsModel
227      * @param  manager     The configurable memory manager
228      */
229    XSSimpleTypeDefinition
230    (
231        DatatypeValidator* const            datatypeValidator
232        , VARIETY                           stVariety
233        , XSTypeDefinition* const           xsBaseType
234        , XSSimpleTypeDefinition* const     primitiveOrItemType
235        , XSSimpleTypeDefinitionList* const memberTypes
236        , XSAnnotation*                     headAnnot
237        , XSModel* const                    xsModel
238        , MemoryManager* const              manager = XMLPlatformUtils::fgMemoryManager
239    );
240
241    //@};
242
243    /** @name Destructor */
244    //@{
245    ~XSSimpleTypeDefinition();
246    //@}
247
248    //---------------------
249    /** @name XSSimpleTypeDefinition methods */
250
251    //@{
252
253    /**
254     * [variety]: one of {atomic, list, union} or absent
255     */
256    VARIETY getVariety() const;
257
258    /**
259     * If variety is <code>atomic</code> the primitive type definition (a
260     * built-in primitive datatype definition or the simple ur-type
261     * definition) is available, otherwise <code>null</code>.
262     */
263    XSSimpleTypeDefinition *getPrimitiveType();
264
265    /**
266     * If variety is <code>list</code> the item type definition (an atomic or
267     * union simple type definition) is available, otherwise
268     * <code>null</code>.
269     */
270    XSSimpleTypeDefinition *getItemType();
271
272    /**
273     * If variety is <code>union</code> the list of member type definitions (a
274     * non-empty sequence of simple type definitions) is available,
275     * otherwise <code>null</code>.
276     */
277    XSSimpleTypeDefinitionList *getMemberTypes() const;
278
279    /**
280     * [facets]: get all facets defined on this type. The value is a bit
281     * combination of FACET_XXX constants of all defined facets.
282     */
283    int getDefinedFacets() const;
284
285    /**
286     * Convenience method. [Facets]: check whether a facet is defined on this
287     * type.
288     * @param facetName  The name of the facet.
289     * @return  True if the facet is defined, false otherwise.
290     */
291    bool isDefinedFacet(FACET facetName);
292
293    /**
294     * [facets]: get all facets defined and fixed on this type.
295     */
296    int getFixedFacets() const;
297
298    /**
299     * Convenience method. [Facets]: check whether a facet is defined and
300     * fixed on this type.
301     * @param facetName  The name of the facet.
302     * @return  True if the facet is fixed, false otherwise.
303     */
304    bool isFixedFacet(FACET facetName);
305
306    /**
307     * Convenience method. Returns a value of a single constraining facet for
308     * this simple type definition. This method must not be used to retrieve
309     * values for <code>enumeration</code> and <code>pattern</code> facets.
310     * @param facetName The name of the facet, i.e.
311     *   <code>FACET_LENGTH, FACET_TOTALDIGITS </code> (see
312     *   <code>XSConstants</code>).To retrieve value for pattern or
313     *   enumeration, see <code>enumeration</code> and <code>pattern</code>.
314     * @return A value of the facet specified in <code>facetName</code> for
315     *   this simple type definition or <code>null</code>.
316     */
317    const XMLCh *getLexicalFacetValue(FACET facetName);
318
319    /**
320     * Returns a list of enumeration values.
321     */
322    StringList *getLexicalEnumeration();
323
324    /**
325     * Returns a list of pattern values.
326     */
327    StringList *getLexicalPattern();
328
329    /**
330     *  Fundamental Facet: ordered
331     */
332    ORDERING getOrdered() const;
333
334    /**
335     * Fundamental Facet: cardinality.
336     */
337    bool getFinite() const;
338
339    /**
340     * Fundamental Facet: bounded.
341     */
342    bool getBounded() const;
343
344    /**
345     * Fundamental Facet: numeric.
346     */
347    bool getNumeric() const;
348
349    /**
350     * Optional. A set of [annotation]s.
351     */
352    XSAnnotationList *getAnnotations();
353    /**
354     * @return list of constraining facets.
355     * This method must not be used to retrieve
356     * values for <code>enumeration</code> and <code>pattern</code> facets.
357     */
358    XSFacetList *getFacets();
359   
360    /**
361     * @return list of enumeration and pattern facets.
362     */
363    XSMultiValueFacetList *getMultiValueFacets();
364   
365    /**
366     * The name of type <code>NCName</code> of this declaration as defined in
367     * XML Namespaces.
368     */
369    const XMLCh* getName();
370
371    /**
372     *  The [target namespace] of this object, or <code>null</code> if it is
373     * unspecified.
374     */
375    const XMLCh* getNamespace();
376
377    /**
378     * A namespace schema information item corresponding to the target
379     * namespace of the component, if it's globally declared; or null
380     * otherwise.
381     */
382    XSNamespaceItem *getNamespaceItem();
383
384    /**
385     *  A boolean that specifies if the type definition is
386     * anonymous. Convenience attribute.
387     */
388    bool getAnonymous() const;
389
390    /**
391     * {base type definition}: either a simple type definition or a complex
392     * type definition.
393     */
394    XSTypeDefinition *getBaseType();
395
396    /**
397     * Convenience method: check if this type is derived from the given
398     * <code>ancestorType</code>.
399     * @param ancestorType  An ancestor type definition.
400     * @return  Return true if this type is derived from
401     *   <code>ancestorType</code>.
402     */
403    bool derivedFromType(const XSTypeDefinition* const ancestorType);
404
405    //@}
406
407    //----------------------------------
408    /** methods needed by implementation */
409
410    //@{
411
412
413    //@}
414
415private:
416
417    // -----------------------------------------------------------------------
418    //  Unimplemented constructors and operators
419    // -----------------------------------------------------------------------
420    XSSimpleTypeDefinition(const XSSimpleTypeDefinition&);
421    XSSimpleTypeDefinition & operator=(const XSSimpleTypeDefinition &);
422
423    /**
424      * Helper method for construct
425      */
426    void setFacetInfo
427    (
428        int                            definedFacets
429        , int                          fixedFacets
430        , XSFacetList* const           xsFacetList
431        , XSMultiValueFacetList* const xsMultiValueFacetList
432        , StringList* const            patternList
433    );
434    void setPrimitiveType(XSSimpleTypeDefinition*  const toSet);
435
436    friend class XSObjectFactory;
437
438protected:
439
440    // -----------------------------------------------------------------------
441    //  data members
442    // -----------------------------------------------------------------------
443    int                         fDefinedFacets;
444    int                         fFixedFacets;
445    VARIETY                     fVariety;
446    DatatypeValidator*          fDatatypeValidator;
447    XSFacetList*                fXSFacetList;
448    XSMultiValueFacetList*      fXSMultiValueFacetList;
449    StringList*                 fPatternList;
450    XSSimpleTypeDefinition*     fPrimitiveOrItemType;
451    XSSimpleTypeDefinitionList* fMemberTypes;
452    XSAnnotationList*           fXSAnnotationList;
453};
454
455inline XSSimpleTypeDefinition::VARIETY XSSimpleTypeDefinition::getVariety() const
456{
457    return fVariety;
458}
459
460inline XSSimpleTypeDefinition* XSSimpleTypeDefinition::getPrimitiveType()
461{
462    if (fVariety == VARIETY_ATOMIC)
463        return fPrimitiveOrItemType;
464
465    return 0;
466}
467
468inline XSSimpleTypeDefinition* XSSimpleTypeDefinition::getItemType()
469{
470    if (fVariety == VARIETY_LIST)
471        return fPrimitiveOrItemType;
472
473    return 0;
474}
475
476inline XSSimpleTypeDefinitionList* XSSimpleTypeDefinition::getMemberTypes() const
477{
478    return fMemberTypes;
479}
480
481inline int XSSimpleTypeDefinition::getDefinedFacets() const
482{
483    return fDefinedFacets;
484}
485
486inline int XSSimpleTypeDefinition::getFixedFacets() const
487{
488    return fFixedFacets;
489}
490
491inline StringList* XSSimpleTypeDefinition::getLexicalPattern()
492{
493    return fPatternList;
494}
495
496inline XSFacetList* XSSimpleTypeDefinition::getFacets()
497{
498    return fXSFacetList;
499}
500
501inline XSMultiValueFacetList* XSSimpleTypeDefinition::getMultiValueFacets()
502{
503    return fXSMultiValueFacetList;
504}
505
506inline XSAnnotationList *XSSimpleTypeDefinition::getAnnotations()
507{
508    return fXSAnnotationList;
509}
510
511inline void
512XSSimpleTypeDefinition::setPrimitiveType(XSSimpleTypeDefinition* const toSet)
513{
514    fPrimitiveOrItemType = toSet;
515}
516
517XERCES_CPP_NAMESPACE_END
518
519#endif
Note: See TracBrowser for help on using the repository browser.