#ifndef JEZUK_DOM_CHARACTERDATA_H #define JEZUK_DOM_CHARACTERDATA_H //////////////////////////// // C++ DOM definition // // $Id$ //////////////////////////// #include namespace DOM { template class CharacterData_impl; template class CharacterData : public Node { typedef Node NodeT; public: CharacterData() : Node() { } explicit CharacterData(CharacterData_impl* impl) : Node(impl) { } CharacterData(const CharacterData& rhs) : Node(rhs) { } explicit CharacterData(const Node& rhs) : Node(rhs) { Type type = rhs.getNodeType(); if((type != TEXT_NODE) && (type != CDATA_SECTION_NODE)) throw std::bad_cast("Cannot cast Node to Character Data"); } // CharacterData protected: CharacterData(const Node& rhs, int dummy) : Node(rhs) { } public: stringT getData() const { return cdImpl()->getData(); } void setData(const stringT& data) { cdImpl()->setData(data); } // setData int getLength() const { return cdImpl()->getLength(); } stringT substringData(int offset, int count) const { return cdImpl()->substringData(offset, count); } void appendData(const stringT& arg) { cdImpl()->appendData(arg); } // appendData void insertData(int offset, const stringT& arg) { cdImpl()->insertData(offset, arg); } // insertData void deleteData(int offset, int count) { cdImpl()->deleteData(offset, count); } // deleteData void replaceData(int offset, int count, const stringT& arg) { cdImpl()->replaceData(offset, count); } // replaceData private: CharacterData_impl* cdImpl() { return dynamic_cast*>(*NodeT::impl_); } const CharacterData_impl* cdImpl() const { return dynamic_cast*>(*NodeT::impl_); } }; // class CharacterData //////////////////////////////////////////////////////////////////// template class CharacterData_impl : virtual public Node_impl { public: virtual ~CharacterData_impl () { } ////////////////////////////////////////////////////////////////// // DOM::CharacterData methods virtual stringT getData() const = 0; virtual void setData(const stringT& data) = 0; virtual int getLength() const = 0; virtual stringT substringData(int offset, int count) const = 0; virtual void appendData(const stringT& arg) = 0; virtual void insertData(int offset, const stringT& arg) = 0; virtual void deleteData(int offset, int count) = 0; virtual void replaceData(int offset, int count, const stringT& arg) = 0; }; // CharacterData_impl } // namespace DOM #endif