#ifndef JEZUK_DOM_ATTR_H #define JEZUK_DOM_ATTR_H //////////////////////////// // C++ DOM definition // // $Id$ //////////////////////////// #include namespace DOM { template class Element; template class Attr_impl; template class Attr : public Node { public: Attr() : Node() { } explicit Attr(Attr_impl* impl) : Node(impl) { } Attr(const Attr& rhs) : Node(rhs) { } explicit Attr(const Node& rhs) : Node(rhs) { if(rhs.getNodeType() != Node::ATTRIBUTE_NODE) throw std::bad_cast(); } // Attr stringT getName() const { return attrImpl()->getName(); } bool getSpecified() const { return attrImpl()->getSpecified(); } stringT getValue() const { return attrImpl()->getValue(); } void setValue(const stringT& value) { attrImpl()->throwIfReadOnly(); attrImpl()->setValue(value); } // setValue Element getOwnerElement() const { return Element(attrImpl()->getOwnerElement()); } private: Attr_impl* attrImpl() const { return dynamic_cast*>(*impl_); } typedef Element ElementT; friend class Element; }; // class DocumentFragment ////////////////////////////////////////////////////////// template class Element_impl; template class Attr_impl : virtual public Node_impl { public: virtual ~Attr_impl() { } /////////////////////////////////////////////////// // DOM::Attribute methods virtual stringT getName() const = 0; virtual bool getSpecified() const = 0; virtual stringT getValue() const = 0; virtual void setValue(const stringT& value) = 0; virtual Element_impl* getOwnerElement() const = 0; }; // class Attr_impl } // namespace DOM #endif