]> git.decadent.org.uk Git - videolink.git/blob - childiterator.cpp
Added --help option and arranged to print usage information when this is used and...
[videolink.git] / childiterator.cpp
1 // Copyright 2005 Ben Hutchings <ben@decadentplace.org.uk>.
2 // See the file "COPYING" for licence details.
3
4 #include "childiterator.hpp"
5
6 #include <cassert>
7
8 #include "xpcom_support.hpp"
9
10 using xpcom_support::check;
11
12 ChildIterator::ChildIterator()
13         : node_(0)
14 {}
15
16 ChildIterator::ChildIterator(nsIDOMNode * node)
17 {
18     check(node->GetFirstChild(&node_));
19 }
20
21 ChildIterator::~ChildIterator()
22 {
23     if (node_)
24         node_->Release();
25 }
26
27 already_AddRefed<nsIDOMNode> ChildIterator::operator*() const
28 {
29     assert(node_);
30     node_->AddRef();
31     return node_;
32 }
33
34 ChildIterator & ChildIterator::operator++()
35 {
36     nsIDOMNode * next;
37     check(node_->GetNextSibling(&next));
38     node_->Release();
39     node_ = next;
40     return *this;
41 }
42
43 bool ChildIterator::operator==(const ChildIterator & other) const
44 {
45     return node_ == other.node_;
46 }