2002-06-21 11:16:28 +00:00
|
|
|
#ifndef JEZUK_DOM_TEXT_H
|
|
|
|
#define JEZUK_DOM_TEXT_H
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
// C++ DOM definition
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
////////////////////////////
|
|
|
|
|
2007-09-04 22:55:47 +00:00
|
|
|
#include <DOM/CharacterData.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 DOM
|
|
|
|
{
|
2007-09-07 22:03:27 +00:00
|
|
|
template<class stringT, class string_adaptorT> class Text_impl;
|
2002-06-21 11:16:28 +00:00
|
|
|
|
2007-09-08 22:31:24 +00:00
|
|
|
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
|
2007-09-07 22:03:27 +00:00
|
|
|
class Text : public CharacterData<stringT, string_adaptorT>
|
2002-06-21 11:16:28 +00:00
|
|
|
{
|
2007-09-07 22:03:27 +00:00
|
|
|
typedef Text_impl<stringT, string_adaptorT> Text_implT;
|
2002-06-21 11:16:28 +00:00
|
|
|
public:
|
2007-09-07 22:03:27 +00:00
|
|
|
typedef Node<stringT, string_adaptorT> NodeT;
|
|
|
|
typedef CharacterData<stringT, string_adaptorT> CharacterDataT;
|
|
|
|
|
|
|
|
Text() : CharacterDataT() { }
|
|
|
|
explicit Text(Text_implT* impl) : CharacterDataT(impl) { }
|
|
|
|
Text(const Text& rhs) : CharacterDataT(rhs) { }
|
|
|
|
explicit Text(const NodeT& rhs) : CharacterDataT(rhs, 0)
|
2002-06-21 11:16:28 +00:00
|
|
|
{
|
2005-10-22 03:17:39 +00:00
|
|
|
typename Text::Type type = rhs.getNodeType();
|
2005-08-30 09:40:34 +00:00
|
|
|
if((type != Text::TEXT_NODE) && (type != Text::CDATA_SECTION_NODE))
|
2005-12-09 11:46:53 +00:00
|
|
|
//throw std::runtime_error("bad_cast: Cannot cast Node to Text");
|
|
|
|
throw std::bad_cast();
|
2002-06-21 11:16:28 +00:00
|
|
|
} // Text
|
|
|
|
|
2005-08-30 11:35:12 +00:00
|
|
|
protected:
|
2007-09-07 22:03:27 +00:00
|
|
|
Text(const NodeT& rhs, int dummy) : CharacterDataT(rhs, 0) { }
|
2005-08-30 11:35:12 +00:00
|
|
|
|
2002-06-21 11:16:28 +00:00
|
|
|
Text splitText(int offset)
|
|
|
|
{
|
|
|
|
return tImpl()->splitText(offset);
|
|
|
|
} // splitText
|
|
|
|
|
|
|
|
protected:
|
2007-09-07 22:03:27 +00:00
|
|
|
Text_implT* tImpl() const { return dynamic_cast<Text_implT*>(CharacterDataT::impl()); }
|
2002-06-21 11:16:28 +00:00
|
|
|
}; // class Text
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
2007-09-07 22:03:27 +00:00
|
|
|
template<class stringT, class string_adaptorT>
|
|
|
|
class Text_impl : virtual public CharacterData_impl<stringT, string_adaptorT>
|
2002-06-21 11:16:28 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Text_impl() { }
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// DOM::Text methods
|
2007-09-07 22:03:27 +00:00
|
|
|
virtual Text_impl<stringT, string_adaptorT>* splitText(int offset) = 0;
|
2002-06-21 11:16:28 +00:00
|
|
|
}; // Text_impl
|
|
|
|
|
|
|
|
} // namespace DOM
|
2007-09-05 11:47:13 +00:00
|
|
|
} // namespace Arabica
|
2002-06-21 11:16:28 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|