2002-06-21 13:16:28 +02:00
|
|
|
#ifndef JEZUK_DOM_TEXT_H
|
|
|
|
#define JEZUK_DOM_TEXT_H
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
// C++ DOM definition
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
////////////////////////////
|
|
|
|
|
|
|
|
#include <DOM/CharacterData.h>
|
|
|
|
|
|
|
|
namespace DOM
|
|
|
|
{
|
|
|
|
template<class stringT> class Text_impl;
|
|
|
|
|
|
|
|
template<class stringT>
|
|
|
|
class Text : public CharacterData<stringT>
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
typedef CharacterData<stringT> CharDataT;
|
2002-06-21 13:16:28 +02:00
|
|
|
public:
|
|
|
|
Text() : CharacterData<stringT>() { }
|
|
|
|
explicit Text(Text_impl<stringT>* impl) : CharacterData<stringT>(impl) { }
|
|
|
|
Text(const Text& rhs) : CharacterData<stringT>(rhs) { }
|
2005-08-30 11:40:34 +02:00
|
|
|
explicit Text(const Node<stringT>& rhs) : CharacterData<stringT>(rhs, 0)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2005-08-30 11:40:34 +02:00
|
|
|
Type type = rhs.getNodeType();
|
|
|
|
if((type != Text::TEXT_NODE) && (type != Text::CDATA_SECTION_NODE))
|
2002-06-21 13:16:28 +02:00
|
|
|
throw std::bad_cast("Cannot cast Node to Text");
|
|
|
|
} // Text
|
|
|
|
|
2005-08-30 13:35:12 +02:00
|
|
|
protected:
|
|
|
|
Text(const Node<stringT>& rhs, int dummy) : CharacterData<stringT>(rhs, 0) { }
|
|
|
|
|
2002-06-21 13:16:28 +02:00
|
|
|
Text splitText(int offset)
|
|
|
|
{
|
|
|
|
return tImpl()->splitText(offset);
|
|
|
|
} // splitText
|
|
|
|
|
|
|
|
protected:
|
2004-09-18 01:17:51 +02:00
|
|
|
Text_impl<stringT>* tImpl() const { return dynamic_cast<Text_impl<stringT>*>(CharDataT::impl()); }
|
2002-06-21 13:16:28 +02:00
|
|
|
}; // class Text
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
template<class stringT>
|
|
|
|
class Text_impl : virtual public CharacterData_impl<stringT>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Text_impl() { }
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// DOM::Text methods
|
|
|
|
virtual Text_impl<stringT>* splitText(int offset) = 0;
|
|
|
|
}; // Text_impl
|
|
|
|
|
|
|
|
} // namespace DOM
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|