Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:52

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_XSSIMPLETYPEDEFINITION_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XSSIMPLETYPEDEFINITION_HPP
0024 
0025 #include <xercesc/framework/psvi/XSTypeDefinition.hpp>
0026 
0027 XERCES_CPP_NAMESPACE_BEGIN
0028 
0029 /**
0030  * This class represents a simpleType definition
0031  * schema component.
0032  * This is *always* owned by the validator /parser object from which
0033  * it is obtained.  
0034  *
0035  */
0036 
0037 // forward declarations
0038 class XSAnnotation;
0039 class XSFacet;
0040 class XSMultiValueFacet;
0041 class DatatypeValidator;
0042 
0043 class XMLPARSER_EXPORT XSSimpleTypeDefinition : public XSTypeDefinition
0044 {
0045 public:
0046 
0047     // Variety definitions
0048     enum VARIETY {
0049         /**
0050          * The variety is absent for the anySimpleType definition.
0051          */
0052         VARIETY_ABSENT            = 0,
0053         /**
0054          * <code>Atomic</code> type.
0055          */
0056         VARIETY_ATOMIC            = 1,
0057         /**
0058          * <code>List</code> type.
0059          */
0060         VARIETY_LIST              = 2,
0061         /**
0062          * <code>Union</code> type.
0063          */
0064         VARIETY_UNION             = 3
0065     };
0066 
0067     // Facets
0068     enum FACET {
0069         /**
0070          * No facets defined.
0071          */
0072         FACET_NONE                = 0,
0073         /**
0074          * 4.3.1 Length
0075          */
0076         FACET_LENGTH              = 1,
0077         /**
0078          * 4.3.2 minLength. 
0079          */
0080         FACET_MINLENGTH           = 2,
0081         /**
0082          * 4.3.3 maxLength.
0083          */
0084         FACET_MAXLENGTH           = 4,
0085         /**
0086          * 4.3.4 pattern.
0087          */
0088         FACET_PATTERN             = 8,
0089         /**
0090          * 4.3.5 whitespace.
0091          */
0092         FACET_WHITESPACE          = 16,
0093         /**
0094          * 4.3.7 maxInclusive.
0095          */
0096         FACET_MAXINCLUSIVE        = 32,
0097         /**
0098          * 4.3.9 maxExclusive.
0099          */
0100         FACET_MAXEXCLUSIVE        = 64,
0101         /**
0102          * 4.3.9 minExclusive.
0103          */
0104         FACET_MINEXCLUSIVE        = 128,
0105         /**
0106          * 4.3.10 minInclusive.
0107          */
0108         FACET_MININCLUSIVE        = 256,
0109         /**
0110          * 4.3.11 totalDigits .
0111          */
0112         FACET_TOTALDIGITS         = 512,
0113         /**
0114          * 4.3.12 fractionDigits.
0115          */
0116         FACET_FRACTIONDIGITS      = 1024,
0117         /**
0118          * 4.3.5 enumeration.
0119          */
0120         FACET_ENUMERATION         = 2048
0121     };
0122 
0123     // possible order relations
0124     enum ORDERING {
0125         /**
0126          * A constant defined for the 'ordered' fundamental facet: Not ordered.
0127          */
0128         ORDERED_FALSE             = 0,
0129         /**
0130          * A constant defined for the 'ordered' fundamental facet: partially 
0131          * ordered.
0132          */
0133         ORDERED_PARTIAL           = 1,
0134         /**
0135          * A constant defined for the 'ordered' fundamental facet: total ordered.
0136          */
0137         ORDERED_TOTAL             = 2
0138     };
0139 
0140     //  Constructors and Destructor
0141     // -----------------------------------------------------------------------
0142     /** @name Constructors */
0143     //@{
0144 
0145     /**
0146       * The default constructor 
0147       *
0148       * @param  datatypeValidator
0149       * @param  stVariety
0150       * @param  xsBaseType
0151       * @param  primitiveOrItemType
0152       * @param  memberTypes
0153       * @param  headAnnot
0154       * @param  xsModel
0155       * @param  manager     The configurable memory manager
0156       */
0157     XSSimpleTypeDefinition
0158     (
0159         DatatypeValidator* const            datatypeValidator
0160         , VARIETY                           stVariety
0161         , XSTypeDefinition* const           xsBaseType
0162         , XSSimpleTypeDefinition* const     primitiveOrItemType
0163         , XSSimpleTypeDefinitionList* const memberTypes
0164         , XSAnnotation*                     headAnnot
0165         , XSModel* const                    xsModel
0166         , MemoryManager* const              manager = XMLPlatformUtils::fgMemoryManager
0167     );
0168 
0169     //@};
0170 
0171     /** @name Destructor */
0172     //@{
0173     ~XSSimpleTypeDefinition();
0174     //@}
0175 
0176     //---------------------
0177     /** @name XSSimpleTypeDefinition methods */
0178 
0179     //@{
0180 
0181     /**
0182      * [variety]: one of {atomic, list, union} or absent 
0183      */
0184     VARIETY getVariety() const;
0185 
0186     /**
0187      * If variety is <code>atomic</code> the primitive type definition (a 
0188      * built-in primitive datatype definition or the simple ur-type 
0189      * definition) is available, otherwise <code>null</code>. 
0190      */
0191     XSSimpleTypeDefinition *getPrimitiveType();
0192 
0193     /**
0194      * If variety is <code>list</code> the item type definition (an atomic or 
0195      * union simple type definition) is available, otherwise 
0196      * <code>null</code>. 
0197      */
0198     XSSimpleTypeDefinition *getItemType();
0199 
0200     /**
0201      * If variety is <code>union</code> the list of member type definitions (a 
0202      * non-empty sequence of simple type definitions) is available, 
0203      * otherwise <code>null</code>. 
0204      */
0205     XSSimpleTypeDefinitionList *getMemberTypes() const;
0206 
0207     /**
0208      * [facets]: get all facets defined on this type. The value is a bit 
0209      * combination of FACET_XXX constants of all defined facets. 
0210      */
0211     int getDefinedFacets() const;
0212 
0213     /**
0214      * Convenience method. [Facets]: check whether a facet is defined on this 
0215      * type.
0216      * @param facetName  The name of the facet. 
0217      * @return  True if the facet is defined, false otherwise.
0218      */
0219     bool isDefinedFacet(FACET facetName);
0220 
0221     /**
0222      * [facets]: get all facets defined and fixed on this type.
0223      */
0224     int getFixedFacets() const;
0225 
0226     /**
0227      * Convenience method. [Facets]: check whether a facet is defined and 
0228      * fixed on this type. 
0229      * @param facetName  The name of the facet. 
0230      * @return  True if the facet is fixed, false otherwise.
0231      */
0232     bool isFixedFacet(FACET facetName);
0233 
0234     /**
0235      * Convenience method. Returns a value of a single constraining facet for 
0236      * this simple type definition. This method must not be used to retrieve 
0237      * values for <code>enumeration</code> and <code>pattern</code> facets. 
0238      * @param facetName The name of the facet, i.e. 
0239      *   <code>FACET_LENGTH, FACET_TOTALDIGITS </code> (see 
0240      *   <code>XSConstants</code>).To retrieve value for pattern or 
0241      *   enumeration, see <code>enumeration</code> and <code>pattern</code>.
0242      * @return A value of the facet specified in <code>facetName</code> for 
0243      *   this simple type definition or <code>null</code>. 
0244      */
0245     const XMLCh *getLexicalFacetValue(FACET facetName);
0246 
0247     /**
0248      * Returns a list of enumeration values. 
0249      */
0250     StringList *getLexicalEnumeration();
0251 
0252     /**
0253      * Returns a list of pattern values. 
0254      */
0255     StringList *getLexicalPattern();
0256 
0257     /**
0258      *  Fundamental Facet: ordered 
0259      */
0260     ORDERING getOrdered() const;
0261 
0262     /**
0263      * Fundamental Facet: cardinality. 
0264      */
0265     bool getFinite() const;
0266 
0267     /**
0268      * Fundamental Facet: bounded. 
0269      */
0270     bool getBounded() const;
0271 
0272     /**
0273      * Fundamental Facet: numeric. 
0274      */
0275     bool getNumeric() const;
0276 
0277     /**
0278      * Optional. A set of [annotation]s. 
0279      */
0280     XSAnnotationList *getAnnotations();
0281     /** 
0282      * @return list of constraining facets.
0283      * This method must not be used to retrieve 
0284      * values for <code>enumeration</code> and <code>pattern</code> facets.
0285      */
0286     XSFacetList *getFacets();
0287     
0288     /** 
0289      * @return list of enumeration and pattern facets.
0290      */
0291     XSMultiValueFacetList *getMultiValueFacets();
0292     
0293     /**
0294      * The name of type <code>NCName</code> of this declaration as defined in 
0295      * XML Namespaces.
0296      */
0297     const XMLCh* getName() const;
0298 
0299     /**
0300      *  The [target namespace] of this object, or <code>null</code> if it is 
0301      * unspecified. 
0302      */
0303     const XMLCh* getNamespace() const;
0304 
0305     /**
0306      * A namespace schema information item corresponding to the target 
0307      * namespace of the component, if it's globally declared; or null 
0308      * otherwise.
0309      */
0310     XSNamespaceItem *getNamespaceItem();
0311 
0312     /**
0313      *  A boolean that specifies if the type definition is 
0314      * anonymous. Convenience attribute. 
0315      */
0316     bool getAnonymous() const;
0317 
0318     /**
0319      * {base type definition}: either a simple type definition or a complex 
0320      * type definition. 
0321      */
0322     XSTypeDefinition *getBaseType();
0323 
0324     /**
0325      * Convenience method: check if this type is derived from the given 
0326      * <code>ancestorType</code>. 
0327      * @param ancestorType  An ancestor type definition. 
0328      * @return  Return true if this type is derived from 
0329      *   <code>ancestorType</code>.
0330      */
0331     bool derivedFromType(const XSTypeDefinition* const ancestorType);
0332 
0333     /**
0334      * 
0335      */
0336     inline DatatypeValidator* getDatatypeValidator() const;
0337 
0338     //@}
0339 
0340     //----------------------------------
0341     /** methods needed by implementation */
0342 
0343     //@{
0344 
0345 
0346     //@}
0347 
0348 private:
0349 
0350     // -----------------------------------------------------------------------
0351     //  Unimplemented constructors and operators
0352     // -----------------------------------------------------------------------
0353     XSSimpleTypeDefinition(const XSSimpleTypeDefinition&);
0354     XSSimpleTypeDefinition & operator=(const XSSimpleTypeDefinition &);
0355 
0356     /**
0357       * Helper method for construct
0358       */
0359     void setFacetInfo
0360     (
0361         int                            definedFacets
0362         , int                          fixedFacets
0363         , XSFacetList* const           xsFacetList
0364         , XSMultiValueFacetList* const xsMultiValueFacetList
0365         , StringList* const            patternList
0366     );
0367     void setPrimitiveType(XSSimpleTypeDefinition*  const toSet);
0368 
0369     friend class XSObjectFactory;
0370 
0371 protected:
0372 
0373     // -----------------------------------------------------------------------
0374     //  data members
0375     // -----------------------------------------------------------------------
0376     int                         fDefinedFacets;
0377     int                         fFixedFacets;
0378     VARIETY                     fVariety;
0379     DatatypeValidator*          fDatatypeValidator;
0380     XSFacetList*                fXSFacetList;
0381     XSMultiValueFacetList*      fXSMultiValueFacetList;
0382     StringList*                 fPatternList;
0383     XSSimpleTypeDefinition*     fPrimitiveOrItemType;
0384     XSSimpleTypeDefinitionList* fMemberTypes;
0385     XSAnnotationList*           fXSAnnotationList;
0386 };
0387 
0388 inline XSSimpleTypeDefinition::VARIETY XSSimpleTypeDefinition::getVariety() const
0389 {
0390     return fVariety;
0391 }
0392 
0393 inline XSSimpleTypeDefinition* XSSimpleTypeDefinition::getPrimitiveType()
0394 {
0395     if (fVariety == VARIETY_ATOMIC)
0396         return fPrimitiveOrItemType;
0397 
0398     return 0;
0399 }
0400 
0401 inline XSSimpleTypeDefinition* XSSimpleTypeDefinition::getItemType()
0402 {
0403     if (fVariety == VARIETY_LIST)
0404         return fPrimitiveOrItemType;
0405 
0406     return 0;
0407 }
0408 
0409 inline XSSimpleTypeDefinitionList* XSSimpleTypeDefinition::getMemberTypes() const
0410 {
0411     return fMemberTypes;
0412 }
0413 
0414 inline int XSSimpleTypeDefinition::getDefinedFacets() const
0415 {
0416     return fDefinedFacets;
0417 }
0418 
0419 inline int XSSimpleTypeDefinition::getFixedFacets() const
0420 {
0421     return fFixedFacets;
0422 }
0423 
0424 inline StringList* XSSimpleTypeDefinition::getLexicalPattern()
0425 {
0426     return fPatternList;
0427 }
0428 
0429 inline XSFacetList* XSSimpleTypeDefinition::getFacets()
0430 {
0431     return fXSFacetList;
0432 }
0433 
0434 inline XSMultiValueFacetList* XSSimpleTypeDefinition::getMultiValueFacets()
0435 {
0436     return fXSMultiValueFacetList;
0437 }
0438 
0439 inline XSAnnotationList *XSSimpleTypeDefinition::getAnnotations()
0440 {
0441     return fXSAnnotationList;
0442 }
0443 
0444 inline void
0445 XSSimpleTypeDefinition::setPrimitiveType(XSSimpleTypeDefinition* const toSet)
0446 {
0447     fPrimitiveOrItemType = toSet;
0448 }
0449 
0450 inline DatatypeValidator* 
0451 XSSimpleTypeDefinition::getDatatypeValidator() const
0452 {
0453     return fDatatypeValidator;
0454 }
0455 
0456 XERCES_CPP_NAMESPACE_END
0457 
0458 #endif