2002-06-21 13:16:28 +02:00
|
|
|
#ifndef JEZUK_DOM_TRAVERSAL_DOCUMENTRAVERSAL_H
|
|
|
|
#define JEZUK_DOM_TRAVERSAL_DOCUMENTRAVERSAL_H
|
|
|
|
|
|
|
|
/////////////////////////////////////////
|
|
|
|
// C++ DOM Traversal Implementation
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
/////////////////////////////////////////
|
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <DOM/Traversal/NodeIterator.hpp>
|
|
|
|
#include <DOM/Traversal/TreeWalker.hpp>
|
|
|
|
#include <DOM/Traversal/NodeFilter.hpp>
|
|
|
|
#include <DOM/Node.hpp>
|
|
|
|
#include <DOM/Traversal/TraversalImpl.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
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace Traversal
|
|
|
|
{
|
|
|
|
|
|
|
|
enum whatToShowFlags
|
|
|
|
{
|
|
|
|
SHOW_ALL = 0xFFFFFFFF,
|
|
|
|
SHOW_ELEMENT = 0x00000001,
|
|
|
|
SHOW_ATTRIBUTE = 0x00000002,
|
|
|
|
SHOW_TEXT = 0x00000004,
|
|
|
|
SHOW_CDATA_SECTION = 0x00000008,
|
|
|
|
SHOW_ENTITY_REFERENCE = 0x00000010,
|
|
|
|
SHOW_ENTITY = 0x00000020,
|
|
|
|
SHOW_PROCESSING_INSTRUCTION = 0x00000040,
|
|
|
|
SHOW_COMMENT = 0x00000080,
|
|
|
|
SHOW_DOCUMENT = 0x00000100,
|
|
|
|
SHOW_DOCUMENT_TYPE = 0x00000200,
|
|
|
|
SHOW_DOCUMENT_FRAGMENT = 0x00000400,
|
|
|
|
SHOW_NOTATION = 0x00000800
|
|
|
|
};
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class NodeIterator;
|
|
|
|
template<class stringT, class string_adaptorT> class TreeWalker;
|
|
|
|
template<class stringT, class string_adaptorT> class DocumentTraversal_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 DocumentTraversal : protected DOM::Proxy<DocumentTraversal_impl<stringT, string_adaptorT> >
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
public:
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
|
|
|
typedef TreeWalker<stringT, string_adaptorT> TreeWalkerT;
|
|
|
|
typedef NodeIterator<stringT, string_adaptorT> NodeIteratorT;
|
|
|
|
typedef DocumentTraversal_impl<stringT, string_adaptorT> DocumentTraversal_implT;
|
|
|
|
typedef DOM::Proxy<DocumentTraversal_implT> proxy_t;
|
2006-12-14 16:06:36 +01:00
|
|
|
typedef typename proxy_t::value_type impl_t;
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef DOM::Document<stringT, string_adaptorT> DocumentT;
|
|
|
|
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
2006-12-14 16:06:36 +01:00
|
|
|
|
|
|
|
DocumentTraversal() : proxy_t(0) { }
|
2007-09-08 00:03:27 +02:00
|
|
|
explicit DocumentTraversal(DocumentTraversal_implT* const impl) : proxy_t(impl) { }
|
2006-12-14 16:06:36 +01:00
|
|
|
DocumentTraversal(const DocumentTraversal& rhs) : proxy_t(rhs) { }
|
2007-09-08 00:03:27 +02:00
|
|
|
explicit DocumentTraversal(const DocumentT& rhs) : proxy_t(rhs.dImpl())
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2006-12-14 16:06:36 +01:00
|
|
|
if(dynamic_cast<impl_t*>(rhs.dImpl()) == 0)
|
2002-06-21 13:16:28 +02:00
|
|
|
throw DOM::DOMException(DOM::DOMException::NOT_SUPPORTED_ERR);
|
|
|
|
} // DocumentTraversal
|
|
|
|
|
|
|
|
virtual ~DocumentTraversal() { }
|
2006-12-14 16:06:36 +01:00
|
|
|
bool operator==(const DocumentTraversal& rhs) const { return proxy_t::operator==(rhs); }
|
|
|
|
bool operator!=(const DocumentTraversal& rhs) const { return proxy_t::operator!=(rhs); }
|
|
|
|
bool operator==(int dummy) const { return proxy_t::operator==(dummy); }
|
|
|
|
bool operator!=(int dummy) const { return proxy_t::operator!=(dummy); }
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
DocumentTraversal& operator=(const DocumentTraversal& rhs)
|
|
|
|
{
|
2006-12-14 16:06:36 +01:00
|
|
|
proxy_t::operator=(rhs);
|
2002-06-21 13:16:28 +02:00
|
|
|
return *this;
|
|
|
|
} // operator=
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
// DocumentTraversal methods
|
2007-09-08 00:03:27 +02:00
|
|
|
NodeIteratorT createNodeIterator(NodeT root,
|
|
|
|
unsigned long whatToShow,
|
|
|
|
bool entityRefExpansion)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return NodeIteratorT(proxy_t::impl()->createNodeIterator(root, whatToShow, 0, entityRefExpansion));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createNodeIterator
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
NodeIteratorT createNodeIterator(NodeT root,
|
|
|
|
unsigned long whatToShow,
|
|
|
|
NodeFilterT& filter,
|
|
|
|
bool entityRefExpansion)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return NodeIteratorT(proxy_t::impl()->createNodeIterator(root, whatToShow, &filter, entityRefExpansion));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createNodeIterator
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
TreeWalkerT createTreeWalker(NodeT root,
|
|
|
|
unsigned long whatToShow,
|
|
|
|
bool entityRefExpansion)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return TreeWalkerT(proxy_t::impl()->createTreeWalker(root, whatToShow, 0, entityRefExpansion));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createTreeWalker
|
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
TreeWalkerT createTreeWalker(NodeT root,
|
|
|
|
unsigned long whatToShow,
|
|
|
|
NodeFilterT& filter,
|
|
|
|
bool entityRefExpansion)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-08 00:03:27 +02:00
|
|
|
return TreeWalkerT(proxy_t::impl()->createTreeWalker(root, whatToShow, &filter, entityRefExpansion));
|
2002-06-21 13:16:28 +02:00
|
|
|
} // createTreeWalker
|
|
|
|
}; // class DocumentTraversal
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
// implementation class
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT> class NodeIterator_impl;
|
|
|
|
template<class stringT, class string_adaptorT> class TreeWalker_impl;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-08 00:03:27 +02:00
|
|
|
template<class stringT, class string_adaptorT>
|
2006-12-14 16:06:36 +01:00
|
|
|
class DocumentTraversal_impl : virtual public TraversalImpl
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
public:
|
2007-09-08 01:52:30 +02:00
|
|
|
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
2007-09-08 00:03:27 +02:00
|
|
|
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
|
|
|
typedef TreeWalker_impl<stringT, string_adaptorT> TreeWalker_implT;
|
|
|
|
typedef NodeIterator_impl<stringT, string_adaptorT> NodeIterator_implT;
|
|
|
|
|
|
|
|
virtual NodeIterator_implT* createNodeIterator(NodeT root,
|
|
|
|
unsigned long whatToShow,
|
|
|
|
NodeFilterT* filter,
|
|
|
|
bool entityRefExpansion) = 0;
|
|
|
|
|
|
|
|
virtual TreeWalker_implT* createTreeWalker(NodeT root,
|
|
|
|
unsigned long whatToShow,
|
|
|
|
NodeFilterT* filter,
|
|
|
|
bool entityRefExpansion) = 0;
|
2002-06-21 13:16:28 +02:00
|
|
|
}; // class DocumentTraveral_impl
|
|
|
|
|
|
|
|
} // namespace Traversal
|
|
|
|
|
|
|
|
} // namespace DOM
|
2007-09-05 13:47:13 +02:00
|
|
|
} // namespace Arabica
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
#endif
|
2007-01-12 15:52:14 +01:00
|
|
|
// end of file
|
|
|
|
|