#ifndef JEZUK_DOM_TEXT_H #define JEZUK_DOM_TEXT_H //////////////////////////// // C++ DOM definition // // $Id$ //////////////////////////// #include namespace Arabica { namespace DOM { template class Text_impl; template > class Text : public CharacterData { typedef Text_impl Text_implT; public: typedef Node NodeT; typedef CharacterData CharacterDataT; Text() : CharacterDataT() { } explicit Text(Text_implT* impl) : CharacterDataT(impl) { } Text(const Text& rhs) : CharacterDataT(rhs) { } explicit Text(const NodeT& rhs) : CharacterDataT(rhs, 0) { typename Text::Type type = rhs.getNodeType(); if((type != Text::TEXT_NODE) && (type != Text::CDATA_SECTION_NODE)) //throw std::runtime_error("bad_cast: Cannot cast Node to Text"); throw std::bad_cast(); } // Text protected: Text(const NodeT& rhs, int dummy) : CharacterDataT(rhs, 0) { } Text splitText(int offset) { return tImpl()->splitText(offset); } // splitText protected: Text_implT* tImpl() const { return dynamic_cast(CharacterDataT::impl()); } }; // class Text //////////////////////////////////////////////////////////////////// template class Text_impl : virtual public CharacterData_impl { public: virtual ~Text_impl() { } //////////////////////////////////////////////////////////// // DOM::Text methods virtual Text_impl* splitText(int offset) = 0; }; // Text_impl } // namespace DOM } // namespace Arabica #endif