arabica/include/DOM/Traversal/TreeWalker.hpp

113 lines
3.4 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 TreeWalker_impl;
template<class stringT>
class TreeWalker : protected DOM::Proxy<TreeWalker_impl<stringT> >
2002-06-21 13:16:28 +02:00
{
2007-01-12 15:52:14 +01:00
private:
typedef DOM::Proxy<TreeWalker_impl<stringT> > 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_impl<stringT>* 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
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> 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
2007-01-12 15:52:14 +01:00
NodeFilter<stringT>* 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
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> getCurrentNode() { return proxy_t::impl()->getCurrentNode(); }
void setCurrentNode(const DOM::Node<stringT>& currentNode) { proxy_t::impl()->setCurrentNode(currentNode); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> parentNode() { return proxy_t::impl()->parentNode(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> firstChild() { return proxy_t::impl()->firstChild(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> lastChild() { return proxy_t::impl()->lastChild(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> previousSibling() { return proxy_t::impl()->previousSibling(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> nextSibling() { return proxy_t::impl()->nextSibling(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> previousNode() { return proxy_t::impl()->previousNode(); }
2002-06-21 13:16:28 +02:00
2007-01-12 15:52:14 +01:00
DOM::Node<stringT> nextNode() { return proxy_t::impl()->nextNode(); }
2002-06-21 13:16:28 +02:00
}; // class TreeWalker
////////////////////////////////////////////////
template<class stringT>
class TreeWalker_impl : public TraversalImpl
2002-06-21 13:16:28 +02:00
{
public:
virtual DOM::Node<stringT> getRoot() = 0;
2002-06-21 13:16:28 +02:00
virtual unsigned long getWhatToShow() = 0;
2002-06-21 13:16:28 +02:00
virtual NodeFilter<stringT>* getFilter() = 0;
2002-06-21 13:16:28 +02:00
virtual bool getExpandEntityReferences() = 0;
2002-06-21 13:16:28 +02:00
virtual DOM::Node<stringT> getCurrentNode() = 0;
2002-06-21 13:16:28 +02:00
virtual void setCurrentNode(const DOM::Node<stringT>& currentNode) = 0;
virtual DOM::Node<stringT> parentNode() = 0;
2002-06-21 13:16:28 +02:00
virtual DOM::Node<stringT> firstChild() = 0;
2002-06-21 13:16:28 +02:00
virtual DOM::Node<stringT> lastChild() = 0;
2002-06-21 13:16:28 +02:00
virtual DOM::Node<stringT> previousSibling() = 0;
2002-06-21 13:16:28 +02:00
virtual DOM::Node<stringT> nextSibling() = 0;
virtual DOM::Node<stringT> previousNode() = 0;
virtual DOM::Node<stringT> nextNode() = 0;
}; // 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