2002-06-21 13:16:28 +02:00
|
|
|
#ifndef JEZUK_DOM_DOCUMENT_H
|
|
|
|
#define JEZUK_DOM_DOCUMENT_H
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
// C++ DOM definition
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
////////////////////////////
|
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <DOM/Node.hpp>
|
|
|
|
#include <DOM/NodeList.hpp>
|
|
|
|
#include <DOM/NamedNodeMap.hpp>
|
|
|
|
#include <DOM/Element.hpp>
|
|
|
|
#include <DOM/Attr.hpp>
|
|
|
|
#include <DOM/ProcessingInstruction.hpp>
|
|
|
|
#include <DOM/DocumentType.hpp>
|
|
|
|
#include <DOM/DOMImplementation.hpp>
|
|
|
|
#include <DOM/DocumentFragment.hpp>
|
|
|
|
#include <DOM/EntityReference.hpp>
|
|
|
|
#include <DOM/CDATASection.hpp>
|
|
|
|
#include <DOM/Text.hpp>
|
|
|
|
#include <DOM/Comment.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <DOM/Traversal/DocumentTraversal.hpp>
|
|
|
|
#include <DOM/Traversal/DocumentTraversalImpl.hpp>
|
2006-12-14 16:06:36 +01:00
|
|
|
|
2007-09-05 13:47:13 +02:00
|
|
|
namespace Arabica
|
|
|
|
{
|
2002-06-21 13:16:28 +02:00
|
|
|
namespace DOM
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace Events {
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class DocumentEvent;
|
2002-06-21 13:16:28 +02:00
|
|
|
} // namespace Events
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class Document_impl;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT>
|
|
|
|
class Document : public Node<stringT, string_adaptorT>
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef Node<stringT, string_adaptorT> NodeT;
|
2002-06-21 13:16:28 +02:00
|
|
|
public:
|
2007-09-08 00:03:27 +02:00
|
|
|
Document() : Node<stringT, string_adaptorT>() { }
|
|
|
|
Document(Document_impl<stringT, string_adaptorT>* impl) : Node<stringT, string_adaptorT>(impl) { }
|
|
|
|
Document(const Document& rhs) : Node<stringT, string_adaptorT>(rhs) { }
|
|
|
|
explicit Document(const Node<stringT, string_adaptorT>& rhs) : Node<stringT, string_adaptorT>(rhs)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::DOCUMENT_NODE)
|
2002-06-21 13:16:28 +02:00
|
|
|
throw std::bad_cast();
|
|
|
|
} // Document
|
|
|
|
~Document() { }
|
|
|
|
|
|
|
|
Document& operator=(const Document& rhs)
|
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
Node<stringT, string_adaptorT>::operator=(rhs);
|
2002-06-21 13:16:28 +02:00
|
|
|
return *this;
|
|
|
|
} // operator
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
DocumentType<stringT, string_adaptorT> getDoctype() const { return dImpl()->getDoctype(); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
DOMImplementation<stringT, string_adaptorT> getImplementation() const { return DOMImplementation<stringT, string_adaptorT>(dImpl()->getImplementation()); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Element<stringT, string_adaptorT> getDocumentElement() const { return Element<stringT, string_adaptorT>(dImpl()->getDocumentElement()); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Element<stringT, string_adaptorT> createElement(const stringT& tagName) const { return Element<stringT, string_adaptorT>(dImpl()->createElement(tagName)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
DocumentFragment<stringT, string_adaptorT> createDocumentFragment() const { return DocumentFragment<stringT, string_adaptorT>(dImpl()->createDocumentFragment()); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Text<stringT, string_adaptorT> createTextNode(const stringT& data) const { return Text<stringT, string_adaptorT>(dImpl()->createTextNode(data)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Comment<stringT, string_adaptorT> createComment(const stringT& data) const { return Comment<stringT, string_adaptorT>(dImpl()->createComment(data)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
CDATASection<stringT, string_adaptorT> createCDATASection(const stringT& data) const { return CDATASection<stringT, string_adaptorT>(dImpl()->createCDATASection(data)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
ProcessingInstruction<stringT, string_adaptorT> createProcessingInstruction(const stringT& target, const stringT& data) const
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return ProcessingInstruction<stringT, string_adaptorT>(dImpl()->createProcessingInstruction(target, data));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createProcessingInstruction
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Attr<stringT, string_adaptorT> createAttribute(const stringT& name) const { return Attr<stringT, string_adaptorT>(dImpl()->createAttribute(name)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
EntityReference<stringT, string_adaptorT> createEntityReference(const stringT& name) const { return EntityReference<stringT, string_adaptorT>(dImpl()->createEntityReference(name)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
NodeList<stringT, string_adaptorT> getElementsByTagName(const stringT& tagname) const { return NodeList<stringT, string_adaptorT>(dImpl()->getElementsByTagName(tagname)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Node<stringT, string_adaptorT> importNode(const Node<stringT, string_adaptorT>& importedNode, bool deep) const { return Node<stringT, string_adaptorT>(dImpl()->importNode(*importedNode.impl_, deep)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Element<stringT, string_adaptorT> createElementNS(const stringT& namespaceURI, const stringT& qualifiedName) const
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return Element<stringT, string_adaptorT>(dImpl()->createElementNS(namespaceURI, qualifiedName));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createElementNS
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Attr<stringT, string_adaptorT> createAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName) const
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return Attr<stringT, string_adaptorT>(dImpl()->createAttributeNS(namespaceURI, qualifiedName));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createAttributeNS
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
NodeList<stringT, string_adaptorT> getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return NodeList<stringT, string_adaptorT>(dImpl()->getElementsByTagNameNS(namespaceURI, localName));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // getElementsByTagNameNS
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Element<stringT, string_adaptorT> getElementById(const stringT& elementId) const { return Element<stringT, string_adaptorT>(dImpl()->getElementById(elementId)); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2006-12-14 16:06:36 +01:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
Traversal::DocumentTraversal<stringT, string_adaptorT> createDocumentTraversal()
|
2006-12-14 16:06:36 +01:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
Traversal::DocumentTraversal<stringT, string_adaptorT> docTraversal(new Traversal::DocumentTraversalImpl<stringT, string_adaptorT>());
|
2006-12-14 16:06:36 +01:00
|
|
|
return docTraversal;
|
|
|
|
}
|
|
|
|
|
2002-06-21 13:16:28 +02:00
|
|
|
private:
|
2007-09-08 00:03:27 +02:00
|
|
|
Document_impl<stringT, string_adaptorT>* dImpl() const { return dynamic_cast<Document_impl<stringT, string_adaptorT>*>(*NodeT::impl_); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef class Traversal::DocumentTraversal<stringT, string_adaptorT> DocumentTraversalT;
|
|
|
|
friend class Traversal::DocumentTraversal<stringT, string_adaptorT>;
|
|
|
|
typedef class Events::DocumentEvent<stringT, string_adaptorT> DocumentEventT;
|
|
|
|
friend class Events::DocumentEvent<stringT, string_adaptorT>;
|
2002-06-21 13:16:28 +02:00
|
|
|
}; // class DocumentFragment
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class DocumentType_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class DOMImplementation_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class Element_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class DocumentFragment_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class Text_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class Comment_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class CDATASection_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class ProcessingInstruction_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class Attr_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class EntityReference_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class NodeList_impl;
|
|
|
|
|
|
|
|
template<class stringT, class string_adaptorT>
|
|
|
|
class Document_impl : virtual public Node_impl<stringT, string_adaptorT>
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Document_impl() { }
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual DocumentType_impl<stringT, string_adaptorT>* getDoctype() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual DOMImplementation<stringT, string_adaptorT> getImplementation() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Element_impl<stringT, string_adaptorT>* getDocumentElement() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Element_impl<stringT, string_adaptorT>* createElement(const stringT& tagName) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual DocumentFragment_impl<stringT, string_adaptorT>* createDocumentFragment() const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Text_impl<stringT, string_adaptorT>* createTextNode(const stringT& data) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Comment_impl<stringT, string_adaptorT>* createComment(const stringT& data) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual CDATASection_impl<stringT, string_adaptorT>* createCDATASection(const stringT& data) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual ProcessingInstruction_impl<stringT, string_adaptorT>* createProcessingInstruction(const stringT& target, const stringT& data) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Attr_impl<stringT, string_adaptorT>* createAttribute(const stringT& name) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual EntityReference_impl<stringT, string_adaptorT>* createEntityReference(const stringT& name) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual NodeList_impl<stringT, string_adaptorT>* getElementsByTagName(const stringT& tagname) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Node_impl<stringT, string_adaptorT>* importNode(Node_impl<stringT, string_adaptorT>* importedNode, bool deep) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Element_impl<stringT, string_adaptorT>* createElementNS(const stringT& namespaceURI, const stringT& qualifiedName) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Attr_impl<stringT, string_adaptorT>* createAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual NodeList_impl<stringT, string_adaptorT>* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
virtual Element_impl<stringT, string_adaptorT>* getElementById(const stringT& elementId) const = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
}; // class Document_impl
|
|
|
|
|
|
|
|
} // namespace DOM
|
2007-09-05 13:47:13 +02:00
|
|
|
} // namespace Arabica
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|