| API Docs for SAX and DOM |
| Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members # 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  * $Log: XMLAttDef.hpp,v $
    00019  * Revision 1.14  2004/09/08 13:55:58  peiyongz
    00020  * Apache License Version 2.0
    00021  *
    00022  * Revision 1.13  2004/09/02 19:08:09  cargilld
    00023  * Fix API Doc warning message
    00024  *
    00025  * Revision 1.12  2003/12/17 00:18:33  cargilld
    00026  * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    00027  *
    00028  * Revision 1.11  2003/11/24 05:19:15  neilg
    00029  * update method documentation
    00030  *
    00031  * Revision 1.10  2003/10/10 16:23:29  peiyongz
    00032  * Implementation of Serialization/Deserialization
    00033  *
    00034  * Revision 1.9  2003/05/16 21:36:55  knoaman
    00035  * Memory manager implementation: Modify constructors to pass in the memory manager.
    00036  *
    00037  * Revision 1.8  2003/05/15 18:26:07  knoaman
    00038  * Partial implementation of the configurable memory manager.
    00039  *
    00040  * Revision 1.7  2003/04/21 20:46:01  knoaman
    00041  * Use XMLString::release to prepare for configurable memory manager.
    00042  *
    00043  * Revision 1.6  2003/03/07 18:08:10  tng
    00044  * Return a reference instead of void for operator=
    00045  *
    00046  * Revision 1.5  2003/01/29 19:45:35  gareth
    00047  * added api for DOMTypeInfo
    00048  *
    00049  * Revision 1.4  2002/12/10 02:15:55  knoaman
    00050  * Schema Errata: E1-21.
    00051  *
    00052  * Revision 1.3  2002/11/04 15:00:21  tng
    00053  * C++ Namespace Support.
    00054  *
    00055  * Revision 1.2  2002/02/20 18:17:01  tng
    00056  * [Bug 5977] Warnings on generating apiDocs.
    00057  *
    00058  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
    00059  * sane_include
    00060  *
    00061  * Revision 1.13  2001/11/15 16:36:36  knoaman
    00062  * Re-organize constant values.
    00063  *
    00064  * Revision 1.12  2001/08/09 15:23:37  knoaman
    00065  * add support for <anyAttribute> declaration.
    00066  *
    00067  * Revision 1.11  2001/06/21 14:25:26  knoaman
    00068  * Fix for bug 1946
    00069  *
    00070  * Revision 1.10  2001/05/11 13:25:31  tng
    00071  * Copyright update.
    00072  *
    00073  * Revision 1.9  2001/02/27 18:48:20  tng
    00074  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
    00075  *
    00076  * Revision 1.8  2000/12/14 18:49:56  tng
    00077  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00078  *
    00079  * Revision 1.7  2000/11/30 18:22:38  andyh
    00080  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00081  * pools already containing some items.  Fixed by Tinny Ng.
    00082  *
    00083  * Revision 1.6  2000/07/07 22:23:38  jpolast
    00084  * remove useless getKey() functions.
    00085  *
    00086  * Revision 1.5  2000/02/24 20:00:22  abagchi
    00087  * Swat for removing Log from API docs
    00088  *
    00089  * Revision 1.4  2000/02/16 23:03:48  roddey
    00090  * More documentation updates
    00091  *
    00092  * Revision 1.3  2000/02/15 01:21:30  roddey
    00093  * Some initial documentation improvements. More to come...
    00094  *
    00095  * Revision 1.2  2000/02/06 07:47:46  rahulj
    00096  * Year 2K copyright swat.
    00097  *
    00098  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
    00099  * Initial checkin
    00100  *
    00101  * Revision 1.2  1999/11/08 20:44:34  rahul
    00102  * Swat for adding in Product name and CVS comment log variable.
    00103  *
    00104  */
    00105
    00106 #if !defined(ATTDEF_HPP)
    00107 #define ATTDEF_HPP
    00108
    00109 #include <xercesc/util/PlatformUtils.hpp>
    00110 #include <xercesc/util/XMLString.hpp>
    00111 #include <xercesc/util/XMemory.hpp>
    00112 #include <xercesc/internal/XSerializable.hpp>
    00113
    00114 XERCES_CPP_NAMESPACE_BEGIN
    00115
    00116 class XMLAttr;
    00117
    00136 class  XMLAttDef : public XSerializable, public XMemory
    00137 {
    00138 public:
    00139     // -----------------------------------------------------------------------
    00140     //  Class specific types
    00141     //
    00142     //  AttTypes
    00143     //      The list of possible types that an attribute can have, according
    00144     //      to the XML 1.0 spec and schema.
    00145     //
    00146     //  DefAttTypes
    00147     //      The modifiers that an attribute decl can have, which indicates
    00148     //      whether instances of that attributes are required, implied, etc..
    00149     //
    00150     //  CreateReasons
    00151     //      This type is used to store how an attribute declaration got into
    00152     //      the elementdecl's attribute pool.
    00153     //
    00154     // -----------------------------------------------------------------------
    00155     enum AttTypes
    00156     {
    00157         CData               = 0
    00158         , ID                = 1
    00159         , IDRef             = 2
    00160         , IDRefs            = 3
    00161         , Entity            = 4
    00162         , Entities          = 5
    00163         , NmToken           = 6
    00164         , NmTokens          = 7
    00165         , Notation          = 8
    00166         , Enumeration       = 9
    00167         , Simple            = 10
    00168         , Any_Any           = 11
    00169         , Any_Other         = 12
    00170         , Any_List          = 13
    00171
    00172         , AttTypes_Count
    00173         , AttTypes_Min      = 0
    00174         , AttTypes_Max      = 13
    00175         , AttTypes_Unknown  = -1
    00176     };
    00177
    00178     enum DefAttTypes
    00179     {
    00180         Default                  = 0
    00181         , Fixed                  = 1
    00182         , Required               = 2
    00183         , Required_And_Fixed     = 3
    00184         , Implied                = 4
    00185         , ProcessContents_Skip   = 5
    00186         , ProcessContents_Lax    = 6
    00187         , ProcessContents_Strict = 7
    00188         , Prohibited             = 8
    00189
    00190         , DefAttTypes_Count
    00191         , DefAttTypes_Min   = 0
    00192         , DefAttTypes_Max   = 8
    00193         , DefAttTypes_Unknown = -1
    00194     };
    00195
    00196     enum CreateReasons
    00197     {
    00198         NoReason
    00199         , JustFaultIn
    00200     };
    00201
    00202     // -----------------------------------------------------------------------
    00203     //  Public static data members
    00204     // -----------------------------------------------------------------------
    00205     static const unsigned int fgInvalidAttrId;
    00206
    00207
    00208     // -----------------------------------------------------------------------
    00209     //  Public, static methods
    00210     // -----------------------------------------------------------------------
    00211
    00214
    00225     static const XMLCh* getAttTypeString(const AttTypes attrType
    00226         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00227
    00238     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType
    00239         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00240
    00242
    00243
    00244     // -----------------------------------------------------------------------
    00245     //  Destructor
    00246     // -----------------------------------------------------------------------
    00247
    00250
    00254     virtual ~XMLAttDef();
    00256
    00257
    00258     // -----------------------------------------------------------------------
    00259     //  The virtual attribute def interface
    00260     // -----------------------------------------------------------------------
    00261
    00264
    00273     virtual const XMLCh* getFullName() const = 0;
    00274
    00279     virtual void reset() = 0;
    00280
    00282
    00283
    00284     // -----------------------------------------------------------------------
    00285     //  Getter methods
    00286     // -----------------------------------------------------------------------
    00287
    00290
    00299     DefAttTypes getDefaultType() const;
    00300
    00310     const XMLCh* getEnumeration() const;
    00311
    00320     unsigned int getId() const;
    00321
    00336     bool getProvided() const;
    00337
    00347     AttTypes getType() const;
    00348
    00358     const XMLCh* getValue() const;
    00359
    00368     CreateReasons getCreateReason() const;
    00369
    00377     bool isExternal() const;
    00378
    00386     MemoryManager* getMemoryManager() const;
    00387
    00388
    00393     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00394
    00399     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00400
    00402
    00403
    00404     // -----------------------------------------------------------------------
    00405     //  Setter methods
    00406     // -----------------------------------------------------------------------
    00407
    00410
    00419     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
    00420
    00429     void setId(const unsigned int newId);
    00430
    00440     void setProvided(const bool newValue);
    00441
    00449     void setType(const XMLAttDef::AttTypes newValue);
    00450
    00461     void setValue(const XMLCh* const newValue);
    00462
    00473     void setEnumeration(const XMLCh* const newValue);
    00474
    00482     void setCreateReason(const CreateReasons newReason);
    00483
    00489     void setExternalAttDeclaration(const bool aValue);
    00490
    00492
    00493     /***
    00494      * Support for Serialization/De-serialization
    00495      ***/
    00496     DECL_XSERIALIZABLE(XMLAttDef)
    00497
    00498 protected :
    00499     // -----------------------------------------------------------------------
    00500     //  Hidden constructors
    00501     // -----------------------------------------------------------------------
    00502     XMLAttDef
    00503     (
    00504         const   AttTypes       type = CData
    00505         , const DefAttTypes    defType= Implied
    00506         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00507     );
    00508     XMLAttDef
    00509     (
    00510         const   XMLCh* const        attValue
    00511         , const AttTypes            type
    00512         , const DefAttTypes         defType
    00513         , const XMLCh* const        enumValues = 0
    00514         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00515     );
    00516
    00517
    00518 private :
    00519     // -----------------------------------------------------------------------
    00520     //  Unimplemented constructors and operators
    00521     // -----------------------------------------------------------------------
    00522     XMLAttDef(const XMLAttDef&);
    00523     XMLAttDef& operator=(const XMLAttDef&);
    00524
    00525
    00526     // -----------------------------------------------------------------------
    00527     //  Private helper methods
    00528     // -----------------------------------------------------------------------
    00529     void cleanUp();
    00530
    00531
    00532     // -----------------------------------------------------------------------
    00533     //  Private data members
    00534     //
    00535     //  fDefaultType
    00536     //      Indicates what, if any, default stuff this attribute has.
    00537     //
    00538     //  fEnumeration
    00539     //      If its an enumeration, this is the list of values as space
    00540     //      separated values.
    00541     //
    00542     //  fId
    00543     //      This is the unique id of this attribute, given to it when its put
    00544     //      into the validator's attribute decl pool. It defaults to the
    00545     //      special value XMLAttrDef::fgInvalidAttrId.
    00546     //
    00547     //  fProvided
    00548     //      This field is really for use by the scanner. It is used to track
    00549     //      which of the attributes of an element were provided. Any marked
    00550     //      as not provided (after scanning the start tag) and having a
    00551     //      default type of Required, is in error.
    00552     //
    00553     //  fType
    00554     //      The type of attribute, which is one of the AttTypes values.
    00555     //
    00556     //  fValue
    00557     //      This is the value of the attribute, which is the default value
    00558     //      given in the attribute declaration.
    00559     //
    00560     //  fCreateReason
    00561     //      This flag tells us how this attribute got created.  Sometimes even
    00562     //      the attribute was not declared for the element, we want to fault
    00563     //      fault it into the pool to avoid lots of redundant errors.
    00564     //
    00565     //  fExternalAttribute
    00566     //      This flag indicates whether or not the attribute was declared externally.
    00567     // -----------------------------------------------------------------------
    00568     DefAttTypes     fDefaultType;
    00569     AttTypes        fType;
    00570     CreateReasons   fCreateReason;
    00571     bool            fProvided;
    00572     bool            fExternalAttribute;
    00573     unsigned int    fId;
    00574     XMLCh*          fValue;
    00575     XMLCh*          fEnumeration;
    00576     MemoryManager*  fMemoryManager;
    00577 };
    00578
    00579
    00580 // ---------------------------------------------------------------------------
    00581 //  Getter methods
    00582 // ---------------------------------------------------------------------------
    00583 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
    00584 {
    00585     return fDefaultType;
    00586 }
    00587
    00588 inline const XMLCh* XMLAttDef::getEnumeration() const
    00589 {
    00590     return fEnumeration;
    00591 }
    00592
    00593 inline unsigned int XMLAttDef::getId() const
    00594 {
    00595     return fId;
    00596 }
    00597
    00598 inline bool XMLAttDef::getProvided() const
    00599 {
    00600     return fProvided;
    00601 }
    00602
    00603 inline XMLAttDef::AttTypes XMLAttDef::getType() const
    00604 {
    00605     return fType;
    00606 }
    00607
    00608 inline const XMLCh* XMLAttDef::getValue() const
    00609 {
    00610     return fValue;
    00611 }
    00612
    00613 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
    00614 {
    00615     return fCreateReason;
    00616 }
    00617
    00618 inline bool XMLAttDef::isExternal() const
    00619 {
    00620     return fExternalAttribute;
    00621 }
    00622
    00623 inline MemoryManager* XMLAttDef::getMemoryManager() const
    00624 {
    00625     return fMemoryManager;
    00626 }
    00627
    00628 // ---------------------------------------------------------------------------
    00629 //  XMLAttDef: Setter methods
    00630 // ---------------------------------------------------------------------------
    00631 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
    00632 {
    00633     fDefaultType = newValue;
    00634 }
    00635
    00636 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
    00637 {
    00638     if (fEnumeration)
    00639         fMemoryManager->deallocate(fEnumeration);
    00640
    00641     fEnumeration = XMLString::replicate(newValue, fMemoryManager);
    00642 }
    00643
    00644 inline void XMLAttDef::setId(const unsigned int newId)
    00645 {
    00646     fId = newId;
    00647 }
    00648
    00649 inline void XMLAttDef::setProvided(const bool newValue)
    00650 {
    00651     fProvided = newValue;
    00652 }
    00653
    00654 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
    00655 {
    00656     fType = newValue;
    00657 }
    00658
    00659 inline void XMLAttDef::setValue(const XMLCh* const newValue)
    00660 {
    00661     if (fValue)
    00662        fMemoryManager->deallocate(fValue);
    00663
    00664     fValue = XMLString::replicate(newValue, fMemoryManager);
    00665 }
    00666
    00667 inline void
    00668 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
    00669 {
    00670     fCreateReason = newReason;
    00671 }
    00672
    00673 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
    00674 {
    00675     fExternalAttribute = aValue;
    00676 }
    00677
    00678 XERCES_CPP_NAMESPACE_END
    00679
    00680 #endif

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