XMLEntityDecl.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id$
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLENTITYDECL_HPP)
#define XERCESC_INCLUDE_GUARD_XMLENTITYDECL_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLPARSER_EXPORT XMLEntityDecl : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLEntityDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XMLEntityDecl
(
const XMLCh* const entName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLEntityDecl
(
const XMLCh* const entName
, const XMLCh* const value
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLEntityDecl
(
const XMLCh* const entName
, const XMLCh value
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLEntityDecl();
// -----------------------------------------------------------------------
// Virtual entity decl interface
// -----------------------------------------------------------------------
virtual bool getDeclaredInIntSubset() const = 0;
virtual bool getIsParameter() const = 0;
virtual bool getIsSpecialChar() const = 0;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLSize_t getId() const;
const XMLCh* getName() const;
const XMLCh* getNotationName() const;
const XMLCh* getPublicId() const;
const XMLCh* getSystemId() const;
const XMLCh* getBaseURI() const;
const XMLCh* getValue() const;
XMLSize_t getValueLen() const;
bool isExternal() const;
bool isUnparsed() const;
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setName
(
const XMLCh* const entName
);
void setIsExternal(bool value);
void setNotationName(const XMLCh* const newName);
void setPublicId(const XMLCh* const newId);
void setSystemId(const XMLCh* const newId);
void setBaseURI(const XMLCh* const newId);
void setValue(const XMLCh* const newValue);
/* For internal use only */
void setId(const XMLSize_t newId);
// -----------------------------------------------------------------------
// Support named pool syntax
// -----------------------------------------------------------------------
const XMLCh* getKey() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLEntityDecl)
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLEntityDecl(const XMLEntityDecl&);
XMLEntityDecl& operator=(XMLEntityDecl&);
// -----------------------------------------------------------------------
// XMLEntityDecl: Private helper methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Private data members
//
// fId
// This is the unique id given to this entity decl.
//
// fName
// The name of the entity. Entity names are never namespace based.
//
// fNotationName
// The optional notation of the entity. If there was none, then its
// empty.
//
// fPublicId
// The public id of the entity, which can be empty.
//
// fSystemId
// The system id of the entity.
//
// fValue
// fValueLen
// The entity's value and length, which is only valid if its an
// internal style entity.
//
// fBaseURI
// The base URI of the entity. According to XML InfoSet, such value
// is the URI where it is declared (NOT referenced).
// -----------------------------------------------------------------------
XMLSize_t fId;
XMLSize_t fValueLen;
XMLCh* fValue;
XMLCh* fName;
XMLCh* fNotationName;
XMLCh* fPublicId;
XMLCh* fSystemId;
XMLCh* fBaseURI;
bool fIsExternal;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XMLEntityDecl: Getter methods
// ---------------------------------------------------------------------------
inline XMLSize_t XMLEntityDecl::getId() const
{
return fId;
}
inline const XMLCh* XMLEntityDecl::getName() const
{
return fName;
}
inline const XMLCh* XMLEntityDecl::getNotationName() const
{
return fNotationName;
}
inline const XMLCh* XMLEntityDecl::getPublicId() const
{
return fPublicId;
}
inline const XMLCh* XMLEntityDecl::getSystemId() const
{
return fSystemId;
}
inline const XMLCh* XMLEntityDecl::getBaseURI() const
{
return fBaseURI;
}
inline const XMLCh* XMLEntityDecl::getValue() const
{
return fValue;
}
inline XMLSize_t XMLEntityDecl::getValueLen() const
{
return fValueLen;
}
inline bool XMLEntityDecl::isExternal() const
{
return fIsExternal;
}
inline bool XMLEntityDecl::isUnparsed() const
{
// If it has a notation, its unparsed
return (fNotationName != 0);
}
inline MemoryManager* XMLEntityDecl::getMemoryManager() const
{
return fMemoryManager;
}
// ---------------------------------------------------------------------------
// XMLEntityDecl: Setter methods
// ---------------------------------------------------------------------------
inline void XMLEntityDecl::setId(const XMLSize_t newId)
{
fId = newId;
}
inline void XMLEntityDecl::setIsExternal(bool value)
{
fIsExternal = value;
}
inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
{
if (fNotationName)
fMemoryManager->deallocate(fNotationName);
fNotationName = XMLString::replicate(newName, fMemoryManager);
}
inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
{
if (fPublicId)
fMemoryManager->deallocate(fPublicId);
fPublicId = XMLString::replicate(newId, fMemoryManager);
}
inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
{
if (fSystemId)
fMemoryManager->deallocate(fSystemId);
fSystemId = XMLString::replicate(newId, fMemoryManager);
}
inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
{
if (fBaseURI)
fMemoryManager->deallocate(fBaseURI);
fBaseURI = XMLString::replicate(newId, fMemoryManager);
}
inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
{
if (fValue)
fMemoryManager->deallocate(fValue);
fValue = XMLString::replicate(newValue, fMemoryManager);
fValueLen = XMLString::stringLen(newValue);
}
// ---------------------------------------------------------------------------
// XMLEntityDecl: Support named pool syntax
// ---------------------------------------------------------------------------
inline const XMLCh* XMLEntityDecl::getKey() const
{
return fName;
}
XERCES_CPP_NAMESPACE_END
#endif
PlatformUtils.hpp
XMLString.hpp
XMemory.hpp
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
XMLSize_t
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
XMLCh
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
MemoryManager
Configurable memory manager.
Definition MemoryManager.hpp:40
MemoryManager::deallocate
virtual void deallocate(void *p)=0
This method deallocates memory.
XMLEntityDecl
This class defines that core information that defines an XML entity, no matter what validator is used...
Definition XMLEntityDecl.hpp:51
XMLEntityDecl::getSystemId
const XMLCh * getSystemId() const
Gets the system id declared for this entity.
Definition XMLEntityDecl.hpp:411
XMLEntityDecl::isExternal
bool isExternal() const
Indicates that this entity is an external entity.
Definition XMLEntityDecl.hpp:431
XMLEntityDecl::isUnparsed
bool isUnparsed() const
Indicates whether this entity is unparsed.
Definition XMLEntityDecl.hpp:436
XMLEntityDecl::getId
XMLSize_t getId() const
Gets the pool id of this entity.
Definition XMLEntityDecl.hpp:391
XMLEntityDecl::getIsParameter
virtual bool getIsParameter() const =0
Get the 'is parameter entity' flag.
XMLEntityDecl::getMemoryManager
MemoryManager * getMemoryManager() const
Get the plugged-in memory manager.
Definition XMLEntityDecl.hpp:442
XMLEntityDecl::setPublicId
void setPublicId(const XMLCh *const newId)
This method will set a new public id on this entity.
Definition XMLEntityDecl.hpp:468
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(const XMLCh *const entName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name.
XMLEntityDecl::~XMLEntityDecl
virtual ~XMLEntityDecl()
Default destructor.
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(const XMLCh *const entName, const XMLCh value, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name and single XMLCh value.
XMLEntityDecl::getPublicId
const XMLCh * getPublicId() const
Gets the public id declared for this entity.
Definition XMLEntityDecl.hpp:406
XMLEntityDecl::setId
void setId(const XMLSize_t newId)
Definition XMLEntityDecl.hpp:450
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Default Constructor.
XMLEntityDecl::getNotationName
const XMLCh * getNotationName() const
Gets the notation name, if any, declared for this entity.
Definition XMLEntityDecl.hpp:401
XMLEntityDecl::getBaseURI
const XMLCh * getBaseURI() const
Gets the base URI for this entity.
Definition XMLEntityDecl.hpp:416
XMLEntityDecl::setNotationName
void setNotationName(const XMLCh *const newName)
This method will set the notation name for this entity.
Definition XMLEntityDecl.hpp:460
XMLEntityDecl::setIsExternal
void setIsExternal(bool value)
This method will mark whether the entity is external.
Definition XMLEntityDecl.hpp:455
XMLEntityDecl::getIsSpecialChar
virtual bool getIsSpecialChar() const =0
Get the 'is special char entity' flag.
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(const XMLCh *const entName, const XMLCh *const value, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name and value.
XMLEntityDecl::setBaseURI
void setBaseURI(const XMLCh *const newId)
This method will set a new baseURI on this entity.
Definition XMLEntityDecl.hpp:484
XMLEntityDecl::setName
void setName(const XMLCh *const entName)
This method will set the entity name.
XMLEntityDecl::getValueLen
XMLSize_t getValueLen() const
This method returns the number of characters in the value returned by getValue().
Definition XMLEntityDecl.hpp:426
XMLEntityDecl::getKey
const XMLCh * getKey() const
This method allows objects of this class to be used within a standard keyed collection used commonly ...
Definition XMLEntityDecl.hpp:505
XMLEntityDecl::setSystemId
void setSystemId(const XMLCh *const newId)
This method will set a new sysetm id on this entity.
Definition XMLEntityDecl.hpp:476
XMLEntityDecl::setValue
void setValue(const XMLCh *const newValue)
This method will set a new value for this entity.
Definition XMLEntityDecl.hpp:492
XMLEntityDecl::getName
const XMLCh * getName() const
Returns a const pointer to the name of this entity decl.
Definition XMLEntityDecl.hpp:396
XMLEntityDecl::getValue
const XMLCh * getValue() const
This method returns the value of an internal entity.
Definition XMLEntityDecl.hpp:421
XMLEntityDecl::getDeclaredInIntSubset
virtual bool getDeclaredInIntSubset() const =0
Get the 'declared in internal subset' flag.
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
XMLString::stringLen
static XMLSize_t stringLen(const char *const src)
Get the length of the string.
XMLString::replicate
static char * replicate(const char *const toRep, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Replicates a string NOTE: The returned buffer is allocated with the MemoryManager.
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41