arabica/include/DOM/Traversal/TreeWalker.hpp

122 lines
3.5 KiB
C++
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_DOM_TRAVERSAL_TREEWALKER_H
#define JEZUK_DOM_TRAVERSAL_TREEWALKER_H
/////////////////////////////////////////
// C++ DOM Traversal Implementation
//
// $Id$
/////////////////////////////////////////
2007-09-05 00:55:47 +02:00
#include <DOM/Node.hpp>
#include <DOM/Traversal/NodeFilter.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
{
template<class stringT, class string_adaptorT> class TreeWalker_impl;
2002-06-21 13:16:28 +02:00
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
class TreeWalker : protected DOM::Proxy<TreeWalker_impl<stringT, string_adaptorT> >
2002-06-21 13:16:28 +02:00
{
public:
typedef TreeWalker_impl<stringT, string_adaptorT> TreeWalker_implT;
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
typedef DOM::Node<stringT, string_adaptorT> NodeT;
2007-01-12 15:52:14 +01:00
private:
typedef DOM::Proxy<TreeWalker_implT> proxy_t;
typedef typename proxy_t::value_type impl_t;
2007-01-12 15:52:14 +01:00
public:
TreeWalker() : proxy_t(0) { }
explicit TreeWalker(TreeWalker_implT* const impl) : proxy_t(impl) { }
TreeWalker(const TreeWalker& rhs) : proxy_t(rhs) { }
2002-06-21 13:16:28 +02:00
virtual ~TreeWalker() { }
bool operator==(const TreeWalker& rhs) const { return proxy_t::operator==(rhs); }
bool operator!=(const TreeWalker& 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
TreeWalker& operator=(const TreeWalker& rhs)
{
proxy_t::operator=(rhs);
2002-06-21 13:16:28 +02:00
return *this;
} // operator=
///////////////////////////////////////////////////////////////
// TreeWalker methods
NodeT getRoot() { return proxy_t::impl()->getRoot(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
unsigned long getWhatToShow() { return proxy_t::impl()->getWhatToShow(); }
2002-06-21 13:16:28 +02:00
NodeFilterT* getFilter() { return proxy_t::impl()->getFilter(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
bool getExpandEntityReferences() { return proxy_t::impl()->getExpandEntityReferences(); }
2002-06-21 13:16:28 +02:00
NodeT getCurrentNode() { return proxy_t::impl()->getCurrentNode(); }
void setCurrentNode(const NodeT& currentNode) { proxy_t::impl()->setCurrentNode(currentNode); }
2002-06-21 13:16:28 +02:00
NodeT parentNode() { return proxy_t::impl()->parentNode(); }
2002-06-21 13:16:28 +02:00
NodeT firstChild() { return proxy_t::impl()->firstChild(); }
2002-06-21 13:16:28 +02:00
NodeT lastChild() { return proxy_t::impl()->lastChild(); }
2002-06-21 13:16:28 +02:00
NodeT previousSibling() { return proxy_t::impl()->previousSibling(); }
2002-06-21 13:16:28 +02:00
NodeT nextSibling() { return proxy_t::impl()->nextSibling(); }
2002-06-21 13:16:28 +02:00
NodeT previousNode() { return proxy_t::impl()->previousNode(); }
2002-06-21 13:16:28 +02:00
NodeT nextNode() { return proxy_t::impl()->nextNode(); }
2002-06-21 13:16:28 +02:00
}; // class TreeWalker
////////////////////////////////////////////////
template<class stringT, class string_adaptorT>
class TreeWalker_impl : public TraversalImpl
2002-06-21 13:16:28 +02:00
{
public:
typedef DOM::Node<stringT, string_adaptorT> NodeT;
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
virtual NodeT getRoot() = 0;
2002-06-21 13:16:28 +02:00
virtual unsigned long getWhatToShow() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeFilterT* getFilter() = 0;
2002-06-21 13:16:28 +02:00
virtual bool getExpandEntityReferences() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT getCurrentNode() = 0;
2002-06-21 13:16:28 +02:00
virtual void setCurrentNode(const NodeT& currentNode) = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT parentNode() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT firstChild() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT lastChild() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT previousSibling() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT nextSibling() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT previousNode() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeT nextNode() = 0;
2002-06-21 13:16:28 +02:00
}; // class TreeWalker_impl
} // namespace Traversal
} // namespace DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif
// end of file