Add method to copy entire properry subtree
This commit is contained in:
@@ -2443,6 +2443,7 @@ SGPropertyNode::fireValueChanged (SGPropertyNode * node)
|
|||||||
{
|
{
|
||||||
if (_listeners != 0) {
|
if (_listeners != 0) {
|
||||||
for (unsigned int i = 0; i < _listeners->size(); i++) {
|
for (unsigned int i = 0; i < _listeners->size(); i++) {
|
||||||
|
if ((*_listeners)[i])
|
||||||
(*_listeners)[i]->valueChanged(node);
|
(*_listeners)[i]->valueChanged(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2630,6 +2631,30 @@ bool compareNodeValue(const SGPropertyNode& lhs, const SGPropertyNode& rhs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SGPropertyNode::copy(SGPropertyNode *to)
|
||||||
|
{
|
||||||
|
if (nChildren())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < nChildren(); i++) {
|
||||||
|
SGPropertyNode *child = getChild(i);
|
||||||
|
SGPropertyNode *to_child = to->getChild(child->getName());
|
||||||
|
if (!to_child)
|
||||||
|
to_child = to->addChild(child->getName());
|
||||||
|
if (child->nChildren())
|
||||||
|
{
|
||||||
|
child->copy(to_child);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_child->setValue(child->getStringValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
to->setValue(getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
bool SGPropertyNode::compare(const SGPropertyNode& lhs,
|
bool SGPropertyNode::compare(const SGPropertyNode& lhs,
|
||||||
const SGPropertyNode& rhs)
|
const SGPropertyNode& rhs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1105,6 +1105,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
SGPropertyNode * getNode (const char * relative_path, bool create = false);
|
SGPropertyNode * getNode (const char * relative_path, bool create = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deep copy one node to another.
|
||||||
|
*/
|
||||||
|
void copy(SGPropertyNode *to);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a pointer to another node by relative path.
|
* Get a pointer to another node by relative path.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user