| API Docs for SAX and DOM |
| Main Page Classes Files Related Pages # XMLAttDef.hpp Go to the documentation of this file.
    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: XMLAttDef.hpp 568078 2007-08-21 11:43:25Z amassari $
    00020  */
    00021
    00022 #if !defined(ATTDEF_HPP)
    00023 #define ATTDEF_HPP
    00024
    00025 #include <xercesc/util/PlatformUtils.hpp>
    00026 #include <xercesc/util/XMLString.hpp>
    00027 #include <xercesc/util/XMemory.hpp>
    00028 #include <xercesc/internal/XSerializable.hpp>
    00029
    00030 XERCES_CPP_NAMESPACE_BEGIN
    00031
    00032 class XMLAttr;
    00033
    00052 class  XMLAttDef : public XSerializable, public XMemory
    00053 {
    00054 public:
    00055     // -----------------------------------------------------------------------
    00056     //  Class specific types
    00057     //
    00058     //  AttTypes
    00059     //      The list of possible types that an attribute can have, according
    00060     //      to the XML 1.0 spec and schema.
    00061     //
    00062     //  DefAttTypes
    00063     //      The modifiers that an attribute decl can have, which indicates
    00064     //      whether instances of that attributes are required, implied, etc..
    00065     //
    00066     //  CreateReasons
    00067     //      This type is used to store how an attribute declaration got into
    00068     //      the elementdecl's attribute pool.
    00069     //
    00070     // -----------------------------------------------------------------------
    00071     enum AttTypes
    00072     {
    00073         CData               = 0
    00074         , ID                = 1
    00075         , IDRef             = 2
    00076         , IDRefs            = 3
    00077         , Entity            = 4
    00078         , Entities          = 5
    00079         , NmToken           = 6
    00080         , NmTokens          = 7
    00081         , Notation          = 8
    00082         , Enumeration       = 9
    00083         , Simple            = 10
    00084         , Any_Any           = 11
    00085         , Any_Other         = 12
    00086         , Any_List          = 13
    00087
    00088         , AttTypes_Count
    00089         , AttTypes_Min      = 0
    00090         , AttTypes_Max      = 13
    00091         , AttTypes_Unknown  = -1
    00092     };
    00093
    00094     enum DefAttTypes
    00095     {
    00096         Default                  = 0
    00097         , Fixed                  = 1
    00098         , Required               = 2
    00099         , Required_And_Fixed     = 3
    00100         , Implied                = 4
    00101         , ProcessContents_Skip   = 5
    00102         , ProcessContents_Lax    = 6
    00103         , ProcessContents_Strict = 7
    00104         , Prohibited             = 8
    00105
    00106         , DefAttTypes_Count
    00107         , DefAttTypes_Min   = 0
    00108         , DefAttTypes_Max   = 8
    00109         , DefAttTypes_Unknown = -1
    00110     };
    00111
    00112     enum CreateReasons
    00113     {
    00114         NoReason
    00115         , JustFaultIn
    00116     };
    00117
    00118     // -----------------------------------------------------------------------
    00119     //  Public static data members
    00120     // -----------------------------------------------------------------------
    00121     static const unsigned int fgInvalidAttrId;
    00122
    00123
    00124     // -----------------------------------------------------------------------
    00125     //  Public, static methods
    00126     // -----------------------------------------------------------------------
    00127
    00130
    00141     static const XMLCh* getAttTypeString(const AttTypes attrType
    00142         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00143
    00154     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType
    00155         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00156
    00158
    00159
    00160     // -----------------------------------------------------------------------
    00161     //  Destructor
    00162     // -----------------------------------------------------------------------
    00163
    00166
    00170     virtual ~XMLAttDef();
    00172
    00173
    00174     // -----------------------------------------------------------------------
    00175     //  The virtual attribute def interface
    00176     // -----------------------------------------------------------------------
    00177
    00180
    00189     virtual const XMLCh* getFullName() const = 0;
    00190
    00195     virtual void reset() = 0;
    00196
    00198
    00199
    00200     // -----------------------------------------------------------------------
    00201     //  Getter methods
    00202     // -----------------------------------------------------------------------
    00203
    00206
    00215     DefAttTypes getDefaultType() const;
    00216
    00226     const XMLCh* getEnumeration() const;
    00227
    00236     unsigned int getId() const;
    00237
    00252     bool getProvided() const;
    00253
    00263     AttTypes getType() const;
    00264
    00274     const XMLCh* getValue() const;
    00275
    00284     CreateReasons getCreateReason() const;
    00285
    00293     bool isExternal() const;
    00294
    00302     MemoryManager* getMemoryManager() const;
    00303
    00304
    00309     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00310
    00315     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00316
    00318
    00319
    00320     // -----------------------------------------------------------------------
    00321     //  Setter methods
    00322     // -----------------------------------------------------------------------
    00323
    00326
    00335     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
    00336
    00345     void setId(const unsigned int newId);
    00346
    00356     void setProvided(const bool newValue);
    00357
    00365     void setType(const XMLAttDef::AttTypes newValue);
    00366
    00377     void setValue(const XMLCh* const newValue);
    00378
    00389     void setEnumeration(const XMLCh* const newValue);
    00390
    00398     void setCreateReason(const CreateReasons newReason);
    00399
    00405     void setExternalAttDeclaration(const bool aValue);
    00406
    00408
    00409     /***
    00410      * Support for Serialization/De-serialization
    00411      ***/
    00412     DECL_XSERIALIZABLE(XMLAttDef)
    00413
    00414 protected :
    00415     // -----------------------------------------------------------------------
    00416     //  Hidden constructors
    00417     // -----------------------------------------------------------------------
    00418     XMLAttDef
    00419     (
    00420         const   AttTypes       type = CData
    00421         , const DefAttTypes    defType= Implied
    00422         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00423     );
    00424     XMLAttDef
    00425     (
    00426         const   XMLCh* const        attValue
    00427         , const AttTypes            type
    00428         , const DefAttTypes         defType
    00429         , const XMLCh* const        enumValues = 0
    00430         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00431     );
    00432
    00433
    00434 private :
    00435     // -----------------------------------------------------------------------
    00436     //  Unimplemented constructors and operators
    00437     // -----------------------------------------------------------------------
    00438     XMLAttDef(const XMLAttDef&);
    00439     XMLAttDef& operator=(const XMLAttDef&);
    00440
    00441
    00442     // -----------------------------------------------------------------------
    00443     //  Private helper methods
    00444     // -----------------------------------------------------------------------
    00445     void cleanUp();
    00446
    00447
    00448     // -----------------------------------------------------------------------
    00449     //  Private data members
    00450     //
    00451     //  fDefaultType
    00452     //      Indicates what, if any, default stuff this attribute has.
    00453     //
    00454     //  fEnumeration
    00455     //      If its an enumeration, this is the list of values as space
    00456     //      separated values.
    00457     //
    00458     //  fId
    00459     //      This is the unique id of this attribute, given to it when its put
    00460     //      into the validator's attribute decl pool. It defaults to the
    00461     //      special value XMLAttrDef::fgInvalidAttrId.
    00462     //
    00463     //  fProvided
    00464     //      This field is really for use by the scanner. It is used to track
    00465     //      which of the attributes of an element were provided. Any marked
    00466     //      as not provided (after scanning the start tag) and having a
    00467     //      default type of Required, is in error.
    00468     //
    00469     //  fType
    00470     //      The type of attribute, which is one of the AttTypes values.
    00471     //
    00472     //  fValue
    00473     //      This is the value of the attribute, which is the default value
    00474     //      given in the attribute declaration.
    00475     //
    00476     //  fCreateReason
    00477     //      This flag tells us how this attribute got created.  Sometimes even
    00478     //      the attribute was not declared for the element, we want to fault
    00479     //      fault it into the pool to avoid lots of redundant errors.
    00480     //
    00481     //  fExternalAttribute
    00482     //      This flag indicates whether or not the attribute was declared externally.
    00483     // -----------------------------------------------------------------------
    00484     DefAttTypes     fDefaultType;
    00485     AttTypes        fType;
    00486     CreateReasons   fCreateReason;
    00487     bool            fProvided;
    00488     bool            fExternalAttribute;
    00489     unsigned int    fId;
    00490     XMLCh*          fValue;
    00491     XMLCh*          fEnumeration;
    00492     MemoryManager*  fMemoryManager;
    00493 };
    00494
    00495
    00496 // ---------------------------------------------------------------------------
    00497 //  Getter methods
    00498 // ---------------------------------------------------------------------------
    00499 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
    00500 {
    00501     return fDefaultType;
    00502 }
    00503
    00504 inline const XMLCh* XMLAttDef::getEnumeration() const
    00505 {
    00506     return fEnumeration;
    00507 }
    00508
    00509 inline unsigned int XMLAttDef::getId() const
    00510 {
    00511     return fId;
    00512 }
    00513
    00514 inline bool XMLAttDef::getProvided() const
    00515 {
    00516     return fProvided;
    00517 }
    00518
    00519 inline XMLAttDef::AttTypes XMLAttDef::getType() const
    00520 {
    00521     return fType;
    00522 }
    00523
    00524 inline const XMLCh* XMLAttDef::getValue() const
    00525 {
    00526     return fValue;
    00527 }
    00528
    00529 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
    00530 {
    00531     return fCreateReason;
    00532 }
    00533
    00534 inline bool XMLAttDef::isExternal() const
    00535 {
    00536     return fExternalAttribute;
    00537 }
    00538
    00539 inline MemoryManager* XMLAttDef::getMemoryManager() const
    00540 {
    00541     return fMemoryManager;
    00542 }
    00543
    00544 // ---------------------------------------------------------------------------
    00545 //  XMLAttDef: Setter methods
    00546 // ---------------------------------------------------------------------------
    00547 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
    00548 {
    00549     fDefaultType = newValue;
    00550 }
    00551
    00552 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
    00553 {
    00554     if (fEnumeration)
    00555         fMemoryManager->deallocate(fEnumeration);
    00556
    00557     fEnumeration = XMLString::replicate(newValue, fMemoryManager);
    00558 }
    00559
    00560 inline void XMLAttDef::setId(const unsigned int newId)
    00561 {
    00562     fId = newId;
    00563 }
    00564
    00565 inline void XMLAttDef::setProvided(const bool newValue)
    00566 {
    00567     fProvided = newValue;
    00568 }
    00569
    00570 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
    00571 {
    00572     fType = newValue;
    00573 }
    00574
    00575 inline void XMLAttDef::setValue(const XMLCh* const newValue)
    00576 {
    00577     if (fValue)
    00578        fMemoryManager->deallocate(fValue);
    00579
    00580     fValue = XMLString::replicate(newValue, fMemoryManager);
    00581 }
    00582
    00583 inline void
    00584 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
    00585 {
    00586     fCreateReason = newReason;
    00587 }
    00588
    00589 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
    00590 {
    00591     fExternalAttribute = aValue;
    00592 }
    00593
    00594 XERCES_CPP_NAMESPACE_END
    00595
    00596 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.