void
PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
{
- State &st = state();
const char * attval;
if (_level == 0) {
}
else {
+ State &st = state();
// Get the index.
attval = atts.getValue("n");
int index = 0;
}
}
- push_state(node, atts.getValue("type"), mode);
+ const char *type = atts.getValue("type");
+ if (type)
+ node->clearValue();
+ push_state(node, type, mode);
}
}
}
+/**
+ * Read properties from an in-memory buffer.
+ *
+ * @param buf A character buffer containing the xml data.
+ * @param size The size/length of the buffer in bytes
+ * @param start_node The root node for reading properties.
+ * @return true if the read succeeded, false otherwise.
+ */
+void readProperties (const char *buf, const int size,
+ SGPropertyNode * start_node)
+{
+ PropsVisitor visitor(start_node, "");
+ readXML(buf, size, visitor);
+ if (visitor.hasException())
+ throw visitor.getException();
+}
+
\f
////////////////////////////////////////////////////////////////////////
// Property list writer.
}
// If there are children, write them next.
- if (nChildren > 0 || node->isAlias()) {
+ if (nChildren > 0) {
doIndent(output, indent);
output << '<' << name;
writeAtts(output, node);
retval = false;
break;
default:
+ if (in->isAlias())
+ break;
string message = "Unknown internal SGPropertyNode type";
message += in->getType();
throw sg_error(message, "SimGear Property Reader");
}
}
+ // copy the attributes.
+ out->setAttributes( in->getAttributes() );
+
// Next, copy the children.
int nChildren = in->nChildren();
for (int i = 0; i < nChildren; i++) {