Xerces-C++: XMLEntityDecl.hpp Source File

| API Docs for SAX and DOM |
| Main Page Classes Files Related Pages # 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 568078 2007-08-21 11:43:25Z amassari $
    00020  */
    00021
    00022 #if !defined(XMLENTITYDECL_HPP)
    00023 #define 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  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     unsigned int 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     unsigned int 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
    00260     void setNotationName(const XMLCh* const newName);
    00261
    00268     void setPublicId(const XMLCh* const newId);
    00269
    00279     void setSystemId(const XMLCh* const newId);
    00280
    00287     void setBaseURI(const XMLCh* const newId);
    00288
    00296     void setValue(const XMLCh* const newValue);
    00297
    00299
    00300     /* For internal use only */
    00301     void setId(const unsigned int newId);
    00302
    00303
    00304     // -----------------------------------------------------------------------
    00305     //  Support named pool syntax
    00306     // -----------------------------------------------------------------------
    00307
    00310
    00317     const XMLCh* getKey() const;
    00318
    00320
    00321     /***
    00322      * Support for Serialization/De-serialization
    00323      ***/
    00324     DECL_XSERIALIZABLE(XMLEntityDecl)
    00325
    00326 private :
    00327     // -----------------------------------------------------------------------
    00328     //  Unimplemented constructors and operators
    00329     // -----------------------------------------------------------------------
    00330     XMLEntityDecl(const XMLEntityDecl&);
    00331     XMLEntityDecl& operator=(XMLEntityDecl&);
    00332
    00333
    00334     // -----------------------------------------------------------------------
    00335     //  XMLEntityDecl: Private helper methods
    00336     // -----------------------------------------------------------------------
    00337     void cleanUp();
    00338
    00339
    00340     // -----------------------------------------------------------------------
    00341     //  Private data members
    00342     //
    00343     //  fId
    00344     //      This is the unique id given to this entity decl.
    00345     //
    00346     //  fName
    00347     //      The name of the enitity. Entity names are never namespace based.
    00348     //
    00349     //  fNotationName
    00350     //      The optional notation of the entity. If there was none, then its
    00351     //      empty.
    00352     //
    00353     //  fPublicId
    00354     //      The public id of the entity, which can be empty.
    00355     //
    00356     //  fSystemId
    00357     //      The system id of the entity.
    00358     //
    00359     //  fValue
    00360     //  fValueLen
    00361     //      The entity's value and length, which is only valid if its an
    00362     //      internal style entity.
    00363     //
    00364     //  fBaseURI
    00365     //      The base URI of the entity.   According to XML InfoSet, such value
    00366     //      is the URI where it is declared (NOT referenced).
    00367     // -----------------------------------------------------------------------
    00368     unsigned int    fId;
    00369     unsigned int    fValueLen;
    00370     XMLCh*          fValue;
    00371     XMLCh*          fName;
    00372     XMLCh*          fNotationName;
    00373     XMLCh*          fPublicId;
    00374     XMLCh*          fSystemId;
    00375     XMLCh*          fBaseURI;
    00376     MemoryManager*  fMemoryManager;
    00377 };
    00378
    00379
    00380 // ---------------------------------------------------------------------------
    00381 //  XMLEntityDecl: Getter methods
    00382 // ---------------------------------------------------------------------------
    00383 inline unsigned int XMLEntityDecl::getId() const
    00384 {
    00385     return fId;
    00386 }
    00387
    00388 inline const XMLCh* XMLEntityDecl::getName() const
    00389 {
    00390     return fName;
    00391 }
    00392
    00393 inline const XMLCh* XMLEntityDecl::getNotationName() const
    00394 {
    00395     return fNotationName;
    00396 }
    00397
    00398 inline const XMLCh* XMLEntityDecl::getPublicId() const
    00399 {
    00400     return fPublicId;
    00401 }
    00402
    00403 inline const XMLCh* XMLEntityDecl::getSystemId() const
    00404 {
    00405     return fSystemId;
    00406 }
    00407
    00408 inline const XMLCh* XMLEntityDecl::getBaseURI() const
    00409 {
    00410     return fBaseURI;
    00411 }
    00412
    00413 inline const XMLCh* XMLEntityDecl::getValue() const
    00414 {
    00415     return fValue;
    00416 }
    00417
    00418 inline unsigned int XMLEntityDecl::getValueLen() const
    00419 {
    00420     return fValueLen;
    00421 }
    00422
    00423 inline bool XMLEntityDecl::isExternal() const
    00424 {
    00425     // If it has a system or public id, its external
    00426     return ((fPublicId != 0) || (fSystemId != 0));
    00427 }
    00428
    00429 inline bool XMLEntityDecl::isUnparsed() const
    00430 {
    00431     // If it has a notation, its unparsed
    00432     return (fNotationName != 0);
    00433 }
    00434
    00435 inline MemoryManager* XMLEntityDecl::getMemoryManager() const
    00436 {
    00437     return fMemoryManager;
    00438 }
    00439
    00440 // ---------------------------------------------------------------------------
    00441 //  XMLEntityDecl: Setter methods
    00442 // ---------------------------------------------------------------------------
    00443 inline void XMLEntityDecl::setId(const unsigned int newId)
    00444 {
    00445     fId = newId;
    00446 }
    00447
    00448 inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
    00449 {
    00450     if (fNotationName)
    00451         fMemoryManager->deallocate(fNotationName);
    00452
    00453     fNotationName = XMLString::replicate(newName, fMemoryManager);
    00454 }
    00455
    00456 inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
    00457 {
    00458     if (fPublicId)
    00459         fMemoryManager->deallocate(fPublicId);
    00460
    00461     fPublicId = XMLString::replicate(newId, fMemoryManager);
    00462 }
    00463
    00464 inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
    00465 {
    00466     if (fSystemId)
    00467         fMemoryManager->deallocate(fSystemId);
    00468
    00469     fSystemId = XMLString::replicate(newId, fMemoryManager);
    00470 }
    00471
    00472 inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
    00473 {
    00474     if (fBaseURI)
    00475         fMemoryManager->deallocate(fBaseURI);
    00476
    00477     fBaseURI = XMLString::replicate(newId, fMemoryManager);
    00478 }
    00479
    00480 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
    00481 {
    00482     if (fValue)
    00483         fMemoryManager->deallocate(fValue);
    00484
    00485     fValue = XMLString::replicate(newValue, fMemoryManager);
    00486     fValueLen = XMLString::stringLen(newValue);
    00487 }
    00488
    00489
    00490 // ---------------------------------------------------------------------------
    00491 //  XMLEntityDecl: Support named pool syntax
    00492 // ---------------------------------------------------------------------------
    00493 inline const XMLCh* XMLEntityDecl::getKey() const
    00494 {
    00495     return fName;
    00496 }
    00497
    00498 XERCES_CPP_NAMESPACE_END
    00499
    00500 #endif

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