]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/props_io.cxx
Updates to build system to better support automake-1.5
[simgear.git] / simgear / misc / props_io.cxx
index ee385b5e2c8c2820a9b8012c6c251b7bc0b1843b..160539ae73b41309c9f6d1fe88b9bdeada65976c 100644 (file)
@@ -43,9 +43,9 @@ class PropsVisitor : public XMLVisitor
 public:
 
   PropsVisitor (SGPropertyNode * root, const string &base)
-    : _root(root), _level(0), _base(base), _exception(0) {}
+    : _root(root), _level(0), _base(base), _hasException(false) {}
 
-  virtual ~PropsVisitor () { delete _exception; }
+  virtual ~PropsVisitor () {}
 
   void startXML ();
   void endXML ();
@@ -54,8 +54,12 @@ public:
   void data (const char * s, int length);
   void warning (const char * message, int line, int column);
 
-  bool hasException () const { return (_exception != 0); }
-  const sg_io_exception * getException () const { return _exception; }
+  bool hasException () const { return _hasException; }
+  sg_io_exception &getException () { return _exception; }
+  void setException (const sg_io_exception &exception) {
+    _exception = exception;
+    _hasException = true;
+  }
 
 private:
 
@@ -91,7 +95,8 @@ private:
   int _level;
   vector<State> _state_stack;
   string _base;
-  sg_io_exception * _exception;
+  sg_io_exception _exception;
+  bool _hasException;
 };
 
 void
@@ -176,6 +181,12 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
     attval = atts.getValue("archive");
     if (checkFlag(attval, false))
       mode |= SGPropertyNode::ARCHIVE;
+    attval = atts.getValue("trace-read");
+    if (checkFlag(attval, false))
+      mode |= SGPropertyNode::TRACE_READ;
+    attval = atts.getValue("trace-write");
+    if (checkFlag(attval, false))
+      mode |= SGPropertyNode::TRACE_WRITE;
 
                                // Check for an alias.
     attval = atts.getValue("alias");
@@ -191,9 +202,8 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
       path.append(attval);
       try {
        readProperties(path.str(), node);
-      } catch (const sg_io_exception &t) {
-       cerr << "Caught exception\n";
-       _exception = t.clone();
+      } catch (sg_io_exception &e) {
+       setException(e);
       }
     }
 
@@ -284,7 +294,7 @@ readProperties (istream &input, SGPropertyNode * start_node,
   PropsVisitor visitor(start_node, base);
   readXML(input, visitor, base);
   if (visitor.hasException())
-    throw *(visitor.getException());
+    throw visitor.getException();
 }
 
 
@@ -301,7 +311,7 @@ readProperties (const string &file, SGPropertyNode * start_node)
   PropsVisitor visitor(start_node, file);
   readXML(file, visitor);
   if (visitor.hasException())
-    throw *(visitor.getException());
+    throw visitor.getException();
 }