arabica/include/DOM/Simple/TextImpl.hpp

64 lines
1.8 KiB
C++
Raw Normal View History

2002-06-21 11:16:28 +00:00
#ifndef JEZUK_SimpleDOM_TEXTIMPL_H
#define JEZUK_SimpleDOM_TEXTIMPL_H
2007-09-04 22:55:47 +00:00
#include <DOM/Text.hpp>
#include <DOM/Simple/CharacterDataImpl.hpp>
2002-06-21 11:16:28 +00:00
2007-09-05 11:47:13 +00:00
namespace Arabica
{
2002-06-21 11:16:28 +00:00
namespace SimpleDOM
{
template<class stringT, class string_adaptorT>
class TextImpl : public DOM::Text_impl<stringT>,
public CharacterDataImpl<stringT, string_adaptorT>
{
typedef CharacterDataImpl<stringT, string_adaptorT> CharDataT;
2002-06-21 11:16:28 +00:00
public:
TextImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& data) :
DOM::Text_impl<stringT>(),
CharacterDataImpl<stringT, string_adaptorT>(ownerDoc, data)
{
} // TextImpl
virtual ~TextImpl() { }
//////////////////////////////////////////////////////////////////
// DOM::Text methods
virtual DOM::Text_impl<stringT>* splitText(int offset)
{
CharDataT::throwIfReadOnly();
2002-06-21 11:16:28 +00:00
2004-10-12 20:49:30 +00:00
stringT second = CharDataT::substringData(offset, CharDataT::getLength() - offset);
CharDataT::deleteData(offset, CharDataT::getLength() - offset);
2002-06-21 11:16:28 +00:00
TextImpl* splitNode = new TextImpl(CharDataT::getOwnerDoc(), second);
CharDataT::getParentNode()->insertBefore(splitNode, CharDataT::getNextSibling());
2002-06-21 11:16:28 +00:00
return splitNode;
} // splitText
///////////////////////////////////////////////////////
// DOM::Node methods
virtual DOM::Node_base::Type getNodeType() const
{
return DOM::Node_base::TEXT_NODE;
} // getNodeType
virtual DOM::Node_impl<stringT>* cloneNode(bool deep) const
{
return CharDataT::ownerDoc_->createTextNode(CharDataT::getData());
2002-06-21 11:16:28 +00:00
} // cloneNode
2005-12-09 14:09:32 +00:00
virtual const stringT& getNodeName() const
2002-06-21 11:16:28 +00:00
{
2005-12-09 14:09:32 +00:00
static const stringT text = string_adaptorT::construct_from_utf8("#text");
return text;
2002-06-21 11:16:28 +00:00
} // getNodeName
}; // class TextImpl
} // namespace SAX2DOM
2007-09-05 11:47:13 +00:00
} // namespace Arabica
2002-06-21 11:16:28 +00:00
#endif