XMLAttr.hpp Source File

| 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.7  2003/05/22 02:10:51  knoaman
    00060  * Default the memory manager.
    00061  *
    00062  * Revision 1.6  2003/05/16 21:36:55  knoaman
    00063  * Memory manager implementation: Modify constructors to pass in the memory manager.
    00064  *
    00065  * Revision 1.5  2003/05/15 18:26:07  knoaman
    00066  * Partial implementation of the configurable memory manager.
    00067  *
    00068  * Revision 1.4  2002/11/28 20:12:45  knoaman
    00069  * Allow creating/setting of XMLAttr using a rawname (i.e. 'prefix:localpart').
    00070  *
    00071  * Revision 1.3  2002/11/04 15:00:21  tng
    00072  * C++ Namespace Support.
    00073  *
    00074  * Revision 1.2  2002/02/20 18:17:01  tng
    00075  * [Bug 5977] Warnings on generating apiDocs.
    00076  *
    00077  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
    00078  * sane_include
    00079  *
    00080  * Revision 1.9  2001/11/02 14:21:18  knoaman
    00081  * Add support for identity constraints.
    00082  *
    00083  * Revision 1.8  2001/05/11 13:25:31  tng
    00084  * Copyright update.
    00085  *
    00086  * Revision 1.7  2001/02/27 18:33:55  tng
    00087  * Schema: Use QName in XMLAttr.
    00088  *
    00089  * Revision 1.6  2000/04/10 22:42:53  roddey
    00090  * Extended the buffer reuse to the QName field, to further increase
    00091  * performance of attribute heavy applications.
    00092  *
    00093  * Revision 1.5  2000/03/02 19:54:24  roddey
    00094  * This checkin includes many changes done while waiting for the
    00095  * 1.1.0 code to be finished. I can't list them all here, but a list is
    00096  * available elsewhere.
    00097  *
    00098  * Revision 1.4  2000/02/24 20:00:22  abagchi
    00099  * Swat for removing Log from API docs
    00100  *
    00101  * Revision 1.3  2000/02/15 01:21:30  roddey
    00102  * Some initial documentation improvements. More to come...
    00103  *
    00104  * Revision 1.2  2000/02/06 07:47:47  rahulj
    00105  * Year 2K copyright swat.
    00106  *
    00107  * Revision 1.1.1.1  1999/11/09 01:08:28  twl
    00108  * Initial checkin
    00109  *
    00110  * Revision 1.2  1999/11/08 20:44:35  rahul
    00111  * Swat for adding in Product name and CVS comment log variable.
    00112  *
    00113  */
    00114
    00115 #if !defined(XMLATTR_HPP)
    00116 #define XMLATTR_HPP
    00117
    00118 #include <xercesc/util/PlatformUtils.hpp>
    00119 #include <xercesc/util/QName.hpp>
    00120 #include <xercesc/framework/XMLAttDef.hpp>
    00121
    00122 XERCES_CPP_NAMESPACE_BEGIN
    00123
    00145 class  XMLAttr : public XMemory
    00146 {
    00147 public:
    00148     // -----------------------------------------------------------------------
    00149     //  Constructors and Destructor
    00150     // -----------------------------------------------------------------------
    00153
    00161     XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00162
    00191     XMLAttr
    00192     (
    00193           const unsigned int        uriId
    00194         , const XMLCh* const        attrName
    00195         , const XMLCh* const        attrPrefix
    00196         , const XMLCh* const        attrValue
    00197         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00198         , const bool                specified = true
    00199         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
    00200     );
    00201
    00226     XMLAttr
    00227     (
    00228         const unsigned int uriId
    00229         , const XMLCh* const rawName
    00230         , const XMLCh* const attrValue
    00231         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00232         , const bool specified = true
    00233         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00234     );
    00235
    00237
    00240     ~XMLAttr();
    00242
    00243
    00244     // -----------------------------------------------------------------------
    00245     //  Getter methods
    00246     // -----------------------------------------------------------------------
    00247
    00250
    00254     QName* getAttName() const;
    00255
    00260     const XMLCh* getName() const;
    00261
    00266     const XMLCh* getPrefix() const;
    00267
    00273     const XMLCh* getQName() const;
    00274
    00279     bool getSpecified() const;
    00280
    00285     XMLAttDef::AttTypes getType() const;
    00286
    00292     const XMLCh* getValue() const;
    00293
    00298     unsigned int getURIId() const;
    00299
    00301
    00302
    00303     // -----------------------------------------------------------------------
    00304     //  Setter methods
    00305     // -----------------------------------------------------------------------
    00306
    00309
    00334     void set
    00335     (
    00336         const   unsigned int        uriId
    00337         , const XMLCh* const        attrName
    00338         , const XMLCh* const        attrPrefix
    00339         , const XMLCh* const        attrValue
    00340         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00341     );
    00342
    00363     void set
    00364     (
    00365         const   unsigned int        uriId
    00366         , const XMLCh* const        attrRawName
    00367         , const XMLCh* const        attrValue
    00368         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00369     );
    00370
    00385     void setName
    00386     (
    00387         const   unsigned int        uriId
    00388         , const XMLCh* const        attrName
    00389         , const XMLCh* const        attrPrefix
    00390     );
    00391
    00399     void setSpecified(const bool newValue);
    00400
    00409     void setType(const XMLAttDef::AttTypes newType);
    00410
    00418     void setValue(const XMLCh* const newValue);
    00419
    00427     void setURIId(const unsigned int uriId);
    00428
    00430
    00431
    00432
    00433 private :
    00434     // -----------------------------------------------------------------------
    00435     //  Unimplemented constructors and operators
    00436     // -----------------------------------------------------------------------
    00437     XMLAttr(const XMLAttr&);
    00438     XMLAttr& operator=(const XMLAttr&);
    00439
    00440
    00441     // -----------------------------------------------------------------------
    00442     //  Private, helper methods
    00443     // -----------------------------------------------------------------------
    00444     void cleanUp();
    00445
    00446
    00447     // -----------------------------------------------------------------------
    00448     //  Private instance variables
    00449     //
    00450     //  fAttName
    00451     //      The Attribute Name;
    00452     //
    00453     //  fSpecified
    00454     //      True if this attribute appeared in the element; else, false if
    00455     //      it was defaulted from an AttDef.
    00456     //
    00457     //  fType
    00458     //      The attribute type enum value for this attribute. Indicates what
    00459     //      type of attribute it was.
    00460     //
    00461     //  fValue
    00462     //  fValueBufSz
    00463     //      The attribute value that was given in the attribute instance, and
    00464     //      its current buffer size (minus one, where the null is.)
    00465     //
    00466     //  fMemoryManager
    00467     //      The memory manager used for dynamic memory allocation/deallocation
    00468     //
    00469     // -----------------------------------------------------------------------
    00470     bool                fSpecified;
    00471     XMLAttDef::AttTypes fType;
    00472     unsigned int        fValueBufSz;
    00473     XMLCh*              fValue;
    00474     QName*              fAttName;
    00475     MemoryManager*      fMemoryManager;
    00476 };
    00477
    00478 // ---------------------------------------------------------------------------
    00479 //  XMLAttr: Constructors and Destructor
    00480 // ---------------------------------------------------------------------------
    00481 inline XMLAttr::~XMLAttr()
    00482 {
    00483     cleanUp();
    00484 }
    00485
    00486
    00487 // ---------------------------------------------------------------------------
    00488 //  XMLAttr: Getter methods
    00489 // ---------------------------------------------------------------------------
    00490 inline QName* XMLAttr::getAttName() const
    00491 {
    00492     return fAttName;
    00493 }
    00494
    00495 inline const XMLCh* XMLAttr::getName() const
    00496 {
    00497     return fAttName->getLocalPart();
    00498 }
    00499
    00500 inline const XMLCh* XMLAttr::getPrefix() const
    00501 {
    00502     return fAttName->getPrefix();
    00503 }
    00504
    00505 inline bool XMLAttr::getSpecified() const
    00506 {
    00507     return fSpecified;
    00508 }
    00509
    00510 inline XMLAttDef::AttTypes XMLAttr::getType() const
    00511 {
    00512     return fType;
    00513 }
    00514
    00515 inline const XMLCh* XMLAttr::getValue() const
    00516 {
    00517     return fValue;
    00518 }
    00519
    00520 inline unsigned int XMLAttr::getURIId() const
    00521 {
    00522     return fAttName->getURI();
    00523 }
    00524
    00525
    00526 // ---------------------------------------------------------------------------
    00527 //  XMLAttr: Setter methods
    00528 // ---------------------------------------------------------------------------
    00529 inline void XMLAttr::set(const  unsigned int        uriId
    00530                         , const XMLCh* const        attrName
    00531                         , const XMLCh* const        attrPrefix
    00532                         , const XMLCh* const        attrValue
    00533                         , const XMLAttDef::AttTypes type)
    00534 {
    00535     // Set the name info and the value via their respective calls
    00536     fAttName->setName(attrPrefix, attrName, uriId);
    00537     setValue(attrValue);
    00538
    00539     // And store the type
    00540     fType = type;
    00541 }
    00542
    00543 inline void XMLAttr::set(const  unsigned int        uriId
    00544                         , const XMLCh* const        attrRawName
    00545                         , const XMLCh* const        attrValue
    00546                         , const XMLAttDef::AttTypes type)
    00547 {
    00548     // Set the name info and the value via their respective calls
    00549     fAttName->setName(attrRawName, uriId);
    00550     setValue(attrValue);
    00551
    00552     // And store the type
    00553     fType = type;
    00554 }
    00555
    00556 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
    00557 {
    00558     fType = newValue;
    00559 }
    00560
    00561 inline void XMLAttr::setSpecified(const bool newValue)
    00562 {
    00563     fSpecified = newValue;
    00564 }
    00565
    00566 XERCES_CPP_NAMESPACE_END
    00567
    00568 #endif

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