# XMLEntityDecl.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: XMLEntityDecl.hpp 698579 2008-09-24 14:13:08Z borisk $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_XMLENTITYDECL_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_XMLENTITYDECL_HPP
    00024
    00025 #include <xercesc/util/XMemory.hpp>
    00026 #include <xercesc/util/PlatformUtils.hpp>
    00027 #include <xercesc/util/XMLString.hpp>
    00028 #include <xercesc/internal/XSerializable.hpp>
    00029
    00030 XERCES_CPP_NAMESPACE_BEGIN
    00031
    00050 class XMLPARSER_EXPORT XMLEntityDecl : public XSerializable, public XMemory
    00051 {
    00052 public:
    00053     // -----------------------------------------------------------------------
    00054     //  Constructors and Destructor
    00055     // -----------------------------------------------------------------------
    00056
    00059
    00063     XMLEntityDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00064
    00071     XMLEntityDecl
    00072     (
    00073         const   XMLCh* const    entName
    00074         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00075     );
    00076
    00085     XMLEntityDecl
    00086     (
    00087         const   XMLCh* const    entName
    00088         , const XMLCh* const    value
    00089         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00090     );
    00091
    00100     XMLEntityDecl
    00101     (
    00102         const   XMLCh* const    entName
    00103         , const XMLCh           value
    00104         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00105     );
    00107
    00110
    00114     virtual ~XMLEntityDecl();
    00115
    00117
    00118
    00119     // -----------------------------------------------------------------------
    00120     //  Virtual entity decl interface
    00121     // -----------------------------------------------------------------------
    00122
    00125
    00133     virtual bool getDeclaredInIntSubset() const = 0;
    00134
    00140     virtual bool getIsParameter() const = 0;
    00141
    00147     virtual bool getIsSpecialChar() const = 0;
    00148
    00150
    00151
    00152     // -----------------------------------------------------------------------
    00153     //  Getter methods
    00154     // -----------------------------------------------------------------------
    00155
    00158
    00163     XMLSize_t getId() const;
    00164
    00170     const XMLCh* getName() const;
    00171
    00176     const XMLCh* getNotationName() const;
    00177
    00182     const XMLCh* getPublicId() const;
    00183
    00188     const XMLCh* getSystemId() const;
    00189
    00193     const XMLCh* getBaseURI() const;
    00194
    00200     const XMLCh* getValue() const;
    00201
    00207     XMLSize_t getValueLen() const;
    00208
    00213     bool isExternal() const;
    00214
    00220     bool isUnparsed() const;
    00221
    00229     MemoryManager* getMemoryManager() const;
    00230
    00232
    00233
    00234     // -----------------------------------------------------------------------
    00235     //  Setter methods
    00236     // -----------------------------------------------------------------------
    00237
    00240
    00249     void setName
    00250     (
    00251         const   XMLCh* const    entName
    00252     );
    00253
    00259     void setIsExternal(bool value);
    00260
    00267     void setNotationName(const XMLCh* const newName);
    00268
    00275     void setPublicId(const XMLCh* const newId);
    00276
    00286     void setSystemId(const XMLCh* const newId);
    00287
    00294     void setBaseURI(const XMLCh* const newId);
    00295
    00303     void setValue(const XMLCh* const newValue);
    00304
    00306
    00307     /* For internal use only */
    00308     void setId(const XMLSize_t newId);
    00309
    00310
    00311     // -----------------------------------------------------------------------
    00312     //  Support named pool syntax
    00313     // -----------------------------------------------------------------------
    00314
    00317
    00324     const XMLCh* getKey() const;
    00325
    00327
    00328     /***
    00329      * Support for Serialization/De-serialization
    00330      ***/
    00331     DECL_XSERIALIZABLE(XMLEntityDecl)
    00332
    00333 private :
    00334     // -----------------------------------------------------------------------
    00335     //  Unimplemented constructors and operators
    00336     // -----------------------------------------------------------------------
    00337     XMLEntityDecl(const XMLEntityDecl&);
    00338     XMLEntityDecl& operator=(XMLEntityDecl&);
    00339
    00340
    00341     // -----------------------------------------------------------------------
    00342     //  XMLEntityDecl: Private helper methods
    00343     // -----------------------------------------------------------------------
    00344     void cleanUp();
    00345
    00346
    00347     // -----------------------------------------------------------------------
    00348     //  Private data members
    00349     //
    00350     //  fId
    00351     //      This is the unique id given to this entity decl.
    00352     //
    00353     //  fName
    00354     //      The name of the enitity. Entity names are never namespace based.
    00355     //
    00356     //  fNotationName
    00357     //      The optional notation of the entity. If there was none, then its
    00358     //      empty.
    00359     //
    00360     //  fPublicId
    00361     //      The public id of the entity, which can be empty.
    00362     //
    00363     //  fSystemId
    00364     //      The system id of the entity.
    00365     //
    00366     //  fValue
    00367     //  fValueLen
    00368     //      The entity's value and length, which is only valid if its an
    00369     //      internal style entity.
    00370     //
    00371     //  fBaseURI
    00372     //      The base URI of the entity.   According to XML InfoSet, such value
    00373     //      is the URI where it is declared (NOT referenced).
    00374     // -----------------------------------------------------------------------
    00375     XMLSize_t       fId;
    00376     XMLSize_t       fValueLen;
    00377     XMLCh*          fValue;
    00378     XMLCh*          fName;
    00379     XMLCh*          fNotationName;
    00380     XMLCh*          fPublicId;
    00381     XMLCh*          fSystemId;
    00382     XMLCh*          fBaseURI;
    00383     bool            fIsExternal;
    00384     MemoryManager*  fMemoryManager;
    00385 };
    00386
    00387
    00388 // ---------------------------------------------------------------------------
    00389 //  XMLEntityDecl: Getter methods
    00390 // ---------------------------------------------------------------------------
    00391 inline XMLSize_t XMLEntityDecl::getId() const
    00392 {
    00393     return fId;
    00394 }
    00395
    00396 inline const XMLCh* XMLEntityDecl::getName() const
    00397 {
    00398     return fName;
    00399 }
    00400
    00401 inline const XMLCh* XMLEntityDecl::getNotationName() const
    00402 {
    00403     return fNotationName;
    00404 }
    00405
    00406 inline const XMLCh* XMLEntityDecl::getPublicId() const
    00407 {
    00408     return fPublicId;
    00409 }
    00410
    00411 inline const XMLCh* XMLEntityDecl::getSystemId() const
    00412 {
    00413     return fSystemId;
    00414 }
    00415
    00416 inline const XMLCh* XMLEntityDecl::getBaseURI() const
    00417 {
    00418     return fBaseURI;
    00419 }
    00420
    00421 inline const XMLCh* XMLEntityDecl::getValue() const
    00422 {
    00423     return fValue;
    00424 }
    00425
    00426 inline XMLSize_t XMLEntityDecl::getValueLen() const
    00427 {
    00428     return fValueLen;
    00429 }
    00430
    00431 inline bool XMLEntityDecl::isExternal() const
    00432 {
    00433     return fIsExternal;
    00434 }
    00435
    00436 inline bool XMLEntityDecl::isUnparsed() const
    00437 {
    00438     // If it has a notation, its unparsed
    00439     return (fNotationName != 0);
    00440 }
    00441
    00442 inline MemoryManager* XMLEntityDecl::getMemoryManager() const
    00443 {
    00444     return fMemoryManager;
    00445 }
    00446
    00447 // ---------------------------------------------------------------------------
    00448 //  XMLEntityDecl: Setter methods
    00449 // ---------------------------------------------------------------------------
    00450 inline void XMLEntityDecl::setId(const XMLSize_t newId)
    00451 {
    00452     fId = newId;
    00453 }
    00454
    00455 inline void XMLEntityDecl::setIsExternal(bool value)
    00456 {
    00457     fIsExternal = value;
    00458 }
    00459
    00460 inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
    00461 {
    00462     if (fNotationName)
    00463         fMemoryManager->deallocate(fNotationName);
    00464
    00465     fNotationName = XMLString::replicate(newName, fMemoryManager);
    00466 }
    00467
    00468 inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
    00469 {
    00470     if (fPublicId)
    00471         fMemoryManager->deallocate(fPublicId);
    00472
    00473     fPublicId = XMLString::replicate(newId, fMemoryManager);
    00474 }
    00475
    00476 inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
    00477 {
    00478     if (fSystemId)
    00479         fMemoryManager->deallocate(fSystemId);
    00480
    00481     fSystemId = XMLString::replicate(newId, fMemoryManager);
    00482 }
    00483
    00484 inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
    00485 {
    00486     if (fBaseURI)
    00487         fMemoryManager->deallocate(fBaseURI);
    00488
    00489     fBaseURI = XMLString::replicate(newId, fMemoryManager);
    00490 }
    00491
    00492 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
    00493 {
    00494     if (fValue)
    00495         fMemoryManager->deallocate(fValue);
    00496
    00497     fValue = XMLString::replicate(newValue, fMemoryManager);
    00498     fValueLen = XMLString::stringLen(newValue);
    00499 }
    00500
    00501
    00502 // ---------------------------------------------------------------------------
    00503 //  XMLEntityDecl: Support named pool syntax
    00504 // ---------------------------------------------------------------------------
    00505 inline const XMLCh* XMLEntityDecl::getKey() const
    00506 {
    00507     return fName;
    00508 }
    00509
    00510 XERCES_CPP_NAMESPACE_END
    00511
    00512 #endif