Xerces-C++: XMLAttDef.hpp Source File

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

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