arabica/include/DOM/Simple/EntityImpl.hpp

94 lines
2.9 KiB
C++
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_SimpleDOM_ENTITYIMPL_H
#define JEZUK_SimpleDOM_ENTITYIMPL_H
2007-09-05 00:55:47 +02:00
#include <DOM/Entity.hpp>
#include <DOM/Simple/NodeImpl.hpp>
2002-06-21 13:16:28 +02:00
2007-09-05 13:47:13 +02:00
namespace Arabica
{
2002-06-21 13:16:28 +02:00
namespace SimpleDOM
{
template<class stringT, class string_adaptorT>
class EntityImpl : public DOM::Entity_impl<stringT, string_adaptorT>,
2002-06-21 13:16:28 +02:00
public NodeImplWithChildren<stringT, string_adaptorT>
{
public:
typedef NodeImplWithChildren<stringT, string_adaptorT> NodeImplWithChildrenT;
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
2002-06-21 13:16:28 +02:00
EntityImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc,
stringT name,
stringT publicId,
stringT systemId,
stringT notationName) :
DOM::Entity_impl<stringT, string_adaptorT>(),
NodeImplWithChildrenT(ownerDoc),
2002-06-21 13:16:28 +02:00
name_(name),
publicId_(publicId),
systemId_(systemId),
notationName_(notationName)
{
} // EntityImpl
virtual ~EntityImpl() { }
///////////////////////////////////////////////////////
// DOM::Entity methods
virtual stringT getPublicId() const { return publicId_; }
virtual stringT getSystemId() const { return systemId_; }
virtual stringT getNotationName() const { return notationName_; }
///////////////////////////////////////////////////////
// DOM::Node methods
virtual typename DOM::Node_base::Type getNodeType() const
2002-06-21 13:16:28 +02:00
{
return DOM::Node_base::ENTITY_NODE;
2002-06-21 13:16:28 +02:00
} // getNodeType
2005-12-09 15:09:32 +01:00
virtual const stringT& getNodeName() const
2002-06-21 13:16:28 +02:00
{
return name_;
} // getNodeName
virtual DOMNode_implT* cloneNode(bool deep) const
2002-06-21 13:16:28 +02:00
{
EntityImpl* clone = new EntityImpl(NodeImplWithChildrenT::ownerDoc_, name_, publicId_, systemId_, notationName_);
2002-06-21 13:16:28 +02:00
if(deep)
for(DOMNode_implT* c = NodeImplWithChildrenT::getFirstChild(); c != 0; c = c->getNextSibling())
2002-06-21 13:16:28 +02:00
clone->appendChild(c->cloneNode(true));
NodeImplWithChildrenT::ownerDoc_->orphaned(clone);
2002-06-21 13:16:28 +02:00
return clone;
} // cloneNode
virtual DOMNode_implT* getParentNode() const
2002-06-21 13:16:28 +02:00
{
return 0;
} // getParentNode
///////////////////////////////////////////////
virtual void checkChildType(DOMNode_implT* child)
2002-06-21 13:16:28 +02:00
{
typename DOM::Node_base::Type type = child->getNodeType();
if((type != DOM::Node_base::ELEMENT_NODE) &&
(type != DOM::Node_base::PROCESSING_INSTRUCTION_NODE) &&
(type != DOM::Node_base::COMMENT_NODE) &&
(type != DOM::Node_base::TEXT_NODE) &&
(type != DOM::Node_base::CDATA_SECTION_NODE) &&
(type != DOM::Node_base::ENTITY_REFERENCE_NODE))
2002-06-21 13:16:28 +02:00
throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR);
} // checkChildType
private:
stringT name_;
stringT publicId_;
stringT systemId_;
stringT notationName_;
}; // class EntityImpl
} // namespace SAX2DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif