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