arabica/DOM/Simple/CharacterDataImpl.h

102 lines
2.7 KiB
C
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_SimpleDOM_CHARACTERDATAIMPL_H
#define JEZUK_SimpleDOM_CHARACTERDATAIMPL_H
#include <DOM/CharacterData.h>
#include <DOM/Simple/NodeImpl.h>
namespace SimpleDOM
{
template<class stringT, class string_adaptorT>
class CharacterDataImpl : virtual public DOM::CharacterData_impl<stringT>,
public ChildlessNodeImpl<stringT, string_adaptorT>
{
typedef ChildlessNodeImpl<stringT, string_adaptorT> NodeT;
2002-06-21 13:16:28 +02:00
public:
CharacterDataImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& data) :
ChildlessNodeImpl<stringT, string_adaptorT>(ownerDoc),
data_(data)
{
} // CharacterDataImpl
virtual ~CharacterDataImpl() { }
//////////////////////////////////////////////////////////////////
// DOM::CharacterData methods
virtual stringT getData() const
{
return getNodeValue();
} // getData
virtual void setData(const stringT& data)
{
NodeT::throwIfReadOnly();
2002-06-21 13:16:28 +02:00
setNodeValue(data);
} // setData
virtual int getLength() const
{
return static_cast<int>(string_adaptorT::length(data_));
2002-06-21 13:16:28 +02:00
} // getLength
virtual stringT substringData(int offset, int count) const
{
return string_adaptorT::substr(data_, offset, count);
2002-06-21 13:16:28 +02:00
} // substringData
virtual void appendData(const stringT& arg)
{
NodeT::throwIfReadOnly();
string_adaptorT::append(data_, arg);
2002-06-21 13:16:28 +02:00
} // appendData
virtual void insertData(int offset, const stringT& arg)
{
NodeT::throwIfReadOnly();
if(offset > static_cast<int>(string_adaptorT::length(data_)))
2002-06-21 13:16:28 +02:00
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
string_adaptorT::insert(data_, offset, arg);
2002-06-21 13:16:28 +02:00
} // insertData
virtual void deleteData(int offset, int count)
{
NodeT::throwIfReadOnly();
if(offset > static_cast<int>(string_adaptorT::length(data_)))
2002-06-21 13:16:28 +02:00
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
string_adaptorT::replace(data_, offset, count, stringT());
2002-06-21 13:16:28 +02:00
} // deleteData
virtual void replaceData(int offset, int count, const stringT& arg)
{
NodeT::throwIfReadOnly();
if(offset > static_cast<int>(string_adaptorT::length(data_)))
2002-06-21 13:16:28 +02:00
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
string_adaptorT::replace(data_, offset, count, arg);
2002-06-21 13:16:28 +02:00
} // replaceData
///////////////////////////////////////////////////////
// DOM::Node methods
virtual stringT getNodeValue() const
{
return data_;
} // getNodeValue
virtual void setNodeValue(const stringT& data)
{
NodeT::throwIfReadOnly();
2002-06-21 13:16:28 +02:00
data_ = data;
} // setNodeValue
private:
stringT data_;
}; // class CharacterDataImpl
} // namespace SAX2DOM
#endif