arabica/include/DOM/Simple/TextImpl.hpp

67 lines
2 KiB
C++
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_SimpleDOM_TEXTIMPL_H
#define JEZUK_SimpleDOM_TEXTIMPL_H
2007-09-05 00:55:47 +02:00
#include <DOM/Text.hpp>
#include <DOM/Simple/CharacterDataImpl.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 TextImpl : public DOM::Text_impl<stringT, string_adaptorT>,
2002-06-21 13:16:28 +02:00
public CharacterDataImpl<stringT, string_adaptorT>
{
public:
typedef CharacterDataImpl<stringT, string_adaptorT> CharacterDataT;
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
typedef DOM::Text_impl<stringT, string_adaptorT> DOMText_implT;
2002-06-21 13:16:28 +02:00
TextImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& data) :
DOMText_implT(),
2002-06-21 13:16:28 +02:00
CharacterDataImpl<stringT, string_adaptorT>(ownerDoc, data)
{
} // TextImpl
virtual ~TextImpl() { }
//////////////////////////////////////////////////////////////////
// DOM::Text methods
virtual DOMText_implT* splitText(int offset)
2002-06-21 13:16:28 +02:00
{
CharacterDataT::throwIfReadOnly();
2002-06-21 13:16:28 +02:00
stringT second = CharacterDataT::substringData(offset, CharacterDataT::getLength() - offset);
CharacterDataT::deleteData(offset, CharacterDataT::getLength() - offset);
2002-06-21 13:16:28 +02:00
TextImpl* splitNode = new TextImpl(CharacterDataT::getOwnerDoc(), second);
CharacterDataT::getParentNode()->insertBefore(splitNode, CharacterDataT::getNextSibling());
2002-06-21 13:16:28 +02:00
return splitNode;
} // splitText
///////////////////////////////////////////////////////
// DOM::Node methods
virtual DOM::Node_base::Type getNodeType() const
{
return DOM::Node_base::TEXT_NODE;
} // getNodeType
virtual DOMNode_implT* cloneNode(bool deep) const
2002-06-21 13:16:28 +02:00
{
return CharacterDataT::ownerDoc_->createTextNode(CharacterDataT::getData());
2002-06-21 13:16:28 +02:00
} // cloneNode
2005-12-09 15:09:32 +01:00
virtual const stringT& getNodeName() const
2002-06-21 13:16:28 +02:00
{
2005-12-09 15:09:32 +01:00
static const stringT text = string_adaptorT::construct_from_utf8("#text");
return text;
2002-06-21 13:16:28 +02:00
} // getNodeName
}; // class TextImpl
} // namespace SAX2DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif