]> git.decadent.org.uk Git - videolink.git/blob - linkiterator.hpp
2f93a2ff9484e836d571be9bf225d5b433cb30ac
[videolink.git] / linkiterator.hpp
1 // Copyright 2005 Ben Hutchings <ben@decadentplace.org.uk>.
2 // See the file "COPYING" for licence details.
3
4 #ifndef INC_LINKITERATOR_HPP
5 #define INC_LINKITERATOR_HPP
6
7 #include <iterator>
8
9 #include <nsCOMPtr.h>
10 #include <nsIDOMHTMLCollection.h>
11 #include <nsIDOMNode.h>
12
13 class nsIDOMDocument;
14
15 class LinkIterator
16     : public std::iterator<std::input_iterator_tag, nsCOMPtr<nsIDOMNode>,
17                            void, void, void>
18 {
19 public:
20     LinkIterator();
21     explicit LinkIterator(nsIDOMDocument * document);
22
23     already_AddRefed<nsIDOMNode> operator*() const;
24     LinkIterator & operator++();
25     bool operator==(const LinkIterator &) const;
26     bool operator!=(const LinkIterator & other) const
27         {
28             return !(*this == other);
29         }
30
31 private:
32     nsCOMPtr<nsIDOMHTMLCollection> collection_;
33     unsigned int index_, length_;
34 };
35
36 #endif // !INC_LINKITERATOR_HPP