arabica/include/DOM/NodeList.hpp

77 lines
2 KiB
C++
Raw Permalink Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_DOM_NODELIST_H
#define JEZUK_DOM_NODELIST_H
////////////////////////////
// C++ DOM definition
//
// $Id$
////////////////////////////
2007-09-05 00:55:47 +02:00
#include <DOM/Node.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
{
template<class stringT, class string_adaptorT> class Node;
template<class stringT, class string_adaptorT> class NodeList_impl;
2002-06-21 13:16:28 +02:00
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
2002-06-21 13:16:28 +02:00
class NodeList
{
public:
NodeList() : impl_(0) { }
explicit NodeList(NodeList_impl<stringT, string_adaptorT>* const impl) : impl_(impl) { }
2002-06-21 13:16:28 +02:00
NodeList(const NodeList& rhs) : impl_(rhs.impl_) { }
virtual ~NodeList() { }
bool operator==(const NodeList& rhs) const { return impl_ == rhs.impl_; }
bool operator!=(const NodeList& rhs) const { return impl_ != rhs.impl_; }
bool operator==(int dummy) const { return impl_ == dummy; }
bool operator!=(int dummy) const { return impl_ != dummy; }
NodeList& operator=(const NodeList& rhs)
{
impl_ = rhs.impl_;
return *this;
} // operator=
Node<stringT, string_adaptorT> item(unsigned int index) const { return impl_->item(index); }
2002-06-21 13:16:28 +02:00
unsigned int getLength() const
{
if(impl_ == 0)
return 0;
return impl_->getLength();
} // getLength
2002-06-21 13:16:28 +02:00
private:
Proxy<NodeList_impl<stringT, string_adaptorT> > impl_;
2002-06-21 13:16:28 +02:00
}; // class NodeList
/////////////////////////////////////////////////////////
template<class stringT, class string_adaptorT>
2002-06-21 13:16:28 +02:00
class NodeList_impl
{
public:
2005-08-07 22:16:02 +02:00
virtual ~NodeList_impl() { }
2002-06-21 13:16:28 +02:00
///////////////////////////////////////////////////////
// Ref counting
virtual void addRef() = 0;
virtual void releaseRef() = 0;
///////////////////////////////////////////////////////
// NodeList methods
virtual Node_impl<stringT, string_adaptorT>* item(unsigned int index) const = 0;
2002-06-21 13:16:28 +02:00
virtual unsigned int getLength() const = 0;
}; // class NodeList_impl
} // namespace DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif