}
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;
/**
* 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;
/**
case SGPropertyNode::STRING:
return "string";
case SGPropertyNode::ALIAS:
+ return "alias";
case SGPropertyNode::NONE:
return "unspecified";
}
}
// If there are children, write them next.
- if (nChildren > 0 || node->isAlias()) {
+ if (nChildren > 0) {
doIndent(output, indent);
output << '<' << name;
writeAtts(output, node);
// 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;
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();