summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-07-07 20:10:48 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-07-07 20:10:48 +0000
commit5811786ccdf88af00852db78318c48deaa0dc24c (patch)
tree59bfdd72eaa7217a4820794cf9f382358a7c4c8c /src
parente959098703889719d33b6e5d0a160f68516ae853 (diff)
remove_child and remove_attribute now return operation result
git-svn-id: http://pugixml.googlecode.com/svn/trunk@572 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src')
-rw-r--r--src/pugixml.cpp22
-rw-r--r--src/pugixml.hpp12
2 files changed, 21 insertions, 13 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 0b50fe7..96f6037 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -3774,21 +3774,21 @@ namespace pugi
return result;
}
- void xml_node::remove_attribute(const char_t* name)
+ bool xml_node::remove_attribute(const char_t* name)
{
- remove_attribute(attribute(name));
+ return remove_attribute(attribute(name));
}
- void xml_node::remove_attribute(const xml_attribute& a)
+ bool xml_node::remove_attribute(const xml_attribute& a)
{
- if (!_root || !a._attr) return;
+ if (!_root || !a._attr) return false;
// check that attribute belongs to *this
xml_attribute_struct* attr = a._attr;
while (attr->prev_attribute_c->next_attribute) attr = attr->prev_attribute_c;
- if (attr != _root->first_attribute) return;
+ if (attr != _root->first_attribute) return false;
if (a._attr->next_attribute) a._attr->next_attribute->prev_attribute_c = a._attr->prev_attribute_c;
else if (_root->first_attribute) _root->first_attribute->prev_attribute_c = a._attr->prev_attribute_c;
@@ -3797,16 +3797,18 @@ namespace pugi
else _root->first_attribute = a._attr->next_attribute;
destroy_attribute(a._attr, get_allocator(_root));
+
+ return true;
}
- void xml_node::remove_child(const char_t* name)
+ bool xml_node::remove_child(const char_t* name)
{
- remove_child(child(name));
+ return remove_child(child(name));
}
- void xml_node::remove_child(const xml_node& n)
+ bool xml_node::remove_child(const xml_node& n)
{
- if (!_root || !n._root || n._root->parent != _root) return;
+ if (!_root || !n._root || n._root->parent != _root) return false;
if (n._root->next_sibling) n._root->next_sibling->prev_sibling_c = n._root->prev_sibling_c;
else if (_root->first_child) _root->first_child->prev_sibling_c = n._root->prev_sibling_c;
@@ -3815,6 +3817,8 @@ namespace pugi
else _root->first_child = n._root->next_sibling;
destroy_node(n._root, get_allocator(_root));
+
+ return true;
}
xml_node xml_node::find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 00a273a..dacd8cd 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -1217,29 +1217,33 @@ namespace pugi
* Remove specified attribute
*
* \param a - attribute to be removed
+ * \return success flag
*/
- void remove_attribute(const xml_attribute& a);
+ bool remove_attribute(const xml_attribute& a);
/**
* Remove attribute with the specified name, if any
*
* \param name - attribute name
+ * \return success flag
*/
- void remove_attribute(const char_t* name);
+ bool remove_attribute(const char_t* name);
/**
* Remove specified child
*
* \param n - child node to be removed
+ * \return success flag
*/
- void remove_child(const xml_node& n);
+ bool remove_child(const xml_node& n);
/**
* Remove child with the specified name, if any
*
* \param name - child name
+ * \return success flag
*/
- void remove_child(const char_t* name);
+ bool remove_child(const char_t* name);
public:
/**