Main Page   Class Hierarchy   Compound List   File List   Compound Members  

XMLAttDef.hpp

00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 1999-2001 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.1  2002/05/11 20:00:30  bhavani
00060  * CR#CR062582# adding xercesc 1.7 file
00061  *
00062  * Revision 1.2  2002/02/20 18:17:01  tng
00063  * [Bug 5977] Warnings on generating apiDocs.
00064  *
00065  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
00066  * sane_include
00067  *
00068  * Revision 1.13  2001/11/15 16:36:36  knoaman
00069  * Re-organize constant values.
00070  *
00071  * Revision 1.12  2001/08/09 15:23:37  knoaman
00072  * add support for <anyAttribute> declaration.
00073  *
00074  * Revision 1.11  2001/06/21 14:25:26  knoaman
00075  * Fix for bug 1946
00076  *
00077  * Revision 1.10  2001/05/11 13:25:31  tng
00078  * Copyright update.
00079  *
00080  * Revision 1.9  2001/02/27 18:48:20  tng
00081  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
00082  *
00083  * Revision 1.8  2000/12/14 18:49:56  tng
00084  * Fix API document generation warning: "Warning: end of member group without matching begin"
00085  *
00086  * Revision 1.7  2000/11/30 18:22:38  andyh
00087  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
00088  * pools already containing some items.  Fixed by Tinny Ng.
00089  *
00090  * Revision 1.6  2000/07/07 22:23:38  jpolast
00091  * remove useless getKey() functions.
00092  *
00093  * Revision 1.5  2000/02/24 20:00:22  abagchi
00094  * Swat for removing Log from API docs
00095  *
00096  * Revision 1.4  2000/02/16 23:03:48  roddey
00097  * More documentation updates
00098  *
00099  * Revision 1.3  2000/02/15 01:21:30  roddey
00100  * Some initial documentation improvements. More to come...
00101  *
00102  * Revision 1.2  2000/02/06 07:47:46  rahulj
00103  * Year 2K copyright swat.
00104  *
00105  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00106  * Initial checkin
00107  *
00108  * Revision 1.2  1999/11/08 20:44:34  rahul
00109  * Swat for adding in Product name and CVS comment log variable.
00110  *
00111  */
00112 
00113 #if !defined(ATTDEF_HPP)
00114 #define ATTDEF_HPP
00115 
00116 #include <xercesc/util/XMLString.hpp>
00117 
00118 class XMLAttr;
00119 
00138 class XMLPARSER_EXPORT XMLAttDef
00139 {
00140 public:
00141     // -----------------------------------------------------------------------
00142     //  Class specific types
00143     //
00144     //  AttTypes
00145     //      The list of possible types that an attribute can have, according
00146     //      to the XML 1.0 spec and schema.
00147     //
00148     //  DefAttTypes
00149     //      The modifiers that an attribute decl can have, which indicates
00150     //      whether instances of that attributes are required, implied, etc..
00151     //
00152     //  CreateReasons
00153     //      This type is used to store how an attribute declaration got into
00154     //      the elementdecl's attribute pool.
00155     //
00156     // -----------------------------------------------------------------------
00157         enum AttTypes
00158     {
00159         CData               = 0
00160         , ID                = 1
00161         , IDRef             = 2
00162         , IDRefs            = 3
00163         , Entity            = 4
00164         , Entities          = 5
00165         , NmToken           = 6
00166         , NmTokens          = 7
00167         , Notation          = 8
00168         , Enumeration       = 9
00169         , Simple            = 10
00170         , Any_Any           = 11
00171         , Any_Other         = 12
00172         , Any_List          = 13
00173 
00174         , AttTypes_Count
00175         , AttTypes_Min      = 0
00176         , AttTypes_Max      = 13
00177         , AttTypes_Unknown  = -1
00178         };
00179 
00180     enum DefAttTypes
00181     {
00182         Default                  = 0
00183         , Fixed                  = 1
00184         , Required               = 2
00185         , Required_And_Fixed     = 3
00186         , Implied                = 4
00187         , ProcessContents_Strict = 5
00188         , ProcessContents_Lax    = 6
00189         , ProcessContents_Skip   = 7
00190         , Prohibited             = 8
00191 
00192         , DefAttTypes_Count
00193         , DefAttTypes_Min   = 0
00194         , DefAttTypes_Max   = 8
00195         , DefAttTypes_Unknown = -1
00196         };
00197 
00198     enum CreateReasons
00199     {
00200         NoReason
00201         , JustFaultIn
00202     };
00203 
00204     // -----------------------------------------------------------------------
00205     //  Public static data members
00206     // -----------------------------------------------------------------------
00207     static const unsigned int fgInvalidAttrId;
00208 
00209 
00210     // -----------------------------------------------------------------------
00211     //  Public, static methods
00212     // -----------------------------------------------------------------------
00213 
00216 
00227     static const XMLCh* getAttTypeString(const AttTypes attrType);
00228 
00239     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
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 
00276 
00277 
00278     // -----------------------------------------------------------------------
00279     //  Getter methods
00280     // -----------------------------------------------------------------------
00281 
00284 
00293     DefAttTypes getDefaultType() const;
00294 
00304     const XMLCh* getEnumeration() const;
00305 
00314     unsigned int getId() const;
00315 
00329     bool getProvided() const;
00330 
00340     AttTypes getType() const;
00341 
00351     const XMLCh* getValue() const;
00352 
00361     CreateReasons getCreateReason() const;
00362 
00370     bool isExternal() const;
00371 
00373 
00374 
00375     // -----------------------------------------------------------------------
00376     //  Setter methods
00377     // -----------------------------------------------------------------------
00378 
00381 
00390     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00391 
00400     void setId(const unsigned int newId);
00401 
00410     void setProvided(const bool newValue);
00411 
00419     void setType(const XMLAttDef::AttTypes newValue);
00420 
00431     void setValue(const XMLCh* const newValue);
00432 
00443     void setEnumeration(const XMLCh* const newValue);
00444 
00452     void setCreateReason(const CreateReasons newReason);
00453 
00459     void setExternalAttDeclaration(const bool aValue);
00460 
00462 
00463 protected :
00464     // -----------------------------------------------------------------------
00465     //  Hidden constructors
00466     // -----------------------------------------------------------------------
00467     XMLAttDef
00468     (
00469         const   AttTypes            type = CData
00470         , const DefAttTypes         defType = Implied
00471     );
00472     XMLAttDef
00473     (
00474         const   XMLCh* const        attValue
00475         , const AttTypes            type
00476         , const DefAttTypes         defType
00477         , const XMLCh* const        enumValues = 0
00478     );
00479 
00480 
00481 private :
00482     // -----------------------------------------------------------------------
00483     //  Unimplemented constructors and operators
00484     // -----------------------------------------------------------------------
00485     XMLAttDef(const XMLAttDef&);
00486     void operator=(const XMLAttDef&);
00487 
00488 
00489     // -----------------------------------------------------------------------
00490     //  Private helper methods
00491     // -----------------------------------------------------------------------
00492     void cleanUp();
00493 
00494 
00495     // -----------------------------------------------------------------------
00496     //  Private data members
00497     //
00498     //  fDefaultType
00499     //      Indicates what, if any, default stuff this attribute has.
00500     //
00501     //  fEnumeration
00502     //      If its an enumeration, this is the list of values as space
00503     //      separated values.
00504     //
00505     //  fId
00506     //      This is the unique id of this attribute, given to it when its put
00507     //      into the validator's attribute decl pool. It defaults to the
00508     //      special value XMLAttrDef::fgInvalidAttrId.
00509     //
00510     //  fProvided
00511     //      This field is really for use by the scanner. It is used to track
00512     //      which of the attributes of an element were provided. Any marked
00513     //      as not provided (after scanning the start tag) and having a
00514     //      default type of Required, is in error.
00515     //
00516     //  fType
00517     //      The type of attribute, which is one of the AttTypes values.
00518     //
00519     //  fValue
00520     //      This is the value of the attribute, which is the default value
00521     //      given in the attribute declaration.
00522     //
00523     //  fCreateReason
00524     //      This flag tells us how this attribute got created.  Sometimes even
00525     //      the attribute was not declared for the element, we want to fault
00526     //      fault it into the pool to avoid lots of redundant errors.
00527     //
00528     //  fExternalAttribute
00529     //      This flag indicates whether or not the attribute was declared externally.
00530     // -----------------------------------------------------------------------
00531     DefAttTypes     fDefaultType;
00532     XMLCh*          fEnumeration;
00533     unsigned int    fId;
00534     bool            fProvided;
00535     AttTypes        fType;
00536     XMLCh*          fValue;
00537     CreateReasons   fCreateReason;
00538     bool            fExternalAttribute;
00539 };
00540 
00541 
00542 
00543 // ---------------------------------------------------------------------------
00544 //  Getter methods
00545 // ---------------------------------------------------------------------------
00546 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00547 {
00548     return fDefaultType;
00549 }
00550 
00551 inline const XMLCh* XMLAttDef::getEnumeration() const
00552 {
00553     return fEnumeration;
00554 }
00555 
00556 inline unsigned int XMLAttDef::getId() const
00557 {
00558     return fId;
00559 }
00560 
00561 inline bool XMLAttDef::getProvided() const
00562 {
00563     return fProvided;
00564 }
00565 
00566 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00567 {
00568     return fType;
00569 }
00570 
00571 inline const XMLCh* XMLAttDef::getValue() const
00572 {
00573     return fValue;
00574 }
00575 
00576 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
00577 {
00578     return fCreateReason;
00579 }
00580 
00581 inline bool XMLAttDef::isExternal() const
00582 {
00583     return fExternalAttribute;
00584 }
00585 
00586 
00587 // ---------------------------------------------------------------------------
00588 //  XMLAttDef: Setter methods
00589 // ---------------------------------------------------------------------------
00590 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00591 {
00592     fDefaultType = newValue;
00593 }
00594 
00595 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00596 {
00597     delete [] fEnumeration;
00598 
00599     if (newValue) {
00600         fEnumeration = XMLString::replicate(newValue);
00601     }
00602     else {
00603         fEnumeration = 0;
00604     }
00605 }
00606 
00607 inline void XMLAttDef::setId(const unsigned int newId)
00608 {
00609     fId = newId;
00610 }
00611 
00612 inline void XMLAttDef::setProvided(const bool newValue)
00613 {
00614     fProvided = newValue;
00615 }
00616 
00617 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00618 {
00619     fType = newValue;
00620 }
00621 
00622 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00623 {
00624     delete [] fValue;
00625     fValue = XMLString::replicate(newValue);
00626 }
00627 
00628 inline void
00629 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
00630 {
00631     fCreateReason = newReason;
00632 }
00633 
00634 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
00635 {
00636     fExternalAttribute = aValue;
00637 }
00638 
00639 #endif

Generated on Tue Nov 19 09:36:34 2002 by doxygen1.3-rc1