Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:12

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_QNAME_HPP)
0023 #define XERCESC_INCLUDE_GUARD_QNAME_HPP
0024 
0025 #include <xercesc/util/XMLString.hpp>
0026 #include <xercesc/util/XMLUniDefs.hpp>
0027 #include <xercesc/util/XMemory.hpp>
0028 #include <xercesc/util/PlatformUtils.hpp>
0029 
0030 #include <xercesc/internal/XSerializable.hpp>
0031 
0032 XERCES_CPP_NAMESPACE_BEGIN
0033 
0034 class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
0035 {
0036 public :
0037     // -----------------------------------------------------------------------
0038     //  Constructors and Destructor
0039     // -----------------------------------------------------------------------
0040     /** Default constructor. */
0041     QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0042 
0043     /** Constructs a specified qname using prefix, and localpart. */
0044     QName
0045     (
0046           const XMLCh* const   prefix
0047         , const XMLCh* const   localPart
0048         , const unsigned int   uriId
0049         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0050     );
0051 
0052     /** Constructs a specified qname using rawName. */
0053     QName
0054     (
0055           const XMLCh* const   rawName
0056         , const unsigned int   uriId
0057         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0058     );
0059 
0060     /** Copy constructor. */
0061     QName(const QName& qname);
0062 
0063     ~QName();
0064 
0065     // -----------------------------------------------------------------------
0066     //  Getters
0067     // -----------------------------------------------------------------------
0068     const XMLCh* getPrefix() const;
0069     XMLCh* getPrefix();
0070 
0071     const XMLCh* getLocalPart() const;
0072     XMLCh* getLocalPart();
0073 
0074     unsigned int getURI() const;
0075 
0076     const XMLCh* getRawName() const;
0077     XMLCh* getRawName();
0078 
0079     MemoryManager* getMemoryManager() const;
0080 
0081     // -----------------------------------------------------------------------
0082     //  Setters
0083     // -----------------------------------------------------------------------
0084     void setName
0085     (
0086         const XMLCh* const        prefix
0087       , const XMLCh* const        localPart
0088        , const unsigned int        uriId
0089     );
0090 
0091     void setName
0092     (
0093         const XMLCh* const        rawName
0094        , const unsigned int        uriId
0095     );
0096 
0097     void setPrefix(const XMLCh*) ;
0098     void setLocalPart(const XMLCh*) ;
0099     void setNPrefix(const XMLCh*, const XMLSize_t ) ;
0100     void setNLocalPart(const XMLCh*, const XMLSize_t ) ;
0101     void setURI(const unsigned int) ;
0102 
0103     void setValues(const QName& qname);
0104 
0105     // -----------------------------------------------------------------------
0106     //  comparison
0107     // -----------------------------------------------------------------------
0108     bool operator==(const QName&) const;
0109 
0110     // -----------------------------------------------------------------------
0111     //  Misc
0112     // -----------------------------------------------------------------------
0113     void cleanUp();
0114 
0115     /***
0116      * Support for Serialization/De-serialization
0117      ***/
0118     DECL_XSERIALIZABLE(QName)
0119 
0120 private :
0121     // -----------------------------------------------------------------------
0122     //  Unimplemented constructors and operators
0123     // -----------------------------------------------------------------------    
0124     QName& operator=(const QName&);
0125 
0126     // -----------------------------------------------------------------------
0127     //  Private instance variables
0128     //
0129     //  We copy the followings from XMLAttr.hpp, but stick to Java version's
0130     //  naming convention
0131     //
0132     //  fPrefix
0133     //  fPrefixBufSz
0134     //      The prefix that was applied to this attribute's name, and the
0135     //      current size of the buffer (minus one for the null.) Prefixes
0136     //      really don't matter technically but it might be required for
0137     //      practical reasons, to recreate the original document for instance.
0138     //
0139     //  fLocalPart
0140     //  fLocalPartBufSz
0141     //      The base part of the name of the attribute, and the current size
0142     //      of the buffer (minus one, where the null is.)
0143     //
0144     //  fRawName
0145     //  fRawNameBufSz
0146     //      This is the QName form of the name, which is faulted in (from the
0147     //      prefix and name) upon request. The size field indicates the
0148     //      current size of the buffer (minus one for the null.) It will be
0149     //      zero until filled in.
0150     //
0151     //  fURIId
0152     //      The id of the URI that this attribute belongs to.
0153     // -----------------------------------------------------------------------
0154     XMLSize_t           fPrefixBufSz;
0155     XMLSize_t           fLocalPartBufSz;
0156     XMLSize_t           fRawNameBufSz;
0157     unsigned int        fURIId;
0158     XMLCh*              fPrefix;
0159     XMLCh*              fLocalPart;
0160     XMLCh*              fRawName;
0161     MemoryManager*      fMemoryManager;
0162 };
0163 
0164 // ---------------------------------------------------------------------------
0165 //  QName: Getter methods
0166 // ---------------------------------------------------------------------------
0167 inline const XMLCh* QName::getPrefix() const
0168 {
0169     return fPrefix;
0170 }
0171 
0172 inline XMLCh* QName::getPrefix()
0173 {
0174     return fPrefix;
0175 }
0176 
0177 inline const XMLCh* QName::getLocalPart() const
0178 {
0179     return fLocalPart;
0180 }
0181 
0182 inline XMLCh* QName::getLocalPart()
0183 {
0184     return fLocalPart;
0185 }
0186 
0187 inline unsigned int QName::getURI() const
0188 {
0189     return fURIId;
0190 }
0191 
0192 inline MemoryManager* QName::getMemoryManager() const
0193 {
0194     return fMemoryManager;
0195 }
0196 
0197 // ---------------------------------------------------------------------------
0198 //  QName: Setter methods
0199 // ---------------------------------------------------------------------------
0200 inline void QName::setURI(const unsigned int uriId)
0201 {
0202     fURIId = uriId;
0203 }
0204 
0205 inline void QName::setPrefix(const XMLCh* prefix)
0206 {
0207     setNPrefix(prefix, XMLString::stringLen(prefix));
0208 }
0209 
0210 inline void QName::setLocalPart(const XMLCh* localPart)
0211 {
0212     setNLocalPart(localPart, XMLString::stringLen(localPart));
0213 }
0214 
0215 XERCES_CPP_NAMESPACE_END
0216 
0217 #endif