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


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