Skip to content

Commit

Permalink
Iterator improvements: safety assertions in xml_named_node_iterator, …
Browse files Browse the repository at this point in the history
…const_cast workaround for BCC32 bug

git-svn-id: http://pugixml.googlecode.com/svn/trunk@915 99668b35-9821-0410-8761-19e4c4f06640
  • Loading branch information
arseny.kapoulkine@gmail.com committed May 2, 2012
1 parent a50f47f commit a9a537a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4928,7 +4928,7 @@ namespace pugi
PUGI__FN xml_node* xml_node_iterator::operator->() const
{
assert(_wrap._root);
return &_wrap;
return const_cast<xml_node*>(&_wrap); // BCC32 workaround
}

PUGI__FN const xml_node_iterator& xml_node_iterator::operator++()
Expand Down Expand Up @@ -4989,7 +4989,7 @@ namespace pugi
PUGI__FN xml_attribute* xml_attribute_iterator::operator->() const
{
assert(_wrap._attr);
return &_wrap;
return const_cast<xml_attribute*>(&_wrap); // BCC32 workaround
}

PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator++()
Expand Down Expand Up @@ -5039,16 +5039,19 @@ namespace pugi

PUGI__FN xml_node& xml_named_node_iterator::operator*() const
{
assert(_node._root);
return _node;
}

PUGI__FN xml_node* xml_named_node_iterator::operator->() const
{
return &_node;
assert(_node._root);
return const_cast<xml_node*>(&_node); // BCC32 workaround
}

PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator++()
{
assert(_node._root);
_node = _node.next_sibling(_name);
return *this;
}
Expand Down
1 change: 1 addition & 0 deletions src/pugixml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ namespace pugi
{
friend class xml_attribute_iterator;
friend class xml_node_iterator;
friend class xml_named_node_iterator;

protected:
xml_node_struct* _root;
Expand Down

0 comments on commit a9a537a

Please sign in to comment.