From 502c650cd9b25ba013f77194c3c13274504aa090 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 8 Sep 2000 18:34:45 +0000 Subject: [PATCH] Sep. 8, 2000 updates from David Megginson. --- simgear/misc/props.cxx | 12 ++++++------ simgear/misc/props.hxx | 3 +++ simgear/misc/props_io.cxx | 28 ++++++++++++++++++++++++++++ simgear/sky/sphere.cxx | 1 + 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/simgear/misc/props.cxx b/simgear/misc/props.cxx index b5919127..d7de035b 100644 --- a/simgear/misc/props.cxx +++ b/simgear/misc/props.cxx @@ -1209,7 +1209,7 @@ SGPropertyNode::getSubNode (const string &subpath) const SGValue * SGPropertyNode::getValue (const string &subpath) { - if (_props == 0 || _path.size() == 0) + if (_props == 0) return 0; if (subpath.size() == 0) @@ -1225,7 +1225,7 @@ SGPropertyNode::getValue (const string &subpath) bool SGPropertyNode::getBoolValue (const string &subpath, bool defaultValue) const { - if (_props == 0 || _path.size() == 0) + if (_props == 0) return defaultValue; if (subpath == "") @@ -1242,7 +1242,7 @@ SGPropertyNode::getBoolValue (const string &subpath, bool defaultValue) const int SGPropertyNode::getIntValue (const string &subpath, int defaultValue) const { - if (_props == 0 || _path.size() == 0) + if (_props == 0) return defaultValue; if (subpath == "") @@ -1259,7 +1259,7 @@ SGPropertyNode::getIntValue (const string &subpath, int defaultValue) const float SGPropertyNode::getFloatValue (const string &subpath, float defaultValue) const { - if (_props == 0 || _path.size() == 0) + if (_props == 0) return defaultValue; if (subpath == "") @@ -1277,7 +1277,7 @@ double SGPropertyNode::getDoubleValue (const string &subpath, double defaultValue) const { - if (_props == 0 || _path.size() == 0) + if (_props == 0) return defaultValue; if (subpath == "") @@ -1295,7 +1295,7 @@ const string & SGPropertyNode::getStringValue (const string &subpath, const string &defaultValue) const { - if (_props == 0 || _path.size() == 0) + if (_props == 0) return defaultValue; if (subpath == "") diff --git a/simgear/misc/props.hxx b/simgear/misc/props.hxx index ebaaf7f2..0f31c24c 100644 --- a/simgear/misc/props.hxx +++ b/simgear/misc/props.hxx @@ -406,7 +406,10 @@ private: //////////////////////////////////////////////////////////////////////// extern bool readPropertyList (istream &input, SGPropertyList * props); +extern bool readPropertyList (const string &file, SGPropertyList * props); extern bool writePropertyList (ostream &output, const SGPropertyList * props); +extern bool writePropertyList (const string &file, + const SGPropertyList * props); diff --git a/simgear/misc/props_io.cxx b/simgear/misc/props_io.cxx index 8515fc73..35c282f6 100644 --- a/simgear/misc/props_io.cxx +++ b/simgear/misc/props_io.cxx @@ -9,10 +9,12 @@ #include "props.hxx" #include +#include #include #include using std::istream; +using std::ifstream; using std::ostream; using std::string; using std::vector; @@ -221,6 +223,19 @@ readPropertyList (istream &input, SGPropertyList * props) return readXML(input, visitor) && visitor.isOK(); } +bool +readPropertyList (const string &file, SGPropertyList * props) +{ + ifstream input(file.c_str()); + if (input.good()) { + return readPropertyList(input, props); + } else { + FG_LOG(FG_INPUT, FG_ALERT, "Error reading property list from file " + << file); + return false; + } +} + //////////////////////////////////////////////////////////////////////// @@ -330,3 +345,16 @@ writePropertyList (ostream &output, const SGPropertyList * props) output << "" << endl; } + +bool +writePropertyList (const string &file, const SGPropertyList * props) +{ + ofstream output(file.c_str()); + if (output.good()) { + return writePropertyList(output, props); + } else { + FG_LOG(FG_INPUT, FG_ALERT, "Cannot write property list to file " + << file); + return false; + } +} diff --git a/simgear/sky/sphere.cxx b/simgear/sky/sphere.cxx index 21969e2e..b67f2cc6 100644 --- a/simgear/sky/sphere.cxx +++ b/simgear/sky/sphere.cxx @@ -34,6 +34,7 @@ #include #include +FG_USING_NAMESPACE(std); // return a sphere object as an ssgBranch ssgBranch *ssgMakeSphere( ssgSimpleState *state, ssgColourArray *cl, -- 2.39.5