SGValue *
SGPropertyNode::getValue (const string &subpath)
{
- if (_props == 0 || _path.size() == 0)
+ if (_props == 0)
return 0;
if (subpath.size() == 0)
bool
SGPropertyNode::getBoolValue (const string &subpath, bool defaultValue) const
{
- if (_props == 0 || _path.size() == 0)
+ if (_props == 0)
return defaultValue;
if (subpath == "")
int
SGPropertyNode::getIntValue (const string &subpath, int defaultValue) const
{
- if (_props == 0 || _path.size() == 0)
+ if (_props == 0)
return defaultValue;
if (subpath == "")
float
SGPropertyNode::getFloatValue (const string &subpath, float defaultValue) const
{
- if (_props == 0 || _path.size() == 0)
+ if (_props == 0)
return defaultValue;
if (subpath == "")
SGPropertyNode::getDoubleValue (const string &subpath,
double defaultValue) const
{
- if (_props == 0 || _path.size() == 0)
+ if (_props == 0)
return defaultValue;
if (subpath == "")
SGPropertyNode::getStringValue (const string &subpath,
const string &defaultValue) const
{
- if (_props == 0 || _path.size() == 0)
+ if (_props == 0)
return defaultValue;
if (subpath == "")
////////////////////////////////////////////////////////////////////////
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);
\f
#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;
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;
+ }
+}
+
\f
////////////////////////////////////////////////////////////////////////
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;
+ }
+}
#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,