Add method to copy entire properry subtree
This commit is contained in:
+34
-9
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2581,20 +2582,20 @@ std::ostream& SGRawBase<SGVec4d>::printOn(std::ostream& stream) const
|
|||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
#if !PROPS_STANDALONE
|
#if !PROPS_STANDALONE
|
||||||
template<>
|
template<>
|
||||||
std::istream& readFrom<SGVec4d>(std::istream& stream, SGVec4d& result)
|
std::istream& readFrom<SGVec4d>(std::istream& stream, SGVec4d& result)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
stream >> result[i];
|
stream >> result[i];
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
bool compareNodeValue(const SGPropertyNode& lhs, const SGPropertyNode& rhs)
|
bool compareNodeValue(const SGPropertyNode& lhs, const SGPropertyNode& rhs)
|
||||||
{
|
{
|
||||||
props::Type ltype = lhs.getType();
|
props::Type ltype = lhs.getType();
|
||||||
props::Type rtype = rhs.getType();
|
props::Type rtype = rhs.getType();
|
||||||
if (ltype != rtype)
|
if (ltype != rtype)
|
||||||
@@ -2626,8 +2627,32 @@ bool compareNodeValue(const SGPropertyNode& lhs, const SGPropertyNode& rhs)
|
|||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
|||||||
@@ -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