2002-06-21 13:16:28 +02:00
|
|
|
#ifndef JEZUK_DOM_ATTR_H
|
|
|
|
#define JEZUK_DOM_ATTR_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
|
|
|
|
{
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class Element;
|
|
|
|
template<class stringT, class string_adaptorT> class Attr_impl;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-09 00:31:24 +02:00
|
|
|
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
|
2007-09-08 00:03:27 +02:00
|
|
|
class Attr : public Node<stringT, string_adaptorT>
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
public:
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef Node<stringT, string_adaptorT> NodeT;
|
|
|
|
typedef Element<stringT, string_adaptorT> ElementT;
|
|
|
|
typedef Attr_impl<stringT, string_adaptorT> Attr_implT;
|
|
|
|
|
|
|
|
Attr() : NodeT() { }
|
|
|
|
|
|
|
|
explicit Attr(Attr_implT* impl) : NodeT(impl) { }
|
|
|
|
Attr(const Attr& rhs) : NodeT(rhs) { }
|
|
|
|
explicit Attr(const NodeT& rhs) : NodeT(rhs)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2010-12-09 12:35:54 +01:00
|
|
|
if(NodeT::impl_ == 0) // null nodes can always be cast
|
|
|
|
return;
|
2007-09-08 00:03:27 +02:00
|
|
|
if(rhs.getNodeType() != NodeT::ATTRIBUTE_NODE)
|
2010-12-10 10:24:34 +01:00
|
|
|
throw DOMBadCast("Attr");
|
2002-06-21 13:16:28 +02:00
|
|
|
} // Attr
|
|
|
|
|
2005-12-09 16:53:05 +01:00
|
|
|
const stringT& getName() const { return attrImpl()->getName(); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
bool getSpecified() const { return attrImpl()->getSpecified(); }
|
|
|
|
|
2005-12-09 16:54:23 +01:00
|
|
|
const stringT& getValue() const { return attrImpl()->getValue(); }
|
2006-12-14 12:51:23 +01:00
|
|
|
void setValue(const stringT& value) { attrImpl()->setValue(value); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
ElementT getOwnerElement() const { return ElementT(attrImpl()->getOwnerElement()); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
private:
|
2007-09-08 00:03:27 +02:00
|
|
|
Attr_implT* attrImpl() const { return dynamic_cast<Attr_implT*>(*NodeT::impl_); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
friend class Element<stringT, string_adaptorT>;
|
2005-06-06 23:00:20 +02:00
|
|
|
}; // class Attr
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class Element_impl;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT>
|
|
|
|
class Attr_impl : virtual public Node_impl<stringT, string_adaptorT>
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Attr_impl() { }
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
// DOM::Attribute methods
|
2005-12-09 16:53:05 +01:00
|
|
|
virtual const stringT& getName() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
virtual bool getSpecified() const = 0;
|
|
|
|
|
2005-12-09 16:54:23 +01:00
|
|
|
virtual const stringT& getValue() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
virtual void setValue(const stringT& value) = 0;
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Element_impl<stringT, string_adaptorT>* getOwnerElement() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
}; // class Attr_impl
|
|
|
|
|
|
|
|
} // namespace DOM
|
2007-09-05 13:47:13 +02:00
|
|
|
} // namespace Arabica
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
#endif
|