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

Home

Readme
Installation
Build

API Docs
Samples
Programming
Migration
FAQs

Releases
Feedback

PDF Document

Download
Dev Snapshots
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-2000 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.6  2000/07/07 22:23:38  jpolast
00060  * remove useless getKey() functions.
00061  *
00062  * Revision 1.5  2000/02/24 20:00:22  abagchi
00063  * Swat for removing Log from API docs
00064  *
00065  * Revision 1.4  2000/02/16 23:03:48  roddey
00066  * More documentation updates
00067  *
00068  * Revision 1.3  2000/02/15 01:21:30  roddey
00069  * Some initial documentation improvements. More to come...
00070  *
00071  * Revision 1.2  2000/02/06 07:47:46  rahulj
00072  * Year 2K copyright swat.
00073  *
00074  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00075  * Initial checkin
00076  *
00077  * Revision 1.2  1999/11/08 20:44:34  rahul
00078  * Swat for adding in Product name and CVS comment log variable.
00079  *
00080  */
00081 
00082 #if !defined(ATTDEF_HPP)
00083 #define ATTDEF_HPP
00084 
00085 #include <util/XMLString.hpp>
00086 
00087 class XMLAttr;
00088 
00107 class  XMLAttDef
00108 {
00109 public:
00110     // -----------------------------------------------------------------------
00111     //  Class specific types
00112     //
00113     //  AttTypes
00114     //      The list of possible types that an attribute can have, according
00115     //      to the XML 1.0 spec.
00116     //
00117     //  DefAttTypes
00118     //      The modifiers that an attribute decl can have, which indicates
00119     //      whether instances of that attributes are required, implied, etc..
00120     // -----------------------------------------------------------------------
00121     enum AttTypes
00122     {
00123         CData               = 0
00124         , ID                = 1
00125         , IDRef             = 2
00126         , IDRefs            = 3
00127         , Entity            = 4
00128         , Entities          = 5
00129         , NmToken           = 6
00130         , NmTokens          = 7
00131         , Notation          = 8
00132         , Enumeration       = 9
00133 
00134         , AttTypes_Count
00135         , AttTypes_Min      = 0
00136         , AttTypes_Max      = 9
00137         , AttTypes_Unknown  = -1
00138     };
00139 
00140     enum DefAttTypes
00141     {
00142         Default             = 0
00143         , Required          = 1
00144         , Implied           = 2
00145         , Fixed             = 3
00146 
00147         , DefAttTypes_Count
00148         , DefAttTypes_Min   = 0
00149         , DefAttTypes_Max   = 3
00150         , DefAttTypes_Unknown = -1
00151     };
00152 
00153 
00154     // -----------------------------------------------------------------------
00155     //  Public static data members
00156     // -----------------------------------------------------------------------
00157     static const unsigned int fgInvalidAttrId;
00158 
00159 
00160     // -----------------------------------------------------------------------
00161     //  Public, static methods
00162     // -----------------------------------------------------------------------
00163 
00165     //{@
00166 
00177     static const XMLCh* getAttTypeString(const AttTypes attrType);
00178 
00189     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00190 
00191     //@}
00192 
00193 
00194     // -----------------------------------------------------------------------
00195     //  Destructor
00196     // -----------------------------------------------------------------------
00197 
00199     //@{
00200 
00204     virtual ~XMLAttDef();
00205     //@}
00206 
00207 
00208     // -----------------------------------------------------------------------
00209     //  The virtual attribute def interface
00210     // -----------------------------------------------------------------------
00211 
00213     //{@
00214 
00223     virtual const XMLCh* getFullName() const = 0;
00224 
00225     //@}
00226 
00227 
00228     // -----------------------------------------------------------------------
00229     //  Getter methods
00230     // -----------------------------------------------------------------------
00231 
00233     //{@
00234 
00243     DefAttTypes getDefaultType() const;
00244 
00254     const XMLCh* getEnumeration() const;
00255 
00264     unsigned int getId() const;
00265 
00279     bool getProvided() const;
00280 
00290     AttTypes getType() const;
00291 
00301     const XMLCh* getValue() const;
00302 
00303     //@}
00304 
00305 
00306     // -----------------------------------------------------------------------
00307     //  Setter methods
00308     // -----------------------------------------------------------------------
00309 
00311     //{@
00312 
00321     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00322 
00331     void setId(const unsigned int newId);
00332 
00341     void setProvided(const bool newValue);
00342 
00350     void setType(const XMLAttDef::AttTypes newValue);
00351 
00362     void setValue(const XMLCh* const newValue);
00363 
00374     void setEnumeration(const XMLCh* const newValue);
00375 
00376     //@}
00377 
00378 protected :
00379     // -----------------------------------------------------------------------
00380     //  Hidden constructors
00381     // -----------------------------------------------------------------------
00382     XMLAttDef
00383     (
00384         const   AttTypes            type = CData
00385         , const DefAttTypes         defType = Implied
00386     );
00387     XMLAttDef
00388     (
00389         const   XMLCh* const        attValue
00390         , const AttTypes            type
00391         , const DefAttTypes         defType
00392         , const XMLCh* const        enumValues = 0
00393     );
00394 
00395 
00396 private :
00397     // -----------------------------------------------------------------------
00398     //  Unimplemented constructors and operators
00399     // -----------------------------------------------------------------------
00400     XMLAttDef(const XMLAttDef&);
00401     void operator=(const XMLAttDef&);
00402 
00403 
00404     // -----------------------------------------------------------------------
00405     //  Private helper methods
00406     // -----------------------------------------------------------------------
00407     void cleanUp();
00408 
00409 
00410     // -----------------------------------------------------------------------
00411     //  Private data members
00412     //
00413     //  fDefaultType
00414     //      Indicates what, if any, default stuff this attribute has.
00415     //
00416     //  fEnumeration
00417     //      If its an enumeration, this is the list of values as space
00418     //      separated values.
00419     //
00420     //  fId
00421     //      This is the unique id of this attribute, given to it when its put
00422     //      into the validator's attribute decl pool. It defaults to the
00423     //      special value XMLAttrDef::fgInvalidAttrId.
00424     //
00425     //  fProvided
00426     //      This field is really for use by the scanner. It is used to track
00427     //      which of the attributes of an element were provided. Any marked
00428     //      as not provided (after scanning the start tag) and having a 
00429     //      default type of Required, is in error.
00430     //
00431     //  fType
00432     //      The type of attribute, which is one of the AttTypes values.
00433     //
00434     //  fValue
00435     //      This is the value of the attribute, which is the default value
00436     //      given in the attribute declaration.
00437     // -----------------------------------------------------------------------
00438     DefAttTypes     fDefaultType;
00439     XMLCh*          fEnumeration;
00440     unsigned int    fId;
00441     bool            fProvided;
00442     AttTypes        fType;
00443     XMLCh*          fValue;
00444 };
00445 
00446 
00447 
00448 // ---------------------------------------------------------------------------
00449 //  Getter methods
00450 // ---------------------------------------------------------------------------
00451 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00452 {
00453     return fDefaultType;
00454 }
00455 
00456 inline const XMLCh* XMLAttDef::getEnumeration() const
00457 {
00458     return fEnumeration;
00459 }
00460 
00461 inline unsigned int XMLAttDef::getId() const
00462 {
00463     return fId;
00464 }
00465 
00466 inline bool XMLAttDef::getProvided() const
00467 {
00468     return fProvided;
00469 }
00470 
00471 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00472 {
00473     return fType;
00474 }
00475 
00476 inline const XMLCh* XMLAttDef::getValue() const
00477 {
00478     return fValue;
00479 }
00480 
00481 
00482 // ---------------------------------------------------------------------------
00483 //  XMLAttDef: Setter methods
00484 // ---------------------------------------------------------------------------
00485 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00486 {
00487     fDefaultType = newValue;
00488 }
00489 
00490 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00491 {
00492     delete [] fEnumeration;
00493     fEnumeration = XMLString::replicate(newValue);
00494 }
00495 
00496 inline void XMLAttDef::setId(const unsigned int newId)
00497 {
00498     fId = newId;
00499 }
00500 
00501 inline void XMLAttDef::setProvided(const bool newValue)
00502 {
00503     fProvided = newValue;
00504 }
00505 
00506 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00507 {
00508     fType = newValue;
00509 }
00510 
00511 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00512 {
00513     delete [] fValue;
00514     fValue = XMLString::replicate(newValue);
00515 }
00516 
00517 #endif


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