diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 60a19aa4..50b412cb 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -969,9 +969,9 @@ SGPropertyNode::getPath (bool simplify) const } SGPropertyNode::Type -SGPropertyNode::getType () const +SGPropertyNode::getType (bool deref_alias) const { - if (_type == ALIAS) + if (_type == ALIAS && deref_alias) return _value.alias->getType(); else return _type; diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index a08d6ffa..c800f29d 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -850,8 +850,10 @@ public: /** * Get the type of leaf value, if any, for this node. + * When applied to an ALIAS node, deref_alias decides if the type + * of the referred node is to be returned (default), or ALIAS. */ - Type getType () const; + Type getType (bool deref_alias = true) const; /** diff --git a/simgear/props/props_io.cxx b/simgear/props/props_io.cxx index e936f5b0..ec549011 100644 --- a/simgear/props/props_io.cxx +++ b/simgear/props/props_io.cxx @@ -368,6 +368,7 @@ getTypeName (SGPropertyNode::Type type) case SGPropertyNode::STRING: return "string"; case SGPropertyNode::ALIAS: + return "alias"; case SGPropertyNode::NONE: return "unspecified"; } @@ -483,7 +484,7 @@ writeNode (ostream &output, const SGPropertyNode * node, } // If there are children, write them next. - if (nChildren > 0 || node->isAlias()) { + if (nChildren > 0) { doIndent(output, indent); output << '<' << name; writeAtts(output, node); @@ -550,7 +551,7 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out) // First, copy the actual value, // if any. if (in->hasValue()) { - switch (in->getType()) { + switch (in->getType(false)) { case SGPropertyNode::BOOL: if (!out->setBoolValue(in->getBoolValue())) retval = false; @@ -579,6 +580,12 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out) if (!out->setUnspecifiedValue(in->getStringValue())) retval = false; break; + case SGPropertyNode::ALIAS: { + const char *path = in->getAliasTarget()->getPath(); + SGPropertyNode *node = out->getRootNode()->getNode(path, true); + out->alias(node); + break; + } default: string message = "Unknown internal SGPropertyNode type"; message += in->getType();