- Main Page
- Related Pages
- Classes
- Files

# QName.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: QName.hpp 810580 2009-09-02 15:52:22Z amassari $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_QNAME_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_QNAME_HPP
    00024
    00025 #include <xercesc/util/XMLString.hpp>
    00026 #include <xercesc/util/XMLUniDefs.hpp>
    00027 #include <xercesc/util/XMemory.hpp>
    00028 #include <xercesc/util/PlatformUtils.hpp>
    00029
    00030 #include <xercesc/internal/XSerializable.hpp>
    00031
    00032 XERCES_CPP_NAMESPACE_BEGIN
    00033
    00034 class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
    00035 {
    00036 public :
    00037     // -----------------------------------------------------------------------
    00038     //  Contructors and Destructor
    00039     // -----------------------------------------------------------------------
    00041     QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00042
    00044     QName
    00045     (
    00046           const XMLCh* const   prefix
    00047         , const XMLCh* const   localPart
    00048         , const unsigned int   uriId
    00049         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00050     );
    00051
    00053     QName
    00054     (
    00055           const XMLCh* const   rawName
    00056         , const unsigned int   uriId
    00057         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00058     );
    00059
    00061     QName(const QName& qname);
    00062
    00063     ~QName();
    00064
    00065     // -----------------------------------------------------------------------
    00066     //  Getters
    00067     // -----------------------------------------------------------------------
    00068     const XMLCh* getPrefix() const;
    00069     XMLCh* getPrefix();
    00070
    00071     const XMLCh* getLocalPart() const;
    00072     XMLCh* getLocalPart();
    00073
    00074     unsigned int getURI() const;
    00075
    00076     const XMLCh* getRawName() const;
    00077     XMLCh* getRawName();
    00078
    00079     MemoryManager* getMemoryManager() const;
    00080
    00081     // -----------------------------------------------------------------------
    00082     //  Setters
    00083     // -----------------------------------------------------------------------
    00084     void setName
    00085     (
    00086         const XMLCh* const        prefix
    00087       , const XMLCh* const        localPart
    00088        , const unsigned int        uriId
    00089     );
    00090
    00091     void setName
    00092     (
    00093         const XMLCh* const        rawName
    00094        , const unsigned int        uriId
    00095     );
    00096
    00097     void setPrefix(const XMLCh*) ;
    00098     void setLocalPart(const XMLCh*) ;
    00099     void setNPrefix(const XMLCh*, const XMLSize_t ) ;
    00100     void setNLocalPart(const XMLCh*, const XMLSize_t ) ;
    00101     void setURI(const unsigned int) ;
    00102
    00103     void setValues(const QName& qname);
    00104
    00105     // -----------------------------------------------------------------------
    00106     //  comparison
    00107     // -----------------------------------------------------------------------
    00108     bool operator==(const QName&) const;
    00109
    00110     // -----------------------------------------------------------------------
    00111     //  Misc
    00112     // -----------------------------------------------------------------------
    00113     void cleanUp();
    00114
    00115     /***
    00116      * Support for Serialization/De-serialization
    00117      ***/
    00118     DECL_XSERIALIZABLE(QName)
    00119
    00120 private :
    00121     // -----------------------------------------------------------------------
    00122     //  Unimplemented constructors and operators
    00123     // -----------------------------------------------------------------------
    00124     QName& operator=(const QName&);
    00125
    00126     // -----------------------------------------------------------------------
    00127     //  Private instance variables
    00128     //
    00129     //  We copy the followings from XMLAttr.hpp, but stick to Java version's
    00130     //  naming convention
    00131     //
    00132     //  fPrefix
    00133     //  fPrefixBufSz
    00134     //      The prefix that was applied to this attribute's name, and the
    00135     //      current size of the buffer (minus one for the null.) Prefixes
    00136     //      really don't matter technically but it might be required for
    00137     //      pratical reasons, to recreate the original document for instance.
    00138     //
    00139     //  fLocalPart
    00140     //  fLocalPartBufSz
    00141     //      The base part of the name of the attribute, and the current size
    00142     //      of the buffer (minus one, where the null is.)
    00143     //
    00144     //  fRawName
    00145     //  fRawNameBufSz
    00146     //      This is the QName form of the name, which is faulted in (from the
    00147     //      prefix and name) upon request. The size field indicates the
    00148     //      current size of the buffer (minus one for the null.) It will be
    00149     //      zero until fauled in.
    00150     //
    00151     //  fURIId
    00152     //      The id of the URI that this attribute belongs to.
    00153     // -----------------------------------------------------------------------
    00154     XMLSize_t           fPrefixBufSz;
    00155     XMLSize_t           fLocalPartBufSz;
    00156     XMLSize_t           fRawNameBufSz;
    00157     unsigned int        fURIId;
    00158     XMLCh*              fPrefix;
    00159     XMLCh*              fLocalPart;
    00160     XMLCh*              fRawName;
    00161     MemoryManager*      fMemoryManager;
    00162 };
    00163
    00164 // ---------------------------------------------------------------------------
    00165 //  QName: Getter methods
    00166 // ---------------------------------------------------------------------------
    00167 inline const XMLCh* QName::getPrefix() const
    00168 {
    00169     return fPrefix;
    00170 }
    00171
    00172 inline XMLCh* QName::getPrefix()
    00173 {
    00174     return fPrefix;
    00175 }
    00176
    00177 inline const XMLCh* QName::getLocalPart() const
    00178 {
    00179     return fLocalPart;
    00180 }
    00181
    00182 inline XMLCh* QName::getLocalPart()
    00183 {
    00184     return fLocalPart;
    00185 }
    00186
    00187 inline unsigned int QName::getURI() const
    00188 {
    00189     return fURIId;
    00190 }
    00191
    00192 inline MemoryManager* QName::getMemoryManager() const
    00193 {
    00194     return fMemoryManager;
    00195 }
    00196
    00197 // ---------------------------------------------------------------------------
    00198 //  QName: Setter methods
    00199 // ---------------------------------------------------------------------------
    00200 inline void QName::setURI(const unsigned int uriId)
    00201 {
    00202     fURIId = uriId;
    00203 }
    00204
    00205 inline void QName::setPrefix(const XMLCh* prefix)
    00206 {
    00207     setNPrefix(prefix, XMLString::stringLen(prefix));
    00208 }
    00209
    00210 inline void QName::setLocalPart(const XMLCh* localPart)
    00211 {
    00212     setNLocalPart(localPart, XMLString::stringLen(localPart));
    00213 }
    00214
    00215 XERCES_CPP_NAMESPACE_END
    00216
    00217 #endif