2002-06-21 13:16:28 +02:00
|
|
|
#ifndef JEZUK_SimpleDOM_CHARACTERDATAIMPL_H
|
|
|
|
#define JEZUK_SimpleDOM_CHARACTERDATAIMPL_H
|
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <DOM/CharacterData.hpp>
|
|
|
|
#include <DOM/Simple/NodeImpl.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-05 13:47:13 +02:00
|
|
|
namespace Arabica
|
|
|
|
{
|
2002-06-21 13:16:28 +02:00
|
|
|
namespace SimpleDOM
|
|
|
|
{
|
|
|
|
|
|
|
|
template<class stringT, class string_adaptorT>
|
2007-09-08 01:52:30 +02:00
|
|
|
class CharacterDataImpl : virtual public DOM::CharacterData_impl<stringT, string_adaptorT>,
|
2002-06-21 13:16:28 +02:00
|
|
|
public ChildlessNodeImpl<stringT, string_adaptorT>
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
typedef ChildlessNodeImpl<stringT, string_adaptorT> NodeT;
|
2002-06-21 13:16:28 +02:00
|
|
|
public:
|
2015-12-10 00:03:49 +01:00
|
|
|
CharacterDataImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& data) :
|
2002-06-21 13:16:28 +02:00
|
|
|
ChildlessNodeImpl<stringT, string_adaptorT>(ownerDoc),
|
|
|
|
data_(data)
|
2015-12-10 00:03:49 +01:00
|
|
|
{
|
2002-06-21 13:16:28 +02:00
|
|
|
} // CharacterDataImpl
|
|
|
|
|
|
|
|
virtual ~CharacterDataImpl() { }
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// DOM::CharacterData methods
|
2005-12-09 16:57:21 +01:00
|
|
|
virtual const stringT& getData() const
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
return getNodeValue();
|
|
|
|
} // getData
|
|
|
|
|
|
|
|
virtual void setData(const stringT& data)
|
|
|
|
{
|
2005-08-30 11:40:34 +02:00
|
|
|
NodeT::throwIfReadOnly();
|
2002-06-21 13:16:28 +02:00
|
|
|
setNodeValue(data);
|
|
|
|
} // setData
|
|
|
|
|
|
|
|
virtual int getLength() const
|
|
|
|
{
|
2005-09-08 23:43:21 +02:00
|
|
|
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
|
|
|
|
{
|
2010-12-09 20:03:23 +01:00
|
|
|
if((offset < 0) || (offset > static_cast<int>(string_adaptorT::length(data_))))
|
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
|
|
|
if(count < 0)
|
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
|
|
|
|
2005-09-08 23:43:21 +02:00
|
|
|
return string_adaptorT::substr(data_, offset, count);
|
2002-06-21 13:16:28 +02:00
|
|
|
} // substringData
|
|
|
|
|
|
|
|
virtual void appendData(const stringT& arg)
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
NodeT::throwIfReadOnly();
|
2005-09-08 23:43:21 +02:00
|
|
|
string_adaptorT::append(data_, arg);
|
2002-06-21 13:16:28 +02:00
|
|
|
} // appendData
|
|
|
|
|
|
|
|
virtual void insertData(int offset, const stringT& arg)
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
NodeT::throwIfReadOnly();
|
2010-12-09 20:03:23 +01:00
|
|
|
|
|
|
|
if((offset < 0) || (offset > static_cast<int>(string_adaptorT::length(data_))))
|
2002-06-21 13:16:28 +02:00
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
2005-09-08 23:43:21 +02:00
|
|
|
|
|
|
|
string_adaptorT::insert(data_, offset, arg);
|
2002-06-21 13:16:28 +02:00
|
|
|
} // insertData
|
|
|
|
|
|
|
|
virtual void deleteData(int offset, int count)
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
NodeT::throwIfReadOnly();
|
2005-09-08 23:43:21 +02:00
|
|
|
|
2010-12-09 20:03:23 +01:00
|
|
|
if((offset < 0) || (offset > static_cast<int>(string_adaptorT::length(data_))))
|
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
|
|
|
if(count < 0)
|
2002-06-21 13:16:28 +02:00
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
2005-09-08 23:43:21 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
NodeT::throwIfReadOnly();
|
2005-09-08 23:43:21 +02:00
|
|
|
|
2010-12-09 20:03:23 +01:00
|
|
|
if((offset < 0) || (offset > static_cast<int>(string_adaptorT::length(data_))))
|
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
|
|
|
if(count < 0)
|
2002-06-21 13:16:28 +02:00
|
|
|
throw DOM::DOMException(DOM::DOMException::INDEX_SIZE_ERR);
|
2005-09-08 23:43:21 +02:00
|
|
|
|
|
|
|
string_adaptorT::replace(data_, offset, count, arg);
|
2002-06-21 13:16:28 +02:00
|
|
|
} // replaceData
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
// DOM::Node methods
|
2015-12-10 00:03:49 +01:00
|
|
|
virtual const stringT& getNodeValue() const
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
return data_;
|
|
|
|
} // getNodeValue
|
|
|
|
|
|
|
|
virtual void setNodeValue(const stringT& data)
|
|
|
|
{
|
2004-09-18 01:17:51 +02:00
|
|
|
NodeT::throwIfReadOnly();
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
data_ = data;
|
|
|
|
} // setNodeValue
|
|
|
|
private:
|
|
|
|
stringT data_;
|
|
|
|
}; // class CharacterDataImpl
|
|
|
|
|
|
|
|
} // namespace SAX2DOM
|
2007-09-05 13:47:13 +02:00
|
|
|
} // namespace Arabica
|
|
|
|
|
2002-06-21 13:16:28 +02:00
|
|
|
#endif
|