File: child_iterator.cpp

package info (click to toggle)
videolink 1.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 368 kB
  • ctags: 502
  • sloc: cpp: 3,210; ansic: 880; makefile: 121
file content (46 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2005 Ben Hutchings <ben@decadent.org.uk>.
// See the file "COPYING" for licence details.

#include "child_iterator.hpp"

#include <cassert>

#include "xpcom_support.hpp"

using xpcom_support::check;

child_iterator::child_iterator()
	: node_(0)
{}

child_iterator::child_iterator(nsIDOMNode * node)
{
    check(node->GetFirstChild(&node_));
}

child_iterator::~child_iterator()
{
    if (node_)
	node_->Release();
}

already_AddRefed<nsIDOMNode> child_iterator::operator*() const
{
    assert(node_);
    node_->AddRef();
    return node_;
}

child_iterator & child_iterator::operator++()
{
    nsIDOMNode * next;
    check(node_->GetNextSibling(&next));
    node_->Release();
    node_ = next;
    return *this;
}

bool child_iterator::operator==(const child_iterator & other) const
{
    return node_ == other.node_;
}