X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fprops_io.cxx;h=a4fe5a16e4b62c54f17440dec2b8877a1ddf66ac;hb=68eb7031e2dce999d112d0164fa28d4b8d66922e;hp=997ac971d3918f3e23c1279a0a6d848fa4947497;hpb=04fb708543bf7546e236d876491e7f0f62c7c12b;p=simgear.git diff --git a/simgear/props/props_io.cxx b/simgear/props/props_io.cxx index 997ac971..a4fe5a16 100644 --- a/simgear/props/props_io.cxx +++ b/simgear/props/props_io.cxx @@ -214,7 +214,10 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts) } } - push_state(node, atts.getValue("type"), mode); + const char *type = atts.getValue("type"); + if (type) + node->clearValue(); + push_state(node, type, mode); } } @@ -322,6 +325,23 @@ readProperties (const string &file, SGPropertyNode * start_node) } +/** + * 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(); +} + //////////////////////////////////////////////////////////////////////// // Property list writer. @@ -466,7 +486,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); @@ -563,12 +583,17 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out) 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++) {