{
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;
#define DALI_SCRIPT_TREE_NODE_MANIPULATOR_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
};
/*
- * Delete nodes immediately, instead of self
- */
-struct DeleteNodesWithoutSelf
-{
- DeleteNodesWithoutSelf(TreeNode* self)
- : mSelf(self){};
-
- /*
- * Call operator to add nodes to the list
- */
- 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>