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  

XMLAttr.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: XMLAttr.hpp,v $
00059  * Revision 1.9  2003/12/17 00:18:33  cargilld
00060  * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
00061  *
00062  * Revision 1.8  2003/11/24 05:19:37  neilg
00063  * update XMLAttr class to carry information needed by DOMTypeInfo
00064  *
00065  * Revision 1.7  2003/05/22 02:10:51  knoaman
00066  * Default the memory manager.
00067  *
00068  * Revision 1.6  2003/05/16 21:36:55  knoaman
00069  * Memory manager implementation: Modify constructors to pass in the memory manager.
00070  *
00071  * Revision 1.5  2003/05/15 18:26:07  knoaman
00072  * Partial implementation of the configurable memory manager.
00073  *
00074  * Revision 1.4  2002/11/28 20:12:45  knoaman
00075  * Allow creating/setting of XMLAttr using a rawname (i.e. 'prefix:localpart').
00076  *
00077  * Revision 1.3  2002/11/04 15:00:21  tng
00078  * C++ Namespace Support.
00079  *
00080  * Revision 1.2  2002/02/20 18:17:01  tng
00081  * [Bug 5977] Warnings on generating apiDocs.
00082  *
00083  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
00084  * sane_include
00085  *
00086  * Revision 1.9  2001/11/02 14:21:18  knoaman
00087  * Add support for identity constraints.
00088  *
00089  * Revision 1.8  2001/05/11 13:25:31  tng
00090  * Copyright update.
00091  *
00092  * Revision 1.7  2001/02/27 18:33:55  tng
00093  * Schema: Use QName in XMLAttr.
00094  *
00095  * Revision 1.6  2000/04/10 22:42:53  roddey
00096  * Extended the buffer reuse to the QName field, to further increase
00097  * performance of attribute heavy applications.
00098  *
00099  * Revision 1.5  2000/03/02 19:54:24  roddey
00100  * This checkin includes many changes done while waiting for the
00101  * 1.1.0 code to be finished. I can't list them all here, but a list is
00102  * available elsewhere.
00103  *
00104  * Revision 1.4  2000/02/24 20:00:22  abagchi
00105  * Swat for removing Log from API docs
00106  *
00107  * Revision 1.3  2000/02/15 01:21:30  roddey
00108  * Some initial documentation improvements. More to come...
00109  *
00110  * Revision 1.2  2000/02/06 07:47:47  rahulj
00111  * Year 2K copyright swat.
00112  *
00113  * Revision 1.1.1.1  1999/11/09 01:08:28  twl
00114  * Initial checkin
00115  *
00116  * Revision 1.2  1999/11/08 20:44:35  rahul
00117  * Swat for adding in Product name and CVS comment log variable.
00118  *
00119  */
00120 
00121 #if !defined(XMLATTR_HPP)
00122 #define XMLATTR_HPP
00123 
00124 #include <xercesc/util/PlatformUtils.hpp>
00125 #include <xercesc/util/QName.hpp>
00126 #include <xercesc/framework/XMLAttDef.hpp>
00127 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
00128 
00129 XERCES_CPP_NAMESPACE_BEGIN
00130 
00152 class  XMLAttr : public XMemory
00153 {
00154 public:
00155     // -----------------------------------------------------------------------
00156     //  Constructors and Destructor
00157     // -----------------------------------------------------------------------
00160 
00168     XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00169 
00202     XMLAttr
00203     (
00204           const unsigned int        uriId
00205         , const XMLCh* const        attrName
00206         , const XMLCh* const        attrPrefix
00207         , const XMLCh* const        attrValue
00208         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00209         , const bool                specified = true
00210         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
00211         , DatatypeValidator * datatypeValidator = 0
00212         , const bool isSchema = false
00213     );
00214 
00243     XMLAttr
00244     (
00245         const unsigned int uriId
00246         , const XMLCh* const rawName
00247         , const XMLCh* const attrValue
00248         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00249         , const bool specified = true
00250         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00251         , DatatypeValidator * datatypeValidator = 0
00252         , const bool isSchema = false
00253     );
00254 
00256 
00259     ~XMLAttr();
00261 
00262 
00263     // -----------------------------------------------------------------------
00264     //  Getter methods
00265     // -----------------------------------------------------------------------
00266 
00269 
00273     QName* getAttName() const;
00274 
00279     const XMLCh* getName() const;
00280 
00285     const XMLCh* getPrefix() const;
00286 
00292     const XMLCh* getQName() const;
00293 
00298     bool getSpecified() const;
00299 
00304     XMLAttDef::AttTypes getType() const;
00305 
00311     const XMLCh* getValue() const;
00312 
00317     unsigned int getURIId() const;
00318 
00322     const XMLCh* getValidatingTypeURI() const;
00323 
00327     const XMLCh* getValidatingTypeName() const;
00328 
00330 
00331 
00332     // -----------------------------------------------------------------------
00333     //  Setter methods
00334     // -----------------------------------------------------------------------
00335 
00338 
00367     void set
00368     (
00369         const   unsigned int        uriId
00370         , const XMLCh* const        attrName
00371         , const XMLCh* const        attrPrefix
00372         , const XMLCh* const        attrValue
00373         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00374         , DatatypeValidator * datatypeValidator = 0
00375         , const bool isSchema = false
00376     );
00377 
00401     void set
00402     (
00403         const   unsigned int        uriId
00404         , const XMLCh* const        attrRawName
00405         , const XMLCh* const        attrValue
00406         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00407         , DatatypeValidator * datatypeValidator = 0
00408         , const bool isSchema = false
00409     );
00410 
00425     void setName
00426     (
00427         const   unsigned int        uriId
00428         , const XMLCh* const        attrName
00429         , const XMLCh* const        attrPrefix
00430     );
00431 
00439     void setSpecified(const bool newValue);
00440 
00449     void setType(const XMLAttDef::AttTypes newType);
00450 
00458     void setValue(const XMLCh* const newValue);
00459 
00467     void setURIId(const unsigned int uriId);
00468 
00475     void setDatatypeValidator(DatatypeValidator * datatypeValidator);
00476 
00483     void setSchemaValidated(const bool isSchema);
00484 
00486 
00487 
00488 
00489 private :
00490     // -----------------------------------------------------------------------
00491     //  Unimplemented constructors and operators
00492     // -----------------------------------------------------------------------
00493     XMLAttr(const XMLAttr&);
00494     XMLAttr& operator=(const XMLAttr&);
00495 
00496 
00497     // -----------------------------------------------------------------------
00498     //  Private, helper methods
00499     // -----------------------------------------------------------------------
00500     void cleanUp();
00501 
00502 
00503     // -----------------------------------------------------------------------
00504     //  Private instance variables
00505     //
00506     //  fAttName
00507     //      The Attribute Name;
00508     //
00509     //  fSpecified
00510     //      True if this attribute appeared in the element; else, false if
00511     //      it was defaulted from an AttDef.
00512     //
00513     //  fType
00514     //      The attribute type enum value for this attribute. Indicates what
00515     //      type of attribute it was.
00516     //
00517     //  fValue
00518     //  fValueBufSz
00519     //      The attribute value that was given in the attribute instance, and
00520     //      its current buffer size (minus one, where the null is.)
00521     //
00522     //  fMemoryManager
00523     //      The memory manager used for dynamic memory allocation/deallocation
00524     //  fDatatypeValidator
00525     //      The validator used to validate the value of this attribute.
00526     //      The attribute does not own this object, and it is only
00527     //      used in the calculation of DOMTypeInfo information.
00528     //  fIsSchemaValidated
00529     //      whether this attribute was validated by an XML Schema
00530     //
00531     // -----------------------------------------------------------------------
00532     bool                fSpecified;
00533     XMLAttDef::AttTypes fType;
00534     unsigned int        fValueBufSz;
00535     XMLCh*              fValue;
00536     QName*              fAttName;
00537     MemoryManager*      fMemoryManager;
00538     DatatypeValidator * fDatatypeValidator;
00539     bool                fIsSchemaValidated;
00540 };
00541 
00542 // ---------------------------------------------------------------------------
00543 //  XMLAttr: Constructors and Destructor
00544 // ---------------------------------------------------------------------------
00545 inline XMLAttr::~XMLAttr()
00546 {
00547     cleanUp();
00548 }
00549 
00550 
00551 // ---------------------------------------------------------------------------
00552 //  XMLAttr: Getter methods
00553 // ---------------------------------------------------------------------------
00554 inline QName* XMLAttr::getAttName() const
00555 {
00556     return fAttName;
00557 }
00558 
00559 inline const XMLCh* XMLAttr::getName() const
00560 {
00561     return fAttName->getLocalPart();
00562 }
00563 
00564 inline const XMLCh* XMLAttr::getPrefix() const
00565 {
00566     return fAttName->getPrefix();
00567 }
00568 
00569 inline bool XMLAttr::getSpecified() const
00570 {
00571     return fSpecified;
00572 }
00573 
00574 inline XMLAttDef::AttTypes XMLAttr::getType() const
00575 {
00576     return fType;
00577 }
00578 
00579 inline const XMLCh* XMLAttr::getValue() const
00580 {
00581     return fValue;
00582 }
00583 
00584 inline unsigned int XMLAttr::getURIId() const
00585 {
00586     return fAttName->getURI();
00587 }
00588 
00589 inline const XMLCh* XMLAttr::getValidatingTypeName() const
00590 {
00591     if(fIsSchemaValidated)
00592     {
00593         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00594             return 0; 
00595         return fDatatypeValidator->getTypeLocalName();
00596     }
00597     else
00598     {
00599         return XMLAttDef::getAttTypeString(fType, fMemoryManager);
00600     }
00601 }
00602 
00603 inline const XMLCh* XMLAttr::getValidatingTypeURI() const
00604 {
00605     if(fIsSchemaValidated)
00606     {
00607         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00608             return 0; 
00609         return fDatatypeValidator->getTypeUri();
00610     }
00611     else
00612     {
00613         return 0;
00614     }
00615 }
00616 
00617 // ---------------------------------------------------------------------------
00618 //  XMLAttr: Setter methods
00619 // ---------------------------------------------------------------------------
00620 inline void XMLAttr::set(const  unsigned int        uriId
00621                         , const XMLCh* const        attrName
00622                         , const XMLCh* const        attrPrefix
00623                         , const XMLCh* const        attrValue
00624                         , const XMLAttDef::AttTypes type
00625                         , DatatypeValidator * datatypeValidator 
00626                         , const bool isSchema )
00627 {
00628     // Set the name info and the value via their respective calls
00629     fAttName->setName(attrPrefix, attrName, uriId);
00630     setValue(attrValue);
00631 
00632     // And store the type
00633     fType = type;
00634 
00635     // and set up info for DOM type info 
00636     fIsSchemaValidated = isSchema;
00637     fDatatypeValidator = datatypeValidator;
00638 }
00639 
00640 inline void XMLAttr::set(const  unsigned int        uriId
00641                         , const XMLCh* const        attrRawName
00642                         , const XMLCh* const        attrValue
00643                         , const XMLAttDef::AttTypes type
00644                         , DatatypeValidator * datatypeValidator 
00645                         , const bool isSchema )
00646 {
00647     // Set the name info and the value via their respective calls
00648     fAttName->setName(attrRawName, uriId);
00649     setValue(attrValue);
00650 
00651     // And store the type
00652     fType = type;
00653 
00654     // and set up info for DOM type info 
00655     fIsSchemaValidated = isSchema;
00656     fDatatypeValidator = datatypeValidator;
00657 }
00658 
00659 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00660 {
00661     fType = newValue;
00662 }
00663 
00664 inline void XMLAttr::setSpecified(const bool newValue)
00665 {
00666     fSpecified = newValue;
00667 }
00668 
00669 inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
00670 {
00671     fDatatypeValidator = datatypeValidator;
00672 }
00673 
00674 inline void XMLAttr::setSchemaValidated(const bool isSchema)
00675 {
00676     fIsSchemaValidated = isSchema;
00677 }
00678 
00679 XERCES_CPP_NAMESPACE_END
00680 
00681 #endif


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