Xerces-C++: XMLEntityDecl.hpp Source File

| API Docs for SAX and DOM |
| Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages # XMLEntityDecl.hpp Go to the documentation of this file.
    00001 /*
    00002  * Copyright 1999-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  * $Id: XMLEntityDecl.hpp 191054 2005-06-17 02:56:35Z jberry $
    00019  */
    00020
    00021 #if !defined(XMLENTITYDECL_HPP)
    00022 #define XMLENTITYDECL_HPP
    00023
    00024 #include <xercesc/util/XMemory.hpp>
    00025 #include <xercesc/util/PlatformUtils.hpp>
    00026 #include <xercesc/util/XMLString.hpp>
    00027 #include <xercesc/internal/XSerializable.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00049 class  XMLEntityDecl : public XSerializable, public XMemory
    00050 {
    00051 public:
    00052     // -----------------------------------------------------------------------
    00053     //  Constructors and Destructor
    00054     // -----------------------------------------------------------------------
    00055
    00058
    00062     XMLEntityDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00063
    00070     XMLEntityDecl
    00071     (
    00072         const   XMLCh* const    entName
    00073         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00074     );
    00075
    00084     XMLEntityDecl
    00085     (
    00086         const   XMLCh* const    entName
    00087         , const XMLCh* const    value
    00088         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00089     );
    00090
    00099     XMLEntityDecl
    00100     (
    00101         const   XMLCh* const    entName
    00102         , const XMLCh           value
    00103         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00104     );
    00106
    00109
    00113     virtual ~XMLEntityDecl();
    00114
    00116
    00117
    00118     // -----------------------------------------------------------------------
    00119     //  Virtual entity decl interface
    00120     // -----------------------------------------------------------------------
    00121
    00124
    00132     virtual bool getDeclaredInIntSubset() const = 0;
    00133
    00139     virtual bool getIsParameter() const = 0;
    00140
    00146     virtual bool getIsSpecialChar() const = 0;
    00147
    00149
    00150
    00151     // -----------------------------------------------------------------------
    00152     //  Getter methods
    00153     // -----------------------------------------------------------------------
    00154
    00157
    00162     unsigned int getId() const;
    00163
    00169     const XMLCh* getName() const;
    00170
    00175     const XMLCh* getNotationName() const;
    00176
    00181     const XMLCh* getPublicId() const;
    00182
    00187     const XMLCh* getSystemId() const;
    00188
    00192     const XMLCh* getBaseURI() const;
    00193
    00199     const XMLCh* getValue() const;
    00200
    00206     unsigned int getValueLen() const;
    00207
    00212     bool isExternal() const;
    00213
    00219     bool isUnparsed() const;
    00220
    00228     MemoryManager* getMemoryManager() const;
    00229
    00231
    00232
    00233     // -----------------------------------------------------------------------
    00234     //  Setter methods
    00235     // -----------------------------------------------------------------------
    00236
    00239
    00248     void setName
    00249     (
    00250         const   XMLCh* const    entName
    00251     );
    00252
    00259     void setNotationName(const XMLCh* const newName);
    00260
    00267     void setPublicId(const XMLCh* const newId);
    00268
    00278     void setSystemId(const XMLCh* const newId);
    00279
    00286     void setBaseURI(const XMLCh* const newId);
    00287
    00295     void setValue(const XMLCh* const newValue);
    00296
    00298
    00299     /* For internal use only */
    00300     void setId(const unsigned int newId);
    00301
    00302
    00303     // -----------------------------------------------------------------------
    00304     //  Support named pool syntax
    00305     // -----------------------------------------------------------------------
    00306
    00309
    00316     const XMLCh* getKey() const;
    00317
    00319
    00320     /***
    00321      * Support for Serialization/De-serialization
    00322      ***/
    00323     DECL_XSERIALIZABLE(XMLEntityDecl)
    00324
    00325 private :
    00326     // -----------------------------------------------------------------------
    00327     //  Unimplemented constructors and operators
    00328     // -----------------------------------------------------------------------
    00329     XMLEntityDecl(const XMLEntityDecl&);
    00330     XMLEntityDecl& operator=(XMLEntityDecl&);
    00331
    00332
    00333     // -----------------------------------------------------------------------
    00334     //  XMLEntityDecl: Private helper methods
    00335     // -----------------------------------------------------------------------
    00336     void cleanUp();
    00337
    00338
    00339     // -----------------------------------------------------------------------
    00340     //  Private data members
    00341     //
    00342     //  fId
    00343     //      This is the unique id given to this entity decl.
    00344     //
    00345     //  fName
    00346     //      The name of the enitity. Entity names are never namespace based.
    00347     //
    00348     //  fNotationName
    00349     //      The optional notation of the entity. If there was none, then its
    00350     //      empty.
    00351     //
    00352     //  fPublicId
    00353     //      The public id of the entity, which can be empty.
    00354     //
    00355     //  fSystemId
    00356     //      The system id of the entity.
    00357     //
    00358     //  fValue
    00359     //  fValueLen
    00360     //      The entity's value and length, which is only valid if its an
    00361     //      internal style entity.
    00362     //
    00363     //  fBaseURI
    00364     //      The base URI of the entity.   According to XML InfoSet, such value
    00365     //      is the URI where it is declared (NOT referenced).
    00366     // -----------------------------------------------------------------------
    00367     unsigned int    fId;
    00368     unsigned int    fValueLen;
    00369     XMLCh*          fValue;
    00370     XMLCh*          fName;
    00371     XMLCh*          fNotationName;
    00372     XMLCh*          fPublicId;
    00373     XMLCh*          fSystemId;
    00374     XMLCh*          fBaseURI;
    00375     MemoryManager*  fMemoryManager;
    00376 };
    00377
    00378
    00379 // ---------------------------------------------------------------------------
    00380 //  XMLEntityDecl: Getter methods
    00381 // ---------------------------------------------------------------------------
    00382 inline unsigned int XMLEntityDecl::getId() const
    00383 {
    00384     return fId;
    00385 }
    00386
    00387 inline const XMLCh* XMLEntityDecl::getName() const
    00388 {
    00389     return fName;
    00390 }
    00391
    00392 inline const XMLCh* XMLEntityDecl::getNotationName() const
    00393 {
    00394     return fNotationName;
    00395 }
    00396
    00397 inline const XMLCh* XMLEntityDecl::getPublicId() const
    00398 {
    00399     return fPublicId;
    00400 }
    00401
    00402 inline const XMLCh* XMLEntityDecl::getSystemId() const
    00403 {
    00404     return fSystemId;
    00405 }
    00406
    00407 inline const XMLCh* XMLEntityDecl::getBaseURI() const
    00408 {
    00409     return fBaseURI;
    00410 }
    00411
    00412 inline const XMLCh* XMLEntityDecl::getValue() const
    00413 {
    00414     return fValue;
    00415 }
    00416
    00417 inline unsigned int XMLEntityDecl::getValueLen() const
    00418 {
    00419     return fValueLen;
    00420 }
    00421
    00422 inline bool XMLEntityDecl::isExternal() const
    00423 {
    00424     // If it has a system or public id, its external
    00425     return ((fPublicId != 0) || (fSystemId != 0));
    00426 }
    00427
    00428 inline bool XMLEntityDecl::isUnparsed() const
    00429 {
    00430     // If it has a notation, its unparsed
    00431     return (fNotationName != 0);
    00432 }
    00433
    00434 inline MemoryManager* XMLEntityDecl::getMemoryManager() const
    00435 {
    00436     return fMemoryManager;
    00437 }
    00438
    00439 // ---------------------------------------------------------------------------
    00440 //  XMLEntityDecl: Setter methods
    00441 // ---------------------------------------------------------------------------
    00442 inline void XMLEntityDecl::setId(const unsigned int newId)
    00443 {
    00444     fId = newId;
    00445 }
    00446
    00447 inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
    00448 {
    00449     if (fNotationName)
    00450         fMemoryManager->deallocate(fNotationName);
    00451
    00452     fNotationName = XMLString::replicate(newName, fMemoryManager);
    00453 }
    00454
    00455 inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
    00456 {
    00457     if (fPublicId)
    00458         fMemoryManager->deallocate(fPublicId);
    00459
    00460     fPublicId = XMLString::replicate(newId, fMemoryManager);
    00461 }
    00462
    00463 inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
    00464 {
    00465     if (fSystemId)
    00466         fMemoryManager->deallocate(fSystemId);
    00467
    00468     fSystemId = XMLString::replicate(newId, fMemoryManager);
    00469 }
    00470
    00471 inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
    00472 {
    00473     if (fBaseURI)
    00474         fMemoryManager->deallocate(fBaseURI);
    00475
    00476     fBaseURI = XMLString::replicate(newId, fMemoryManager);
    00477 }
    00478
    00479 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
    00480 {
    00481     if (fValue)
    00482         fMemoryManager->deallocate(fValue);
    00483
    00484     fValue = XMLString::replicate(newValue, fMemoryManager);
    00485     fValueLen = XMLString::stringLen(newValue);
    00486 }
    00487
    00488
    00489 // ---------------------------------------------------------------------------
    00490 //  XMLEntityDecl: Support named pool syntax
    00491 // ---------------------------------------------------------------------------
    00492 inline const XMLCh* XMLEntityDecl::getKey() const
    00493 {
    00494     return fName;
    00495 }
    00496
    00497 XERCES_CPP_NAMESPACE_END
    00498
    00499 #endif

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