#ifndef JEZUK_DOM_ELEMENT_H #define JEZUK_DOM_ELEMENT_H //////////////////////////// // C++ DOM definition // // $Id$ //////////////////////////// #include #include #include namespace DOM { template class Attr; template class NodeList; template class Element_impl; template class Element : public Node { typedef Node NodeT; public: Element() : Node() { } explicit Element(Element_impl* impl) : Node(impl) { } Element(const Element& rhs) : Node(rhs) { } explicit Element(const Node& rhs) : Node(rhs) { if(rhs.getNodeType() != Node::ELEMENT_NODE) throw std::bad_cast(); } // Element stringT getTagName() const { return eImpl()->getTagName(); } stringT getAttribute(const stringT& name) const { return eImpl()->getAttribute(name); } void setAttribute(const stringT& name, const stringT& value) { eImpl()->setAttribute(name, value); } void removeAttribute(const stringT& name) { eImpl()->removeAttribute(name); } Attr getAttributeNode(const stringT& name) const { return Attr(eImpl()->getAttributeNode(name)); } Attr setAttributeNode(const Attr& newAttr) { return Attr(eImpl()->setAttributeNode(newAttr.attrImpl())); } Attr removeAttributeNode(const Attr& oldAttr) { return Attr(eImpl()->removeAttributeNode(oldAttr.attrImpl())); } NodeList getElementsByTagName(const stringT& tagName) const { return NodeList(eImpl()->getElementsByTagName(tagName)); } 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); } Attr getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const { return Attr(eImpl()->getAttributeNodeNS(namespaceURI, localName)); } Attr setAttributeNodeNS(const Attr& newAttr) { return Attr(eImpl()->getAttributeNodeNS(newAttr)); } NodeList getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const { return NodeList(eImpl()->getElementsByTagNameNS(namespaceURI, localName)); } 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: Element_impl* eImpl() const { return dynamic_cast*>(*NodeT::impl_); } }; // class Element /////////////////////////////////////////////////////////// template class Element_impl : virtual public Node_impl { public: virtual ~Element_impl () { } //////////////////////////////////////////////////////// // DOM::Element virtual stringT getTagName() const = 0; virtual stringT getAttribute(const stringT& name) const = 0; virtual void setAttribute(const stringT& name, const stringT& value) = 0; virtual void removeAttribute(const stringT& name) = 0; virtual Attr_impl* getAttributeNode(const stringT& name) const = 0; virtual Attr_impl* setAttributeNode(Attr_impl* newAttr) = 0; virtual Attr_impl* removeAttributeNode(Attr_impl* oldAttr) = 0; virtual NodeList_impl* getElementsByTagName(const stringT& tagName) const = 0; 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; virtual Attr_impl* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const = 0; virtual Attr_impl* setAttributeNodeNS(Attr_impl* newAttr) = 0; virtual NodeList_impl* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0; virtual bool hasAttribute(const stringT& name) const = 0; virtual bool hasAttributeNS(const stringT& namespaceURI, const stringT& localName) const = 0; }; // class Element_impl } // namespace DOM #endif // end of file