]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/props_test.cxx
Patch from Cameron Moore:
[simgear.git] / simgear / misc / props_test.cxx
index da88d00f46a52e42b547291308d6d73007e930d9..b98e6e6b6f2284ba7a5e0d46cce88a2a6c9f4dd4 100644 (file)
@@ -7,6 +7,7 @@
 
 #include STL_IOSTREAM
 #include "props.hxx"
+#include "props_io.hxx"
 
 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
 SG_USING_STD(cout);
@@ -52,7 +53,7 @@ static double getNum (int index) { return 1.0 / index; }
 static void
 show_values (const SGPropertyNode * node)
 {
-  cout << "Bool: " << node->getBoolValue() << endl;
+  cout << "Bool: " << (node->getBoolValue() ? "true" : "false") << endl;
   cout << "Int: " << node->getIntValue() << endl;
   cout << "Float: " << node->getFloatValue() << endl;
   cout << "Double: " << node->getDoubleValue() << endl;
@@ -274,7 +275,7 @@ test_value ()
 static void
 dump_node (const SGPropertyNode * node)
 {
-  writeProperties(cout, node);
+  writeProperties(cout, node, true);
 }
 
 static void
@@ -312,7 +313,7 @@ test_property_nodes ()
   cout << endl;
 
   cout << "Looking for all /hack[0]/bar children" << endl;
-  vector<SGPropertyNode *> bar = child->getChildren("bar");
+  vector<SGPropertyNode_ptr> bar = child->getChildren("bar");
   cout << "There are " << bar.size() << " matches" << endl;
   for (int i = 0; i < (int)bar.size(); i++)
     cout << bar[i]->getName() << '[' << bar[i]->getIndex() << ']' << endl;
@@ -332,13 +333,15 @@ int main (int ac, char ** av)
   test_property_nodes();
 
   for (int i = 1; i < ac; i++) {
-    cout << "Reading " << av[i] << endl;
-    SGPropertyNode root;
-    if (!readProperties(av[i], &root))
-      cerr << "Failed to read properties from " << av[i] << endl;
-    else
-      writeProperties(cout, &root);
-    cout << endl;
+    try {
+      cout << "Reading " << av[i] << endl;
+      SGPropertyNode root;
+      readProperties(av[i], &root);
+      writeProperties(cout, &root, true);
+      cout << endl;
+    } catch (string &message) {
+      cout << "Aborted with " << message << endl;
+    }
   }
 
   return 0;