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

Home

Readme
Installation
Build

API Docs
Samples
Programming
Migration
FAQs

Releases
Feedback
Bug-Todo

Download
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-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: XMLAttr.hpp,v $

00059  * Revision 1.6  2000/04/10 22:42:53  roddey

00060  * Extended the buffer reuse to the QName field, to further increase

00061  * performance of attribute heavy applications.

00062  *
00063  * Revision 1.5  2000/03/02 19:54:24  roddey

00064  * This checkin includes many changes done while waiting for the

00065  * 1.1.0 code to be finished. I can't list them all here, but a list is

00066  * available elsewhere.

00067  *
00068  * Revision 1.4  2000/02/24 20:00:22  abagchi

00069  * Swat for removing Log from API docs

00070  *
00071  * Revision 1.3  2000/02/15 01:21:30  roddey

00072  * Some initial documentation improvements. More to come...

00073  *
00074  * Revision 1.2  2000/02/06 07:47:47  rahulj

00075  * Year 2K copyright swat.

00076  *
00077  * Revision 1.1.1.1  1999/11/09 01:08:28  twl

00078  * Initial checkin

00079  *
00080  * Revision 1.2  1999/11/08 20:44:35  rahul

00081  * Swat for adding in Product name and CVS comment log variable.

00082  *
00083  */
00084 
00085 #if !defined(XMLATTR_HPP)
00086 #define XMLATTR_HPP
00087 
00088 #include <util/XMLString.hpp>
00089 #include <framework/XMLAttDef.hpp>
00090 
00091 
00113 class  XMLAttr
00114 {
00115 public:
00116     // -----------------------------------------------------------------------
00117     //  Constructors and Destructor
00118     // -----------------------------------------------------------------------
00121 
00127     XMLAttr();
00128 
00155     XMLAttr
00156     (
00157         const   unsigned int        uriId
00158         , const XMLCh* const        attrName
00159         , const XMLCh* const        attrPrefix
00160         , const XMLCh* const        attrValue
00161         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00162         , const bool                specified = true
00163     );
00165 
00168     ~XMLAttr();
00170 
00171 
00172     // -----------------------------------------------------------------------
00173     //  Getter methods
00174     // -----------------------------------------------------------------------
00175 
00178 
00183     const XMLCh* getName() const;
00184 
00189     const XMLCh* getPrefix() const;
00190 
00196     const XMLCh* getQName() const;
00197 
00202     bool getSpecified() const;
00203 
00208     XMLAttDef::AttTypes getType() const;
00209 
00215     const XMLCh* getValue() const;
00216 
00221     unsigned int getURIId() const;
00222 
00224 
00225 
00226     // -----------------------------------------------------------------------
00227     //  Setter methods
00228     // -----------------------------------------------------------------------
00229 
00232 
00260     void set
00261     (
00262         const   unsigned int        uriId
00263         , const XMLCh* const        attrName
00264         , const XMLCh* const        attrPrefix
00265         , const XMLCh* const        attrValue
00266         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00267     );
00268 
00283     void setName
00284     (
00285         const   unsigned int        uriId
00286         , const XMLCh* const        attrName
00287         , const XMLCh* const        attrPrefix
00288     );
00289 
00297     void setSpecified(const bool newValue);
00298 
00307     void setType(const XMLAttDef::AttTypes newType);
00308 
00316     void setValue(const XMLCh* const newValue);
00317 
00323     void setURIId(const unsigned int uriId);
00324 
00326 
00327 
00328 
00329 private :
00330     // -----------------------------------------------------------------------
00331     //  Unimplemented constructors and operators
00332     // -----------------------------------------------------------------------
00333     XMLAttr(const XMLAttr&);
00334     XMLAttr& operator=(const XMLAttr&);
00335 
00336 
00337     // -----------------------------------------------------------------------
00338     //  Private, helper methods
00339     // -----------------------------------------------------------------------
00340     void cleanUp();
00341 
00342 
00343     // -----------------------------------------------------------------------
00344     //  Private instance variables
00345     //
00346     //  fName
00347     //  fNameBufSz
00348     //      The base part of the name of the attribute, and the current size
00349     //      of the buffer (minus one, where the null is.)
00350     //
00351     //  fPrefix
00352     //  fPrefixBufSz
00353     //      The prefix that was applied to this attribute's name, and the
00354     //      current size of the buffer (minus one for the null.) Prefixes
00355     //      really don't matter technically but it might be required for
00356     //      pratical reasons, to recreate the original document for instance.
00357     //
00358     //  fQName
00359     //  fQNameBufSz
00360     //      This is the QName form of the name, which is faulted in (from the
00361     //      prefix and name) upon request. The size field indicates the
00362     //      current size of the buffer (minus one for the null.) It will be
00363     //      zero until fauled in.
00364     //
00365     //  fSpecified
00366     //      True if this attribute appeared in the element; else, false if
00367     //      it was defaulted from an AttDef.
00368     //
00369     //  fType
00370     //      The attribute type enum value for this attribute. Indicates what
00371     //      type of attribute it was.
00372     //
00373     //  fValue
00374     //  fValueBufSz
00375     //      The attribute value that was given in the attribute instance, and
00376     //      its current buffer size (minus one, where the null is.)
00377     //
00378     //  fURIId
00379     //      The id of the URI that this attribute belongs to.
00380     // -----------------------------------------------------------------------
00381     XMLCh*              fName;
00382     unsigned int        fNameBufSz;
00383     XMLCh*              fPrefix;
00384     unsigned int        fPrefixBufSz;
00385     XMLCh*              fQName;
00386     unsigned int        fQNameBufSz;
00387     bool                fSpecified;
00388     XMLAttDef::AttTypes fType;
00389     XMLCh*              fValue;
00390     unsigned int        fValueBufSz;
00391     unsigned int        fURIId;
00392 };
00393 
00394 // ---------------------------------------------------------------------------
00395 //  XMLAttr: Constructors and Destructor
00396 // ---------------------------------------------------------------------------
00397 inline XMLAttr::~XMLAttr()

00398 {
00399     cleanUp();
00400 }
00401 
00402 
00403 // ---------------------------------------------------------------------------
00404 //  XMLAttr: Getter methods
00405 // ---------------------------------------------------------------------------
00406 inline const XMLCh* XMLAttr::getName() const

00407 {
00408     return fName;
00409 }
00410 
00411 inline const XMLCh* XMLAttr::getPrefix() const

00412 {
00413     return fPrefix;
00414 }
00415 
00416 inline bool XMLAttr::getSpecified() const

00417 {
00418     return fSpecified;
00419 }
00420 
00421 inline XMLAttDef::AttTypes XMLAttr::getType() const

00422 {
00423     return fType;
00424 }
00425 
00426 inline const XMLCh* XMLAttr::getValue() const

00427 {
00428     return fValue;
00429 }
00430 
00431 inline unsigned int XMLAttr::getURIId() const

00432 {
00433     return fURIId;
00434 }
00435 
00436 
00437 // ---------------------------------------------------------------------------
00438 //  XMLAttr: Setter methods
00439 // ---------------------------------------------------------------------------
00440 inline void XMLAttr::set(const  unsigned int        uriId
00441                         , const XMLCh* const        attrName
00442                         , const XMLCh* const        attrPrefix
00443                         , const XMLCh* const        attrValue
00444                         , const XMLAttDef::AttTypes type)

00445 {
00446     // Set the name info and the value via their respective calls
00447     setName(uriId, attrName, attrPrefix);
00448     setValue(attrValue);
00449 
00450     // And store the type
00451     fType = type;
00452 }
00453 
00454 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)

00455 {
00456     fType = newValue;
00457 }
00458 
00459 inline void XMLAttr::setSpecified(const bool newValue)

00460 {
00461     fSpecified = newValue;
00462 }
00463 
00464 #endif


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