]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/props_io.cxx
Frederic Bouvier:
[simgear.git] / simgear / props / props_io.cxx
index 997ac971d3918f3e23c1279a0a6d848fa4947497..0aba26edbf4e0782109322afe34e98b4ae7bbf10 100644 (file)
@@ -322,6 +322,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();
+}
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Property list writer.
@@ -466,7 +483,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,6 +580,8 @@ 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");