Sep. 8, 2000 updates from David Megginson.

This commit is contained in:
curt 2000-09-08 18:34:45 +00:00
parent a1bf8d2229
commit 502c650cd9
4 changed files with 38 additions and 6 deletions

View File

@ -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 == "")

View File

@ -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);

View File

@ -9,10 +9,12 @@
#include "props.hxx"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
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 << "</PropertyList>" << 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;
}
}

View File

@ -34,6 +34,7 @@
#include <plib/sg.h>
#include <plib/ssg.h>
FG_USING_NAMESPACE(std);
// return a sphere object as an ssgBranch
ssgBranch *ssgMakeSphere( ssgSimpleState *state, ssgColourArray *cl,