arabica/include/DOM/Simple/EntityReferenceImpl.hpp

76 lines
2.3 KiB
C++
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_SimpleDOM_ENTITYREFERENCEIMPL_H
#define JEZUK_SimpleDOM_ENTITYREFERENCEIMPL_H
2007-09-05 00:55:47 +02:00
#include <DOM/EntityReference.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 EntityReferenceImpl : public DOM::EntityReference_impl<stringT, string_adaptorT>,
2002-06-21 13:16:28 +02:00
public NodeImplWithChildren<stringT, string_adaptorT>
{
typedef NodeImplWithChildren<stringT, string_adaptorT> NodeT;
2002-06-21 13:16:28 +02:00
public:
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
2002-06-21 13:16:28 +02:00
EntityReferenceImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT name) :
DOM::EntityReference_impl<stringT, string_adaptorT>(),
2002-06-21 13:16:28 +02:00
NodeImplWithChildren<stringT, string_adaptorT>(ownerDoc),
name_(name)
{
} // EntityReferenceImpl
virtual ~EntityReferenceImpl() { }
///////////////////////////////////////////////////////
// DOM::Node methods
virtual DOM::Node_base::Type getNodeType() const
{
return DOM::Node_base::ENTITY_REFERENCE_NODE;
} // 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 void setNodeValue(const stringT& x)
{
throw DOM::DOMException(DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR);
} // setNodeValue
virtual DOMNode_implT* cloneNode(bool deep) const
2002-06-21 13:16:28 +02:00
{
return NodeT::ownerDoc_->createEntityReference(name_);
2002-06-21 13:16:28 +02:00
} // cloneNode
//////////////////////////////////////////////////////
// this implementation
private:
virtual void checkChildType(DOMNode_implT* child)
2002-06-21 13:16:28 +02:00
{
if(NodeT::readOnly_)
2002-06-21 13:16:28 +02:00
throw DOM::DOMException(DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR);
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
stringT name_;
}; // class EntityReferenceImpl
} // namespace SAX2DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif