{
DALI_ASSERT_DEBUG(mNode && "Operation on NULL JSON node");
- DeleteNodesWithoutSelf otherDeletor(mNode);
+ CollectNodes collector;
- DepthFirst(mNode, otherDeletor);
+ DepthFirst(mNode, collector);
+
+ for(CollectNodes::iterator iter = collector.nodes.begin(); iter != collector.nodes.end(); ++iter)
+ {
+ if(*iter != mNode)
+ {
+ delete *iter;
+ }
+ }
mNode->mFirstChild = NULL;
mNode->mLastChild = NULL;
};
/*
- * Delete nodes immediately, instead of self
- */
-struct DeleteNodesWithoutSelf
-{
- DeleteNodesWithoutSelf(TreeNode* self)
- : mSelf(self){};
-
- /*
- * Call operator to delete object if given node is not self
- */
- void operator()(TreeNode*& n)
- {
- DALI_ASSERT_DEBUG(n && "Operation on NULL JSON node");
- if(mSelf != n)
- {
- delete n;
- }
- }
-
- const TreeNode* mSelf; ///< self node what we should not remove.
-};
-
-/*
* Depth first walk of nodes applying given operation (unary_function)
*/
template<typename Operation>