From: Thomas Geymayer Date: Sat, 7 Dec 2013 12:42:15 +0000 (+0100) Subject: SGPropertyNode: add removeAllChildren() method X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=42b50bd7f71a92bfa129fb3cbeae75738a97504f;p=simgear.git SGPropertyNode: add removeAllChildren() method --- diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 5b778a7a..882d0432 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -1075,6 +1075,21 @@ SGPropertyNode::removeChildren (const char * name, bool keep) return children; } +void +SGPropertyNode::removeAllChildren() +{ + for(unsigned i = 0; i < _children.size(); ++i) + { + SGPropertyNode_ptr& node = _children[i]; + node->_parent = 0; + node->setAttribute(REMOVED, true); + node->clearValue(); + fireChildRemoved(node); + } + + _children.clear(); +} + string SGPropertyNode::getDisplayName (bool simplify) const { diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index ea722448..cbf60476 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -910,6 +910,7 @@ public: simgear::PropertyList getChildren (const std::string& name) const { return getChildren(name.c_str()); } + // TODO do we need the removeXXX methods to return the deleted nodes? /** * Remove child by position. */ @@ -941,6 +942,11 @@ public: bool keep = true) { return removeChildren(name.c_str(), keep); } + /** + * Remove all children (does not change the value of the node) + */ + void removeAllChildren(); + // // Alias support. //