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  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 2001 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) 2001, 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: QName.hpp,v $
00059  * Revision 1.10  2004/01/29 11:48:46  cargilld
00060  * Code cleanup changes to get rid of various compiler diagnostic messages.
00061  *
00062  * Revision 1.9  2003/09/25 15:22:34  peiyongz
00063  * Implementation of Serialization
00064  *
00065  * Revision 1.8  2003/05/16 21:36:59  knoaman
00066  * Memory manager implementation: Modify constructors to pass in the memory manager.
00067  *
00068  * Revision 1.7  2003/05/16 06:01:52  knoaman
00069  * Partial implementation of the configurable memory manager.
00070  *
00071  * Revision 1.6  2003/05/15 19:04:35  knoaman
00072  * Partial implementation of the configurable memory manager.
00073  *
00074  * Revision 1.5  2002/11/04 15:22:04  tng
00075  * C++ Namespace Support.
00076  *
00077  * Revision 1.4  2002/10/30 21:52:00  tng
00078  * [Bug 13641] compiler-generated copy-constructor for QName doesn't do the right thing.
00079  *
00080  * Revision 1.3  2002/09/05 16:06:41  tng
00081  * [Bug 12232] Make operator to be constant.
00082  *
00083  * Revision 1.2  2002/08/20 16:54:25  tng
00084  * [Bug 6251] Info during compilation.
00085  *
00086  * Revision 1.1.1.1  2002/02/01 22:22:11  peiyongz
00087  * sane_include
00088  *
00089  * Revision 1.8  2001/12/06 17:48:36  tng
00090  * 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.
00091  * 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.
00092  * 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.
00093  * By Henry Zongaro.
00094  *
00095  * Revision 1.7  2001/07/24 18:31:47  knoaman
00096  * Added support for <group> + extra constraint checking for complexType
00097  *
00098  * Revision 1.6  2001/05/11 13:26:28  tng
00099  * Copyright update.
00100  *
00101  * Revision 1.5  2001/04/19 18:17:10  tng
00102  * Schema: SchemaValidator update, and use QName in Content Model
00103  *
00104  * Revision 1.4  2001/03/21 21:56:12  tng
00105  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
00106  *
00107  * Revision 1.3  2001/02/27 14:48:39  tng
00108  * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
00109  *
00110  * Revision 1.2  2001/02/26 21:56:16  tng
00111  * Schema: QName can also be constructed with rawName.
00112  *
00113  * Revision 1.1  2001/02/26 19:44:25  tng
00114  * Schema: add utility class QName, by Pei Yong Zhang.
00115  *
00116  */
00117 
00118 #if !defined(QNAME_HPP)
00119 #define QNAME_HPP
00120 
00121 #include <xercesc/util/XMLString.hpp>
00122 #include <xercesc/util/XMLUniDefs.hpp>
00123 #include <xercesc/util/XMemory.hpp>
00124 #include <xercesc/util/PlatformUtils.hpp>
00125 
00126 #include <xercesc/internal/XSerializable.hpp>
00127 
00128 XERCES_CPP_NAMESPACE_BEGIN
00129 
00130 class  QName : public XSerializable, public XMemory
00131 {
00132 public :
00133     // -----------------------------------------------------------------------
00134     //  Contructors and Destructor
00135     // -----------------------------------------------------------------------
00137     QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00138 
00140     QName
00141     (
00142           const XMLCh* const   prefix
00143         , const XMLCh* const   localPart
00144         , const unsigned int   uriId
00145         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00146     );
00147 
00149     QName
00150     (
00151           const XMLCh* const   rawName
00152         , const unsigned int   uriId
00153         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00154     );
00155 
00157     QName(const QName& qname);
00158 
00159     ~QName();
00160 
00161     // -----------------------------------------------------------------------
00162     //  Getters
00163     // -----------------------------------------------------------------------
00164     const XMLCh* getPrefix() const;
00165     XMLCh* getPrefix();
00166 
00167     const XMLCh* getLocalPart() const;
00168     XMLCh* getLocalPart();
00169 
00170     unsigned int getURI() const;
00171 
00172     const XMLCh* getRawName() const;
00173     XMLCh* getRawName();
00174 
00175     MemoryManager* getMemoryManager() const;
00176 
00177     // -----------------------------------------------------------------------
00178     //  Setters
00179     // -----------------------------------------------------------------------
00180     void setName
00181     (
00182         const XMLCh* const        prefix
00183       , const XMLCh* const        localPart
00184        , const unsigned int        uriId
00185     );
00186 
00187     void setName
00188     (
00189         const XMLCh* const        rawName
00190        , const unsigned int        uriId
00191     );
00192 
00193     void setPrefix(const XMLCh*) ;
00194     void setLocalPart(const XMLCh*) ;
00195     void setNPrefix(const XMLCh*, const unsigned int) ;
00196     void setNLocalPart(const XMLCh*, const unsigned int) ;
00197     void setURI(const unsigned int) ;
00198 
00199     void setValues(const QName& qname);
00200 
00201     // -----------------------------------------------------------------------
00202     //  comparison
00203     // -----------------------------------------------------------------------
00204     bool operator==(const QName&) const;
00205 
00206     // -----------------------------------------------------------------------
00207     //  Misc
00208     // -----------------------------------------------------------------------
00209     void cleanUp();
00210 
00211     /***
00212      * Support for Serialization/De-serialization
00213      ***/
00214     DECL_XSERIALIZABLE(QName)
00215 
00216 private :
00217     // -----------------------------------------------------------------------
00218     //  Unimplemented constructors and operators
00219     // -----------------------------------------------------------------------    
00220     QName& operator=(const QName&);
00221 
00222     // -----------------------------------------------------------------------
00223     //  Private instance variables
00224     //
00225     //  We copy the followings from XMLAttr.hpp, but stick to Java version's
00226     //  naming convention
00227     //
00228     //  fPrefix
00229     //  fPrefixBufSz
00230     //      The prefix that was applied to this attribute's name, and the
00231     //      current size of the buffer (minus one for the null.) Prefixes
00232     //      really don't matter technically but it might be required for
00233     //      pratical reasons, to recreate the original document for instance.
00234     //
00235     //  fLocalPart
00236     //  fLocalPartBufSz
00237     //      The base part of the name of the attribute, and the current size
00238     //      of the buffer (minus one, where the null is.)
00239     //
00240     //  fRawName
00241     //  fRawNameBufSz
00242     //      This is the QName form of the name, which is faulted in (from the
00243     //      prefix and name) upon request. The size field indicates the
00244     //      current size of the buffer (minus one for the null.) It will be
00245     //      zero until fauled in.
00246     //
00247     //  fURIId
00248     //      The id of the URI that this attribute belongs to.
00249     // -----------------------------------------------------------------------
00250     MemoryManager*      fMemoryManager;
00251     XMLCh*              fPrefix;
00252     unsigned int        fPrefixBufSz;
00253     XMLCh*              fLocalPart;
00254     unsigned int        fLocalPartBufSz;
00255     XMLCh*              fRawName;
00256     unsigned int        fRawNameBufSz;
00257     unsigned int        fURIId;
00258 };
00259 
00260 // ---------------------------------------------------------------------------
00261 //  QName: Getter methods
00262 // ---------------------------------------------------------------------------
00263 inline const XMLCh* QName::getPrefix() const
00264 {
00265     return fPrefix;
00266 }
00267 
00268 inline XMLCh* QName::getPrefix()
00269 {
00270     return fPrefix;
00271 }
00272 
00273 inline const XMLCh* QName::getLocalPart() const
00274 {
00275     return fLocalPart;
00276 }
00277 
00278 inline XMLCh* QName::getLocalPart()
00279 {
00280     return fLocalPart;
00281 }
00282 
00283 inline unsigned int QName::getURI() const
00284 {
00285     return fURIId;
00286 }
00287 
00288 inline MemoryManager* QName::getMemoryManager() const
00289 {
00290     return fMemoryManager;
00291 }
00292 
00293 // ---------------------------------------------------------------------------
00294 //  QName: Setter methods
00295 // ---------------------------------------------------------------------------
00296 inline void QName::setURI(const unsigned int uriId)
00297 {
00298     fURIId = uriId;
00299 }
00300 
00301 XERCES_CPP_NAMESPACE_END
00302 
00303 #endif


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