simgear/props/props.*: added method to add exising SGPropertyNode_ptr as child.
Avoids the need to create a new child and copy recursively.
This commit is contained in:
parent
42c89ba6d3
commit
d1aa5a0b82
@ -1098,6 +1098,20 @@ SGPropertyNode::addChild(const char * name, int min_index, bool append)
|
||||
return node;
|
||||
}
|
||||
|
||||
SGPropertyNode_ptr SGPropertyNode::addChild(SGPropertyNode_ptr node, const std::string& name,
|
||||
int min_index, bool append)
|
||||
{
|
||||
int pos = append
|
||||
? std::max(find_last_child(name.c_str(), _children) + 1, min_index)
|
||||
: first_unused_index(name.c_str(), _children, min_index);
|
||||
node->_name = name;
|
||||
node->_parent = this;
|
||||
node->_index = pos;
|
||||
_children.push_back(node);
|
||||
fireChildAdded(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create multiple children with unused indices
|
||||
*/
|
||||
|
@ -926,6 +926,16 @@ public:
|
||||
bool append = true )
|
||||
{ return addChild(name.c_str(), min_index, append); }
|
||||
|
||||
/**
|
||||
* Add existing node as child.
|
||||
*
|
||||
* @param min_index Minimal index for new node (skips lower indices)
|
||||
* @param append Whether to simply use the index after the last used index
|
||||
* or use a lower, unused index if it exists
|
||||
*/
|
||||
SGPropertyNode_ptr addChild(SGPropertyNode_ptr node, const std::string& name,
|
||||
int min_index=0, bool append=true);
|
||||
|
||||
/**
|
||||
* Create multiple child nodes with the given name an unused indices
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user