XMLElementDecl.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_XMLELEMENTDECL_HPP)
#define XERCESC_INCLUDE_GUARD_XMLELEMENTDECL_HPP
#include <xercesc/framework/XMLAttr.hpp>
#include <xercesc/framework/XMLAttDefList.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
class XMLContentModel;
class XMLPARSER_EXPORT XMLElementDecl : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Class specific types
//
// CreateReasons
// This type is used to store how an element declaration got into
// the grammar's element pool. They are faulted in for various
// reasons.
//
// LookupOpts
// These are the values used by the attribute lookup methods.
//
// CharDataOpts
// This is used to indicate how this type of element reacts to
// character data as content.
// -----------------------------------------------------------------------
enum CreateReasons
{
NoReason
, Declared
, AttList
, InContentModel
, AsRootElem
, JustFaultIn
};
enum CharDataOpts
{
NoCharData
, SpacesOk
, AllCharData
};
// -----------------------------------------------------------------------
// Public static data
//
// fgInvalidElemId
// A value to represent an invalid element node id.
//
// fgPCDataElemId
// This is the value to use to represent a PCDATA node when an
// element id is required.
//
// fgPCDataElemName
// This is the value to use to represent a PCDATA node when an
// element name is required.
// -----------------------------------------------------------------------
static const unsigned int fgInvalidElemId;
static const unsigned int fgPCDataElemId;
static const XMLCh fgPCDataElemName[];
// -----------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------
virtual ~XMLElementDecl();
// -----------------------------------------------------------------------
// The virtual element decl interface
// -----------------------------------------------------------------------
virtual XMLAttDefList& getAttDefList() const = 0;
virtual CharDataOpts getCharDataOpts() const = 0;
virtual bool hasAttDefs() const = 0;
virtual const ContentSpecNode* getContentSpec() const = 0;
virtual ContentSpecNode* getContentSpec() = 0;
virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
virtual XMLContentModel* getContentModel() = 0;
virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
virtual const XMLCh* getFormattedContentModel () const = 0;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const XMLCh* getBaseName() const;
XMLCh* getBaseName();
unsigned int getURI() const;
const QName* getElementName() const;
QName* getElementName();
const XMLCh* getFullName() const;
CreateReasons getCreateReason() const;
XMLSize_t getId() const;
bool isDeclared() const;
bool isExternal() const;
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setElementName(const XMLCh* const prefix
, const XMLCh* const localPart
, const int uriId );
void setElementName(const XMLCh* const rawName
, const int uriId );
void setElementName(const QName* const elementName);
void setCreateReason(const CreateReasons newReason);
void setId(const XMLSize_t newId);
void setExternalElemDeclaration(const bool aValue);
// -----------------------------------------------------------------------
// Miscellaneous methods
// -----------------------------------------------------------------------
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLElementDecl)
enum objectType
{
Schema
, DTD
, UnKnown
};
virtual XMLElementDecl::objectType getObjectType() const = 0;
static void storeElementDecl(XSerializeEngine& serEng
, XMLElementDecl* const element);
static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLElementDecl(const XMLElementDecl&);
XMLElementDecl& operator=(const XMLElementDecl&);
// -----------------------------------------------------------------------
// Data members
//
// fElementName
// This is the name of the element decl.
//
// fCreateReason
// We sometimes have to put an element decl object into the elem
// decl pool before the element's declaration is seen, such as when
// its used in another element's content model or an att list is
// seen for it. This flag tells us whether its been declared, and
// if not why it had to be created.
//
// fId
// The unique id of this element. This is created by the derived
// class, or more accurately the grammar that owns the objects
// of the derived types. But, since they all have to have them, we
// let them all store the id here. It is defaulted to have the
// value fgInvalidElem until explicitly set.
//
// fExternalElement
// This flag indicates whether or the element was declared externally.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
QName* fElementName;
CreateReasons fCreateReason;
XMLSize_t fId;
bool fExternalElement;
};
// ---------------------------------------------------------------------------
// XMLElementDecl: Getter methods
// ---------------------------------------------------------------------------
inline const XMLCh* XMLElementDecl::getBaseName() const
{
return fElementName->getLocalPart();
}
inline XMLCh* XMLElementDecl::getBaseName()
{
return fElementName->getLocalPart();
}
inline unsigned int XMLElementDecl::getURI() const
{
return fElementName->getURI();
}
inline const QName* XMLElementDecl::getElementName() const
{
return fElementName;
}
inline QName* XMLElementDecl::getElementName()
{
return fElementName;
}
inline const XMLCh* XMLElementDecl::getFullName() const
{
return fElementName->getRawName();
}
inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
{
return fCreateReason;
}
inline XMLSize_t XMLElementDecl::getId() const
{
return fId;
}
inline bool XMLElementDecl::isDeclared() const
{
return (fCreateReason == Declared);
}
inline bool XMLElementDecl::isExternal() const
{
return fExternalElement;
}
inline MemoryManager* XMLElementDecl::getMemoryManager() const
{
return fMemoryManager;
}
// ---------------------------------------------------------------------------
// XMLElementDecl: Setter methods
// ---------------------------------------------------------------------------
inline void
XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
{
fCreateReason = newReason;
}
inline void XMLElementDecl::setId(const XMLSize_t newId)
{
fId = newId;
}
inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
{
fExternalElement = aValue;
}
XERCES_CPP_NAMESPACE_END
#endif
PlatformUtils.hpp
XMLAttDefList.hpp
XMLAttr.hpp
XMLString.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
QName
Definition QName.hpp:35
QName::getLocalPart
const XMLCh * getLocalPart() const
Definition QName.hpp:177
QName::getRawName
const XMLCh * getRawName() const
QName::getURI
unsigned int getURI() const
Definition QName.hpp:187
XMLAttDefList
This class defines an abstract interface that all validators must support.
Definition XMLAttDefList.hpp:51
XMLContentModel
This class defines the abstract interface for all content models.
Definition XMLContentModel.hpp:47
XMLElementDecl
This class defines the core information of an element declaration.
Definition XMLElementDecl.hpp:52
XMLElementDecl::getFullName
const XMLCh * getFullName() const
Get the full name of this element type.
Definition XMLElementDecl.hpp:498
XMLElementDecl::loadElementDecl
static XMLElementDecl * loadElementDecl(XSerializeEngine &serEng)
XMLElementDecl::setContentSpec
virtual void setContentSpec(ContentSpecNode *toAdopt)=0
Set the content spec node object for this element type.
XMLElementDecl::CreateReasons
CreateReasons
Definition XMLElementDecl.hpp:70
XMLElementDecl::Declared
@ Declared
Definition XMLElementDecl.hpp:72
XMLElementDecl::getFormattedContentModel
virtual const XMLCh * getFormattedContentModel() const =0
Geta formatted string of the content model.
XMLElementDecl::XMLElementDecl
XMLElementDecl(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
XMLElementDecl::setCreateReason
void setCreateReason(const CreateReasons newReason)
Update the create reason for this element type.
Definition XMLElementDecl.hpp:534
XMLElementDecl::hasAttDefs
virtual bool hasAttDefs() const =0
Indicate whether this element type defined any attributes.
XMLElementDecl::getMemoryManager
MemoryManager * getMemoryManager() const
Get the memory manager.
Definition XMLElementDecl.hpp:524
XMLElementDecl::objectType
objectType
Definition XMLElementDecl.hpp:412
XMLElementDecl::getId
XMLSize_t getId() const
Get the element decl pool id for this element type.
Definition XMLElementDecl.hpp:508
XMLElementDecl::CharDataOpts
CharDataOpts
Definition XMLElementDecl.hpp:80
XMLElementDecl::getAttDefList
virtual XMLAttDefList & getAttDefList() const =0
Get a list of attributes defined for this element.
XMLElementDecl::setElementName
void setElementName(const XMLCh *const prefix, const XMLCh *const localPart, const int uriId)
Set the element name object for this element type.
XMLElementDecl::getElementName
const QName * getElementName() const
Get the QName of this element type.
Definition XMLElementDecl.hpp:488
XMLElementDecl::isExternal
bool isExternal() const
Indicate whether this element type has been declared externally.
Definition XMLElementDecl.hpp:519
XMLElementDecl::getBaseName
const XMLCh * getBaseName() const
Get the base name of this element type.
Definition XMLElementDecl.hpp:473
XMLElementDecl::setElementName
void setElementName(const QName *const elementName)
Set the element name object for this element type.
XMLElementDecl::isDeclared
bool isDeclared() const
Indicate whether this element type has been declared yet.
Definition XMLElementDecl.hpp:513
XMLElementDecl::fgPCDataElemId
static const unsigned int fgPCDataElemId
Definition XMLElementDecl.hpp:102
XMLElementDecl::getContentSpec
virtual ContentSpecNode * getContentSpec()=0
Get a pointer to the content spec node.
XMLElementDecl::setElementName
void setElementName(const XMLCh *const rawName, const int uriId)
Set the element name object for this element type.
XMLElementDecl::storeElementDecl
static void storeElementDecl(XSerializeEngine &serEng, XMLElementDecl *const element)
XMLElementDecl::setContentModel
virtual void setContentModel(XMLContentModel *const newModelToAdopt)=0
Set the content model object for this element type.
XMLElementDecl::setId
void setId(const XMLSize_t newId)
Set the element decl pool id for this element type.
Definition XMLElementDecl.hpp:539
XMLElementDecl::getCreateReason
CreateReasons getCreateReason() const
Get the create reason for this element type.
Definition XMLElementDecl.hpp:503
XMLElementDecl::getURI
unsigned int getURI() const
Get the URI id of this element type.
Definition XMLElementDecl.hpp:483
XMLElementDecl::fgInvalidElemId
static const unsigned int fgInvalidElemId
Definition XMLElementDecl.hpp:101
XMLElementDecl::getObjectType
virtual XMLElementDecl::objectType getObjectType() const =0
XMLElementDecl::~XMLElementDecl
virtual ~XMLElementDecl()
XMLElementDecl::setExternalElemDeclaration
void setExternalElemDeclaration(const bool aValue)
Set the element decl to indicate external declaration.
Definition XMLElementDecl.hpp:545
XMLElementDecl::getContentModel
virtual XMLContentModel * getContentModel()=0
Get a pointer to the abstract content model.
XMLElementDecl::getContentSpec
virtual const ContentSpecNode * getContentSpec() const =0
Get a pointer to the content spec node.
XMLElementDecl::getCharDataOpts
virtual CharDataOpts getCharDataOpts() const =0
The character data options for this element type.
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41