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  

QName.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2001,2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * $Log: QName.hpp,v $
00019  * Revision 1.11  2004/09/08 13:56:22  peiyongz
00020  * Apache License Version 2.0
00021  *
00022  * Revision 1.10  2004/01/29 11:48:46  cargilld
00023  * Code cleanup changes to get rid of various compiler diagnostic messages.
00024  *
00025  * Revision 1.9  2003/09/25 15:22:34  peiyongz
00026  * Implementation of Serialization
00027  *
00028  * Revision 1.8  2003/05/16 21:36:59  knoaman
00029  * Memory manager implementation: Modify constructors to pass in the memory manager.
00030  *
00031  * Revision 1.7  2003/05/16 06:01:52  knoaman
00032  * Partial implementation of the configurable memory manager.
00033  *
00034  * Revision 1.6  2003/05/15 19:04:35  knoaman
00035  * Partial implementation of the configurable memory manager.
00036  *
00037  * Revision 1.5  2002/11/04 15:22:04  tng
00038  * C++ Namespace Support.
00039  *
00040  * Revision 1.4  2002/10/30 21:52:00  tng
00041  * [Bug 13641] compiler-generated copy-constructor for QName doesn't do the right thing.
00042  *
00043  * Revision 1.3  2002/09/05 16:06:41  tng
00044  * [Bug 12232] Make operator to be constant.
00045  *
00046  * Revision 1.2  2002/08/20 16:54:25  tng
00047  * [Bug 6251] Info during compilation.
00048  *
00049  * Revision 1.1.1.1  2002/02/01 22:22:11  peiyongz
00050  * sane_include
00051  *
00052  * Revision 1.8  2001/12/06 17:48:36  tng
00053  * Performance Enhancement.  Added setNPrefix and setNLocalPart methods that allow code to take advantage of the fact that it knows the length of the prefix and local name, when possible.  That can avoid a copy of the prefix into a null-terminated temporary variable before copying into the fPrefix.
00054  * Also changed the getRawName method so that it would simply return the local part when there is no prefix, instead of allocating another buffer to copy the local part into the fRawName.
00055  * When there is a prefix, changed the getRawName to copy the prefix and local part into the fRawName using XMLString::moveChars instead of using XMLString::copyString and XMLString::catString.  The catString method has to loop past the prefix portion of the fRawName, which seems like a waste.
00056  * By Henry Zongaro.
00057  *
00058  * Revision 1.7  2001/07/24 18:31:47  knoaman
00059  * Added support for <group> + extra constraint checking for complexType
00060  *
00061  * Revision 1.6  2001/05/11 13:26:28  tng
00062  * Copyright update.
00063  *
00064  * Revision 1.5  2001/04/19 18:17:10  tng
00065  * Schema: SchemaValidator update, and use QName in Content Model
00066  *
00067  * Revision 1.4  2001/03/21 21:56:12  tng
00068  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
00069  *
00070  * Revision 1.3  2001/02/27 14:48:39  tng
00071  * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
00072  *
00073  * Revision 1.2  2001/02/26 21:56:16  tng
00074  * Schema: QName can also be constructed with rawName.
00075  *
00076  * Revision 1.1  2001/02/26 19:44:25  tng
00077  * Schema: add utility class QName, by Pei Yong Zhang.
00078  *
00079  */
00080 
00081 #if !defined(QNAME_HPP)
00082 #define QNAME_HPP
00083 
00084 #include <xercesc/util/XMLString.hpp>
00085 #include <xercesc/util/XMLUniDefs.hpp>
00086 #include <xercesc/util/XMemory.hpp>
00087 #include <xercesc/util/PlatformUtils.hpp>
00088 
00089 #include <xercesc/internal/XSerializable.hpp>
00090 
00091 XERCES_CPP_NAMESPACE_BEGIN
00092 
00093 class  QName : public XSerializable, public XMemory
00094 {
00095 public :
00096     // -----------------------------------------------------------------------
00097     //  Contructors and Destructor
00098     // -----------------------------------------------------------------------
00100     QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00101 
00103     QName
00104     (
00105           const XMLCh* const   prefix
00106         , const XMLCh* const   localPart
00107         , const unsigned int   uriId
00108         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00109     );
00110 
00112     QName
00113     (
00114           const XMLCh* const   rawName
00115         , const unsigned int   uriId
00116         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00117     );
00118 
00120     QName(const QName& qname);
00121 
00122     ~QName();
00123 
00124     // -----------------------------------------------------------------------
00125     //  Getters
00126     // -----------------------------------------------------------------------
00127     const XMLCh* getPrefix() const;
00128     XMLCh* getPrefix();
00129 
00130     const XMLCh* getLocalPart() const;
00131     XMLCh* getLocalPart();
00132 
00133     unsigned int getURI() const;
00134 
00135     const XMLCh* getRawName() const;
00136     XMLCh* getRawName();
00137 
00138     MemoryManager* getMemoryManager() const;
00139 
00140     // -----------------------------------------------------------------------
00141     //  Setters
00142     // -----------------------------------------------------------------------
00143     void setName
00144     (
00145         const XMLCh* const        prefix
00146       , const XMLCh* const        localPart
00147        , const unsigned int        uriId
00148     );
00149 
00150     void setName
00151     (
00152         const XMLCh* const        rawName
00153        , const unsigned int        uriId
00154     );
00155 
00156     void setPrefix(const XMLCh*) ;
00157     void setLocalPart(const XMLCh*) ;
00158     void setNPrefix(const XMLCh*, const unsigned int) ;
00159     void setNLocalPart(const XMLCh*, const unsigned int) ;
00160     void setURI(const unsigned int) ;
00161 
00162     void setValues(const QName& qname);
00163 
00164     // -----------------------------------------------------------------------
00165     //  comparison
00166     // -----------------------------------------------------------------------
00167     bool operator==(const QName&) const;
00168 
00169     // -----------------------------------------------------------------------
00170     //  Misc
00171     // -----------------------------------------------------------------------
00172     void cleanUp();
00173 
00174     /***
00175      * Support for Serialization/De-serialization
00176      ***/
00177     DECL_XSERIALIZABLE(QName)
00178 
00179 private :
00180     // -----------------------------------------------------------------------
00181     //  Unimplemented constructors and operators
00182     // -----------------------------------------------------------------------    
00183     QName& operator=(const QName&);
00184 
00185     // -----------------------------------------------------------------------
00186     //  Private instance variables
00187     //
00188     //  We copy the followings from XMLAttr.hpp, but stick to Java version's
00189     //  naming convention
00190     //
00191     //  fPrefix
00192     //  fPrefixBufSz
00193     //      The prefix that was applied to this attribute's name, and the
00194     //      current size of the buffer (minus one for the null.) Prefixes
00195     //      really don't matter technically but it might be required for
00196     //      pratical reasons, to recreate the original document for instance.
00197     //
00198     //  fLocalPart
00199     //  fLocalPartBufSz
00200     //      The base part of the name of the attribute, and the current size
00201     //      of the buffer (minus one, where the null is.)
00202     //
00203     //  fRawName
00204     //  fRawNameBufSz
00205     //      This is the QName form of the name, which is faulted in (from the
00206     //      prefix and name) upon request. The size field indicates the
00207     //      current size of the buffer (minus one for the null.) It will be
00208     //      zero until fauled in.
00209     //
00210     //  fURIId
00211     //      The id of the URI that this attribute belongs to.
00212     // -----------------------------------------------------------------------
00213     MemoryManager*      fMemoryManager;
00214     XMLCh*              fPrefix;
00215     unsigned int        fPrefixBufSz;
00216     XMLCh*              fLocalPart;
00217     unsigned int        fLocalPartBufSz;
00218     XMLCh*              fRawName;
00219     unsigned int        fRawNameBufSz;
00220     unsigned int        fURIId;
00221 };
00222 
00223 // ---------------------------------------------------------------------------
00224 //  QName: Getter methods
00225 // ---------------------------------------------------------------------------
00226 inline const XMLCh* QName::getPrefix() const
00227 {
00228     return fPrefix;
00229 }
00230 
00231 inline XMLCh* QName::getPrefix()
00232 {
00233     return fPrefix;
00234 }
00235 
00236 inline const XMLCh* QName::getLocalPart() const
00237 {
00238     return fLocalPart;
00239 }
00240 
00241 inline XMLCh* QName::getLocalPart()
00242 {
00243     return fLocalPart;
00244 }
00245 
00246 inline unsigned int QName::getURI() const
00247 {
00248     return fURIId;
00249 }
00250 
00251 inline MemoryManager* QName::getMemoryManager() const
00252 {
00253     return fMemoryManager;
00254 }
00255 
00256 // ---------------------------------------------------------------------------
00257 //  QName: Setter methods
00258 // ---------------------------------------------------------------------------
00259 inline void QName::setURI(const unsigned int uriId)
00260 {
00261     fURIId = uriId;
00262 }
00263 
00264 XERCES_CPP_NAMESPACE_END
00265 
00266 #endif


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