]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/props_io.cxx
- made getValue methods protected, so that they won't be invoked outside
[simgear.git] / simgear / misc / props_io.cxx
index c1cc903dfa35496508b7c0fdbcad3b4584b52d36..ff438fc640dbc28210977bad4eb81126e3131af8 100644 (file)
@@ -1,12 +1,9 @@
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
 #include <simgear/compiler.h>
 
 #include <stdlib.h>            // atof() atoi()
 
+#include <simgear/sg_inlines.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/xml/easyxml.hxx>
 
@@ -126,7 +123,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
     int index = 0;
     if (att_n != 0) {
       index = atoi(att_n);
-      st.counters[name] = max(st.counters[name], index+1);
+      st.counters[name] = SG_MAX2(st.counters[name], index+1);
     } else {
       index = st.counters[name];
       st.counters[name]++;
@@ -277,7 +274,7 @@ readProperties (const string &file, SGPropertyNode * start_node)
  * Return the type name.
  */
 static const char *
-getTypeName (SGValue::Type type)
+getTypeName (SGPropertyNode::Type type)
 {
   switch (type) {
   case SGValue::UNKNOWN:
@@ -345,24 +342,26 @@ writeNode (ostream &output, const SGPropertyNode * node, int indent)
                                // write it first.
   if (node->hasValue()) {
     doIndent(output, indent);
-    output << '<' << name << " n=\"" << index;
-    if (node->isAlias() && node->getAliasTarget() != 0) {
-      output << "\" alias=\""
-            << node->getAliasTarget()->getPath() << "\"/>" << endl;
-    } else {
-      if (node->getType() != SGValue::UNKNOWN)
-       output << "\" type=\"" << getTypeName(node->getType()) << '"';
+    output << '<' << name << " n=\"" << index << '"';
+    if (node->isAlias() && node->getAliasTarget() != 0)
+      output << " alias=\"" << node->getAliasTarget()->getPath() << "\"/>";
+    else {
+      if (node->getType() != SGPropertyNode::UNKNOWN)
+       output << " type=\"" << getTypeName(node->getType()) << '"';
       output << '>';
       writeData(output, node->getStringValue());
-      output << "</" << name << '>' << endl;;
+      output << "</" << name << '>' << endl;
     }
   }
 
                                // If there are children, write them
                                // next.
-  if (nChildren > 0) {
+  if (nChildren > 0 || node->isAlias()) {
     doIndent(output, indent);
-    output << '<' << name << " n=\"" << index << "\">" << endl;;
+    output << '<' << name << " n=\"" << index << '"';
+    if (node->isAlias() && node->getAliasTarget() != 0)
+      output << " alias=\"" << node->getAliasTarget()->getPath() << '"';
+    output << '>' << endl;
     for (int i = 0; i < nChildren; i++)
       writeNode(output, node->getChild(i), indent + INDENT_STEP);
     doIndent(output, indent);
@@ -372,10 +371,10 @@ writeNode (ostream &output, const SGPropertyNode * node, int indent)
                                // If there were no children and no
                                // value, at least note the presence
                                // of the node.
-  if (nChildren == 0 && !node->hasValue()) {
-    doIndent(output, indent);
-    output << '<' << name << " n=\"" << index << "\"/>" << endl;
-  }
+//   if (nChildren == 0 && !node->isAlias() && !node->hasValue()) {
+//     doIndent(output, indent);
+//     output << '<' << name << " n=\"" << index << "\"/>" << endl;
+//   }
 
   return true;
 }