2002-06-21 13:16:28 +02:00
|
|
|
#ifndef JEZUK_DOM_ELEMENT_H
|
|
|
|
#define JEZUK_DOM_ELEMENT_H
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
// C++ DOM definition
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
////////////////////////////
|
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <DOM/Node.hpp>
|
|
|
|
#include <DOM/Attr.hpp>
|
|
|
|
#include <DOM/NamedNodeMap.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 Attr;
|
|
|
|
template<class stringT, class string_adaptorT> class NodeList;
|
|
|
|
template<class stringT, class string_adaptorT> class Element_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 Element : public Node<stringT, string_adaptorT>
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef Element_impl<stringT, string_adaptorT> Element_implT;
|
2002-06-21 13:16:28 +02:00
|
|
|
public:
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef Node<stringT, string_adaptorT> NodeT;
|
|
|
|
typedef NodeList<stringT, string_adaptorT> NodeListT;
|
|
|
|
typedef Attr<stringT, string_adaptorT> AttrT;
|
|
|
|
|
|
|
|
Element() : NodeT() { }
|
|
|
|
explicit Element(Element_implT* impl) : NodeT(impl) { }
|
|
|
|
Element(const Element& rhs) : NodeT(rhs) { }
|
|
|
|
explicit Element(const NodeT& rhs) : NodeT(rhs)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
if(rhs.getNodeType() != NodeT::ELEMENT_NODE)
|
2002-06-21 13:16:28 +02:00
|
|
|
throw std::bad_cast();
|
|
|
|
} // Element
|
|
|
|
|
2005-12-09 15:09:08 +01:00
|
|
|
const stringT& getTagName() const { return eImpl()->getTagName(); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2005-12-09 17:01:31 +01:00
|
|
|
const stringT& getAttribute(const stringT& name) const { return eImpl()->getAttribute(name); }
|
2002-06-21 13:16:28 +02:00
|
|
|
void setAttribute(const stringT& name, const stringT& value) { eImpl()->setAttribute(name, value); }
|
|
|
|
void removeAttribute(const stringT& name) { eImpl()->removeAttribute(name); }
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
AttrT getAttributeNode(const stringT& name) const { return AttrT(eImpl()->getAttributeNode(name)); }
|
|
|
|
AttrT setAttributeNode(const AttrT& newAttr) { return AttrT(eImpl()->setAttributeNode(newAttr.attrImpl())); }
|
|
|
|
AttrT removeAttributeNode(const AttrT& oldAttr) { return AttrT(eImpl()->removeAttributeNode(oldAttr.attrImpl())); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
NodeListT getElementsByTagName(const stringT& tagName) const { return NodeListT(eImpl()->getElementsByTagName(tagName)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
stringT getAttributeNS(const stringT& namespaceURI, const stringT& localName) const { return eImpl()->getAttributeNS(namespaceURI, localName); }
|
|
|
|
void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value) { eImpl()->setAttributeNS(namespaceURI, qualifiedName, value); }
|
|
|
|
void removeAttributeNS(const stringT& namespaceURI, const stringT& localName) { return eImpl()->removeAttributeNS(namespaceURI, localName); }
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
AttrT getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const { return AttrT(eImpl()->getAttributeNodeNS(namespaceURI, localName)); }
|
2009-12-06 22:39:46 +01:00
|
|
|
AttrT setAttributeNodeNS(const AttrT& newAttr) { return AttrT(eImpl()->setAttributeNodeNS(newAttr.attrImpl())); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
NodeListT getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const { return NodeListT(eImpl()->getElementsByTagNameNS(namespaceURI, localName)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
bool hasAttribute(const stringT& name) const { return eImpl()->hasAttribute(name); }
|
|
|
|
|
|
|
|
bool hasAttributeNS(const stringT& namespaceURI, const stringT& localName) const { return eImpl()->hasAttributeNS(namespaceURI, localName); }
|
|
|
|
|
|
|
|
private:
|
2007-09-08 00:03:27 +02:00
|
|
|
Element_implT* eImpl() const { return dynamic_cast<Element_implT*>(*NodeT::impl_); }
|
2002-06-21 13:16:28 +02:00
|
|
|
}; // class Element
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT>
|
|
|
|
class Element_impl : virtual public Node_impl<stringT, string_adaptorT>
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
public:
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef NodeList_impl<stringT, string_adaptorT> NodeList_implT;
|
|
|
|
typedef Attr_impl<stringT, string_adaptorT> Attr_implT;
|
|
|
|
|
2002-06-21 13:16:28 +02:00
|
|
|
virtual ~Element_impl () { }
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// DOM::Element
|
2005-12-09 15:09:08 +01:00
|
|
|
virtual const stringT& getTagName() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2005-12-09 17:01:31 +01:00
|
|
|
virtual const stringT& getAttribute(const stringT& name) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
virtual void setAttribute(const stringT& name, const stringT& value) = 0;
|
|
|
|
virtual void removeAttribute(const stringT& name) = 0;
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Attr_implT* getAttributeNode(const stringT& name) const = 0;
|
|
|
|
virtual Attr_implT* setAttributeNode(Attr_implT* newAttr) = 0;
|
|
|
|
virtual Attr_implT* removeAttributeNode(Attr_implT* oldAttr) = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual NodeList_implT* getElementsByTagName(const stringT& tagName) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
virtual stringT getAttributeNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
|
|
|
virtual void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value) = 0;
|
|
|
|
virtual void removeAttributeNS(const stringT& namespaceURI, const stringT& localName) = 0;
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Attr_implT* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
|
|
|
virtual Attr_implT* setAttributeNodeNS(Attr_implT* newAttr) = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual NodeList_implT* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
virtual bool hasAttribute(const stringT& name) const = 0;
|
|
|
|
|
|
|
|
virtual bool hasAttributeNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
|
|
|
}; // class Element_impl
|
|
|
|
|
|
|
|
} // namespace DOM
|
2007-09-05 13:47:13 +02:00
|
|
|
} // namespace Arabica
|
2002-06-21 13:16:28 +02:00
|
|
|
#endif
|
|
|
|
// end of file
|