]> git.mxchange.org Git - simgear.git/commitdiff
SGPropertyNode: add removeAllChildren() method
authorThomas Geymayer <tomgey@gmail.com>
Sat, 7 Dec 2013 12:42:15 +0000 (13:42 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Sat, 7 Dec 2013 12:42:15 +0000 (13:42 +0100)
simgear/props/props.cxx
simgear/props/props.hxx

index 5b778a7a97627969385f1f95f974400307ab8f91..882d0432ff7684a474a8f4c66f821df6a6ca1c81 100644 (file)
@@ -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
 {
index ea722448802d4a05a3723582ec5b3d15299500db..cbf604765b40bee68de1f8c1b516fa691a76cd8d 100644 (file)
@@ -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.
   //