arabica/include/DOM/ProcessingInstruction.hpp

64 lines
2.2 KiB
C++
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_DOM_PROCESSINGINSTRUCTION_H
#define JEZUK_DOM_PROCESSINGINSTRUCTION_H
////////////////////////////
// C++ DOM definition
//
// $Id$
////////////////////////////
2007-09-05 00:55:47 +02:00
#include <DOM/Node.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 DOM
{
template<class stringT, class string_adaptorT> class ProcessingInstruction_impl;
2002-06-21 13:16:28 +02:00
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
class ProcessingInstruction : public Node<stringT, string_adaptorT>
2002-06-21 13:16:28 +02:00
{
typedef Node<stringT, string_adaptorT> NodeT;
2002-06-21 13:16:28 +02:00
public:
ProcessingInstruction() : Node<stringT, string_adaptorT>(0) { }
explicit ProcessingInstruction(ProcessingInstruction_impl<stringT, string_adaptorT>* impl) : Node<stringT, string_adaptorT>(dynamic_cast<Node_impl<stringT, string_adaptorT>*>(impl)) { }
ProcessingInstruction(const ProcessingInstruction& rhs) : Node<stringT, string_adaptorT>(rhs) { }
explicit ProcessingInstruction(const Node<stringT, string_adaptorT>& rhs) : Node<stringT, string_adaptorT>(rhs)
2002-06-21 13:16:28 +02:00
{
if(NodeT::impl_ == 0) // null nodes can always be cast
return;
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::PROCESSING_INSTRUCTION_NODE)
2010-12-10 10:24:34 +01:00
throw DOMBadCast("ProcessingInstruction");
2002-06-21 13:16:28 +02:00
}
const stringT& getTarget() const { return piImpl()->getTarget(); }
2002-06-21 13:16:28 +02:00
const stringT& getData() const { return piImpl()->getData(); }
2002-06-21 13:16:28 +02:00
void setData(const stringT& data) { piImpl()->setData(data); }
private:
ProcessingInstruction_impl<stringT, string_adaptorT>* piImpl() const { return dynamic_cast<ProcessingInstruction_impl<stringT, string_adaptorT>*>(*NodeT::impl_); }
2002-06-21 13:16:28 +02:00
}; // class DocumentFragment
//////////////////////////////////////////////////////////
template<class stringT, class string_adaptorT>
class ProcessingInstruction_impl : virtual public Node_impl<stringT, string_adaptorT>
2002-06-21 13:16:28 +02:00
{
public:
virtual ~ProcessingInstruction_impl () { }
////////////////////////////////////////////////////////
// DOM::ProcessingInstruction methods
virtual const stringT& getTarget() const = 0;
2002-06-21 13:16:28 +02:00
virtual const stringT& getData() const = 0;
2002-06-21 13:16:28 +02:00
virtual void setData(const stringT& data) = 0;
}; // class ProcessingInstruction_impl
} // namespace DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif