Menu

#10 errors in rapidxml_iterators.hpp

open
nobody
None
5
2010-02-08
2010-02-08
Anonymous
No

There are some errors in the iterators module:

1) All the typedefs are invalid (at least for GCC-4.4.2):
You need to qualify the rapidxml-namespace:
typedef typename rapidxml::xml_node<Ch> value_type;

2) operator++(int) never ever will work:

node_iterator operator++(int)
{
node_iterator tmp = *this;
++this; // °!°
return tmp;
}
"this" is const, you never can assign something or change its value.
++(*this); will work

3) attribute_iterator operator--(int)
{
attribute_iterator tmp = *this;
++this; // is this intended ?!? Should be --(*this);
return tmp;
}

4) something like
bool is_valid() const
{
return m_attribute != NULL;
}
would be handy for looping over all nodes.
At least begin() and end() should be implemented.

5) Iterators are not const-correct.
When you don't change the object, method should be const.
For the iterators this also applies to operator== and operator!=

All in all i think rapidxml is worth to look at. Though there are some handy additions i am missing.
A clone_node-Function that does a deep clone AND allocates new memory, so i can copy a complete subtree into a new document, without sharing content!
Or overloaded xml_node::[next,prev]_sibling with parameter of type node_type, so that i can iterate only over special types.
Or at least get a quick way to get an e.g. node_cdata. This could be a Predicate (like pugixml has).
This would be handy for iterators, too.

Ciao and thanks

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.