http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

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  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
00005  * reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in
00016  *    the documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  * 3. The end-user documentation included with the redistribution,
00020  *    if any, must include the following acknowledgment:
00021  *       "This product includes software developed by the
00022  *        Apache Software Foundation (http://www.apache.org/)."
00023  *    Alternately, this acknowledgment may appear in the software itself,
00024  *    if and wherever such third-party acknowledgments normally appear.
00025  *
00026  * 4. The names "Xerces" and "Apache Software Foundation" must
00027  *    not be used to endorse or promote products derived from this
00028  *    software without prior written permission. For written
00029  *    permission, please contact apache\@apache.org.
00030  *
00031  * 5. Products derived from this software may not be called "Apache",
00032  *    nor may "Apache" appear in their name, without prior written
00033  *    permission of the Apache Software Foundation.
00034  *
00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  * ====================================================================
00048  *
00049  * This software consists of voluntary contributions made by many
00050  * individuals on behalf of the Apache Software Foundation, and was
00051  * originally based on software copyright (c) 1999, International
00052  * Business Machines, Inc., http://www.ibm.com .  For more information
00053  * on the Apache Software Foundation, please see
00054  * <http://www.apache.org/>.
00055  */
00056 
00057 /*
00058  * $Log: XMLAttDef.hpp,v $
00059  * Revision 1.11  2003/11/24 05:19:15  neilg
00060  * update method documentation
00061  *
00062  * Revision 1.10  2003/10/10 16:23:29  peiyongz
00063  * Implementation of Serialization/Deserialization
00064  *
00065  * Revision 1.9  2003/05/16 21:36:55  knoaman
00066  * Memory manager implementation: Modify constructors to pass in the memory manager.
00067  *
00068  * Revision 1.8  2003/05/15 18:26:07  knoaman
00069  * Partial implementation of the configurable memory manager.
00070  *
00071  * Revision 1.7  2003/04/21 20:46:01  knoaman
00072  * Use XMLString::release to prepare for configurable memory manager.
00073  *
00074  * Revision 1.6  2003/03/07 18:08:10  tng
00075  * Return a reference instead of void for operator=
00076  *
00077  * Revision 1.5  2003/01/29 19:45:35  gareth
00078  * added api for DOMTypeInfo
00079  *
00080  * Revision 1.4  2002/12/10 02:15:55  knoaman
00081  * Schema Errata: E1-21.
00082  *
00083  * Revision 1.3  2002/11/04 15:00:21  tng
00084  * C++ Namespace Support.
00085  *
00086  * Revision 1.2  2002/02/20 18:17:01  tng
00087  * [Bug 5977] Warnings on generating apiDocs.
00088  *
00089  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
00090  * sane_include
00091  *
00092  * Revision 1.13  2001/11/15 16:36:36  knoaman
00093  * Re-organize constant values.
00094  *
00095  * Revision 1.12  2001/08/09 15:23:37  knoaman
00096  * add support for <anyAttribute> declaration.
00097  *
00098  * Revision 1.11  2001/06/21 14:25:26  knoaman
00099  * Fix for bug 1946
00100  *
00101  * Revision 1.10  2001/05/11 13:25:31  tng
00102  * Copyright update.
00103  *
00104  * Revision 1.9  2001/02/27 18:48:20  tng
00105  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
00106  *
00107  * Revision 1.8  2000/12/14 18:49:56  tng
00108  * Fix API document generation warning: "Warning: end of member group without matching begin"
00109  *
00110  * Revision 1.7  2000/11/30 18:22:38  andyh
00111  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
00112  * pools already containing some items.  Fixed by Tinny Ng.
00113  *
00114  * Revision 1.6  2000/07/07 22:23:38  jpolast
00115  * remove useless getKey() functions.
00116  *
00117  * Revision 1.5  2000/02/24 20:00:22  abagchi
00118  * Swat for removing Log from API docs
00119  *
00120  * Revision 1.4  2000/02/16 23:03:48  roddey
00121  * More documentation updates
00122  *
00123  * Revision 1.3  2000/02/15 01:21:30  roddey
00124  * Some initial documentation improvements. More to come...
00125  *
00126  * Revision 1.2  2000/02/06 07:47:46  rahulj
00127  * Year 2K copyright swat.
00128  *
00129  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00130  * Initial checkin
00131  *
00132  * Revision 1.2  1999/11/08 20:44:34  rahul
00133  * Swat for adding in Product name and CVS comment log variable.
00134  *
00135  */
00136 
00137 #if !defined(ATTDEF_HPP)
00138 #define ATTDEF_HPP
00139 
00140 #include <xercesc/util/PlatformUtils.hpp>
00141 #include <xercesc/util/XMLString.hpp>
00142 #include <xercesc/util/XMemory.hpp>
00143 #include <xercesc/internal/XSerializable.hpp>
00144 
00145 XERCES_CPP_NAMESPACE_BEGIN
00146 
00147 class XMLAttr;
00148 
00167 class  XMLAttDef : public XSerializable, public XMemory
00168 {
00169 public:
00170     // -----------------------------------------------------------------------
00171     //  Class specific types
00172     //
00173     //  AttTypes
00174     //      The list of possible types that an attribute can have, according
00175     //      to the XML 1.0 spec and schema.
00176     //
00177     //  DefAttTypes
00178     //      The modifiers that an attribute decl can have, which indicates
00179     //      whether instances of that attributes are required, implied, etc..
00180     //
00181     //  CreateReasons
00182     //      This type is used to store how an attribute declaration got into
00183     //      the elementdecl's attribute pool.
00184     //
00185     // -----------------------------------------------------------------------
00186     enum AttTypes
00187     {
00188         CData               = 0
00189         , ID                = 1
00190         , IDRef             = 2
00191         , IDRefs            = 3
00192         , Entity            = 4
00193         , Entities          = 5
00194         , NmToken           = 6
00195         , NmTokens          = 7
00196         , Notation          = 8
00197         , Enumeration       = 9
00198         , Simple            = 10
00199         , Any_Any           = 11
00200         , Any_Other         = 12
00201         , Any_List          = 13
00202 
00203         , AttTypes_Count
00204         , AttTypes_Min      = 0
00205         , AttTypes_Max      = 13
00206         , AttTypes_Unknown  = -1
00207     };
00208 
00209     enum DefAttTypes
00210     {
00211         Default                  = 0
00212         , Fixed                  = 1
00213         , Required               = 2
00214         , Required_And_Fixed     = 3
00215         , Implied                = 4
00216         , ProcessContents_Skip   = 5
00217         , ProcessContents_Lax    = 6
00218         , ProcessContents_Strict = 7
00219         , Prohibited             = 8
00220 
00221         , DefAttTypes_Count
00222         , DefAttTypes_Min   = 0
00223         , DefAttTypes_Max   = 8
00224         , DefAttTypes_Unknown = -1
00225     };
00226 
00227     enum CreateReasons
00228     {
00229         NoReason
00230         , JustFaultIn
00231     };
00232 
00233     // -----------------------------------------------------------------------
00234     //  Public static data members
00235     // -----------------------------------------------------------------------
00236     static const unsigned int fgInvalidAttrId;
00237 
00238 
00239     // -----------------------------------------------------------------------
00240     //  Public, static methods
00241     // -----------------------------------------------------------------------
00242 
00245 
00256     static const XMLCh* getAttTypeString(const AttTypes attrType);
00257 
00268     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00269 
00271 
00272 
00273     // -----------------------------------------------------------------------
00274     //  Destructor
00275     // -----------------------------------------------------------------------
00276 
00279 
00283     virtual ~XMLAttDef();
00285 
00286 
00287     // -----------------------------------------------------------------------
00288     //  The virtual attribute def interface
00289     // -----------------------------------------------------------------------
00290 
00293 
00302     virtual const XMLCh* getFullName() const = 0;
00303 
00308     virtual void reset() = 0;
00309 
00311 
00312 
00313     // -----------------------------------------------------------------------
00314     //  Getter methods
00315     // -----------------------------------------------------------------------
00316 
00319 
00328     DefAttTypes getDefaultType() const;
00329 
00339     const XMLCh* getEnumeration() const;
00340 
00349     unsigned int getId() const;
00350 
00365     bool getProvided() const;
00366 
00376     AttTypes getType() const;
00377 
00387     const XMLCh* getValue() const;
00388 
00397     CreateReasons getCreateReason() const;
00398 
00406     bool isExternal() const;
00407 
00415     MemoryManager* getMemoryManager() const;
00416 
00417 
00422     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
00423 
00428     virtual const XMLCh* getDOMTypeInfoName() const = 0;
00429 
00431 
00432 
00433     // -----------------------------------------------------------------------
00434     //  Setter methods
00435     // -----------------------------------------------------------------------
00436 
00439 
00448     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00449 
00458     void setId(const unsigned int newId);
00459 
00469     void setProvided(const bool newValue);
00470 
00478     void setType(const XMLAttDef::AttTypes newValue);
00479 
00490     void setValue(const XMLCh* const newValue);
00491 
00502     void setEnumeration(const XMLCh* const newValue);
00503 
00511     void setCreateReason(const CreateReasons newReason);
00512 
00518     void setExternalAttDeclaration(const bool aValue);
00519 
00521 
00522     /***
00523      * Support for Serialization/De-serialization
00524      ***/
00525     DECL_XSERIALIZABLE(XMLAttDef)
00526 
00527 protected :
00528     // -----------------------------------------------------------------------
00529     //  Hidden constructors
00530     // -----------------------------------------------------------------------
00531     XMLAttDef
00532     (
00533         const   AttTypes       type = CData
00534         , const DefAttTypes    defType= Implied
00535         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00536     );
00537     XMLAttDef
00538     (
00539         const   XMLCh* const        attValue
00540         , const AttTypes            type
00541         , const DefAttTypes         defType
00542         , const XMLCh* const        enumValues = 0
00543         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00544     );
00545 
00546 
00547 private :
00548     // -----------------------------------------------------------------------
00549     //  Unimplemented constructors and operators
00550     // -----------------------------------------------------------------------
00551     XMLAttDef(const XMLAttDef&);
00552     XMLAttDef& operator=(const XMLAttDef&);
00553 
00554 
00555     // -----------------------------------------------------------------------
00556     //  Private helper methods
00557     // -----------------------------------------------------------------------
00558     void cleanUp();
00559 
00560 
00561     // -----------------------------------------------------------------------
00562     //  Private data members
00563     //
00564     //  fDefaultType
00565     //      Indicates what, if any, default stuff this attribute has.
00566     //
00567     //  fEnumeration
00568     //      If its an enumeration, this is the list of values as space
00569     //      separated values.
00570     //
00571     //  fId
00572     //      This is the unique id of this attribute, given to it when its put
00573     //      into the validator's attribute decl pool. It defaults to the
00574     //      special value XMLAttrDef::fgInvalidAttrId.
00575     //
00576     //  fProvided
00577     //      This field is really for use by the scanner. It is used to track
00578     //      which of the attributes of an element were provided. Any marked
00579     //      as not provided (after scanning the start tag) and having a
00580     //      default type of Required, is in error.
00581     //
00582     //  fType
00583     //      The type of attribute, which is one of the AttTypes values.
00584     //
00585     //  fValue
00586     //      This is the value of the attribute, which is the default value
00587     //      given in the attribute declaration.
00588     //
00589     //  fCreateReason
00590     //      This flag tells us how this attribute got created.  Sometimes even
00591     //      the attribute was not declared for the element, we want to fault
00592     //      fault it into the pool to avoid lots of redundant errors.
00593     //
00594     //  fExternalAttribute
00595     //      This flag indicates whether or not the attribute was declared externally.
00596     // -----------------------------------------------------------------------
00597     DefAttTypes     fDefaultType;
00598     AttTypes        fType;
00599     CreateReasons   fCreateReason;
00600     bool            fProvided;
00601     bool            fExternalAttribute;
00602     unsigned int    fId;
00603     XMLCh*          fValue;
00604     XMLCh*          fEnumeration;
00605     MemoryManager*  fMemoryManager;
00606 };
00607 
00608 
00609 // ---------------------------------------------------------------------------
00610 //  Getter methods
00611 // ---------------------------------------------------------------------------
00612 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00613 {
00614     return fDefaultType;
00615 }
00616 
00617 inline const XMLCh* XMLAttDef::getEnumeration() const
00618 {
00619     return fEnumeration;
00620 }
00621 
00622 inline unsigned int XMLAttDef::getId() const
00623 {
00624     return fId;
00625 }
00626 
00627 inline bool XMLAttDef::getProvided() const
00628 {
00629     return fProvided;
00630 }
00631 
00632 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00633 {
00634     return fType;
00635 }
00636 
00637 inline const XMLCh* XMLAttDef::getValue() const
00638 {
00639     return fValue;
00640 }
00641 
00642 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
00643 {
00644     return fCreateReason;
00645 }
00646 
00647 inline bool XMLAttDef::isExternal() const
00648 {
00649     return fExternalAttribute;
00650 }
00651 
00652 inline MemoryManager* XMLAttDef::getMemoryManager() const
00653 {
00654     return fMemoryManager;
00655 }
00656 
00657 // ---------------------------------------------------------------------------
00658 //  XMLAttDef: Setter methods
00659 // ---------------------------------------------------------------------------
00660 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00661 {
00662     fDefaultType = newValue;
00663 }
00664 
00665 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00666 {
00667     if (fEnumeration)
00668         fMemoryManager->deallocate(fEnumeration);
00669 
00670     fEnumeration = XMLString::replicate(newValue, fMemoryManager);
00671 }
00672 
00673 inline void XMLAttDef::setId(const unsigned int newId)
00674 {
00675     fId = newId;
00676 }
00677 
00678 inline void XMLAttDef::setProvided(const bool newValue)
00679 {
00680     fProvided = newValue;
00681 }
00682 
00683 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00684 {
00685     fType = newValue;
00686 }
00687 
00688 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00689 {
00690     if (fValue)
00691        fMemoryManager->deallocate(fValue);
00692 
00693     fValue = XMLString::replicate(newValue, fMemoryManager);
00694 }
00695 
00696 inline void
00697 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
00698 {
00699     fCreateReason = newReason;
00700 }
00701 
00702 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
00703 {
00704     fExternalAttribute = aValue;
00705 }
00706 
00707 XERCES_CPP_NAMESPACE_END
00708 
00709 #endif


Copyright © 2003 The Apache Software Foundation. All Rights Reserved.