diff -ur SimGear-0.3.10/simgear/misc/sg_path.cxx SimGear-0.3.10.new/simgear/misc/sg_path.cxx
--- SimGear-0.3.10/simgear/misc/sg_path.cxx 2006-03-09 23:34:48.000000000 +0100
+++ SimGear-0.3.10.new/simgear/misc/sg_path.cxx 2007-03-30 16:09:32.000000000 +0200
@@ -36,17 +36,9 @@
/**
- * define directory path separators
+ * define directory search path separators
*/
-#if defined( macintosh )
-static const char sgDirPathSep = ':';
-static const char sgDirPathSepBad = '/';
-#else
-static const char sgDirPathSep = '/';
-static const char sgDirPathSepBad = '\\';
-#endif
-
#if defined( WIN32 ) && !defined(__CYGWIN__)
static const char sgSearchPathSep = ';';
#else
@@ -54,28 +46,6 @@
#endif
-// If Unix, replace all ":" with "/". If MacOS, replace all "/" with
-// ":" it should go without saying that neither of these characters
-// should be used in file or directory names. In windoze, allow the
-// second character to be a ":" for things like c:\foo\bar
-
-void
-SGPath::fix()
-{
- for ( string::size_type i = 0; i < path.size(); ++i ) {
-#if defined( WIN32 )
- // for windoze, don't replace the ":" for the second character
- if ( i == 1 ) {
- continue;
- }
-#endif
- if ( path[i] == sgDirPathSepBad ) {
- path[i] = sgDirPathSep;
- }
- }
-}
-
-
// default constructor
SGPath::SGPath()
: path("")
@@ -83,19 +53,6 @@
}
-// create a path based on "path"
-SGPath::SGPath( const std::string& p )
- : path(p)
-{
- fix();
-}
-
-
-// destructor
-SGPath::~SGPath() {
-}
-
-
// set path
void SGPath::set( const string& p ) {
path = p;
@@ -103,19 +60,6 @@
}
-// append another piece to the existing path
-void SGPath::append( const string& p ) {
- if ( path.size() == 0 ) {
- path = p;
- } else {
- if ( p[0] != sgDirPathSep ) {
- path += sgDirPathSep;
- }
- path += p;
- }
- fix();
-}
-
//add a new path component to the existing path string
void SGPath::add( const string& p ) {
append( sgSearchPathSep+p );
@@ -136,7 +80,7 @@
// Get the file part of the path (everything after the last path sep)
string SGPath::file() const {
- int index = path.rfind(sgDirPathSep);
+ int index = path.rfind(SGPATH_sgDirPathSep);
if (index >= 0) {
return path.substr(index + 1);
} else {
@@ -145,16 +89,6 @@
}
-// get the directory part of the path.
-string SGPath::dir() const {
- int index = path.rfind(sgDirPathSep);
- if (index >= 0) {
- return path.substr(0, index);
- } else {
- return "";
- }
-}
-
// get the base part of the path (everything but the extension.)
string SGPath::base() const {
int index = path.rfind(".");
@@ -197,10 +131,10 @@
string_list dirlist = sgPathSplit(dir());
string path = dirlist[0];
string_list path_elements = sgPathBranchSplit(path);
- bool absolute = !path.empty() && path[0] == sgDirPathSep;
+ bool absolute = !path.empty() && path[0] == SGPATH_sgDirPathSep;
unsigned int i = 1;
- SGPath dir = absolute ? string( 1, sgDirPathSep ) : "";
+ SGPath dir = absolute ? string( 1, SGPATH_sgDirPathSep ) : "";
dir.concat( path_elements[0] );
#if defined( _MSC_VER) || defined(__MINGW32__)
if ( dir.str().find(':') != string::npos && path_elements.size() >= 2 ) {
@@ -233,7 +167,7 @@
string_list path_elements;
string element, path = dirpath;
while ( path.size() ) {
- size_t p = path.find( sgDirPathSep );
+ size_t p = path.find( SGPATH_sgDirPathSep );
if ( p != string::npos ) {
element = path.substr( 0, p );
path.erase( 0, p + 1 );
diff -ur SimGear-0.3.10/simgear/misc/sg_path.hxx SimGear-0.3.10.new/simgear/misc/sg_path.hxx
--- SimGear-0.3.10/simgear/misc/sg_path.hxx 2006-03-09 23:34:48.000000000 +0100
+++ SimGear-0.3.10.new/simgear/misc/sg_path.hxx 2007-03-30 16:11:08.000000000 +0200
@@ -49,6 +49,18 @@
* automatically to the proper format.
*/
+/**
+ * define directory path separators
+ */
+
+#if defined( macintosh )
+#define SGPATH_sgDirPathSep ':'
+#define SGPATH_sgDirPathSepBad '/'
+#else
+#define SGPATH_sgDirPathSep '/'
+#define SGPATH_sgDirPathSepBad '\\'
+#endif
+
class SGPath {
private:
@@ -64,10 +76,13 @@
* Construct a path based on the starting path provided.
* @param p initial path
*/
- SGPath( const string& p );
+ SGPath( const string& p ) : path(p)
+ {
+ fix();
+ }
/** Destructor */
- ~SGPath();
+ ~SGPath() {}
/**
* Set path to a new value
@@ -80,7 +95,17 @@
* Append another piece to the existing path. Inserts a path
* separator between the existing component and the new component.
* @param p additional path component */
- void append( const string& p );
+ void append( const string& p ) {
+ if ( path.size() == 0 ) {
+ path = p;
+ } else {
+ if ( p[0] != SGPATH_sgDirPathSep ) {
+ path += SGPATH_sgDirPathSep;
+ }
+ path += p;
+ }
+ fix();
+ }
/**
* Append a new piece to the existing path. Inserts a search path
@@ -105,7 +130,14 @@
* Get the directory part of the path.
* @return directory string
*/
- string dir() const;
+ string dir() const {
+ int index = path.rfind(SGPATH_sgDirPathSep);
+ if (index >= 0) {
+ return path.substr(0, index);
+ } else {
+ return "";
+ }
+ }
/**
* Get the base part of the path (everything but the extension.)
@@ -144,7 +176,25 @@
private:
- void fix();
+ // If Unix, replace all ":" with "/". If MacOS, replace all "/" with
+ // ":" it should go without saying that neither of these characters
+ // should be used in file or directory names. In windoze, allow the
+ // second character to be a ":" for things like c:\foo\bar
+
+ void fix()
+ {
+ for ( string::size_type i = 0; i < path.size(); ++i ) {
+ #if defined( WIN32 )
+ // for windoze, don't replace the ":" for the second character
+ if ( i == 1 ) {
+ continue;
+ }
+ #endif
+ if ( path[i] == SGPATH_sgDirPathSepBad ) {
+ path[i] = SGPATH_sgDirPathSep;
+ }
+ }
+ }
};
diff -ur SimGear-0.3.10/simgear/props/props.cxx SimGear-0.3.10.new/simgear/props/props.cxx
--- SimGear-0.3.10/simgear/props/props.cxx 2006-03-15 16:15:39.000000000 +0100
+++ SimGear-0.3.10.new/simgear/props/props.cxx 2007-03-30 16:35:36.000000000 +0200
@@ -317,60 +317,6 @@
////////////////////////////////////////////////////////////////////////
inline bool
-SGPropertyNode::get_bool () const
-{
- if (_tied)
- return _value.bool_val->getValue();
- else
- return _local_val.bool_val;
-}
-
-inline int
-SGPropertyNode::get_int () const
-{
- if (_tied)
- return _value.int_val->getValue();
- else
- return _local_val.int_val;
-}
-
-inline long
-SGPropertyNode::get_long () const
-{
- if (_tied)
- return _value.long_val->getValue();
- else
- return _local_val.long_val;
-}
-
-inline float
-SGPropertyNode::get_float () const
-{
- if (_tied)
- return _value.float_val->getValue();
- else
- return _local_val.float_val;
-}
-
-inline double
-SGPropertyNode::get_double () const
-{
- if (_tied)
- return _value.double_val->getValue();
- else
- return _local_val.double_val;
-}
-
-inline const char *
-SGPropertyNode::get_string () const
-{
- if (_tied)
- return _value.string_val->getValue();
- else
- return _local_val.string_val;
-}
-
-inline bool
SGPropertyNode::set_bool (bool val)
{
if (_tied) {
@@ -1129,40 +1075,6 @@
}
}
-double
-SGPropertyNode::getDoubleValue () const
-{
- // Shortcut for common case
- if (_attr == (READ|WRITE) && _type == DOUBLE)
- return get_double();
-
- if (getAttribute(TRACE_READ))
- trace_read();
- if (!getAttribute(READ))
- return SGRawValue<double>::DefaultValue;
-
- switch (_type) {
- case ALIAS:
- return _value.alias->getDoubleValue();
- case BOOL:
- return double(get_bool());
- case INT:
- return double(get_int());
- case LONG:
- return double(get_long());
- case FLOAT:
- return double(get_float());
- case DOUBLE:
- return get_double();
- case STRING:
- case UNSPECIFIED:
- return strtod(get_string(), 0);
- case NONE:
- default:
- return SGRawValue<double>::DefaultValue;
- }
-}
-
const char *
SGPropertyNode::getStringValue () const
{
Only in SimGear-0.3.10.new/simgear/props: props.cxx~
diff -ur SimGear-0.3.10/simgear/props/props.hxx SimGear-0.3.10.new/simgear/props/props.hxx
--- SimGear-0.3.10/simgear/props/props.hxx 2006-03-15 16:15:39.000000000 +0100
+++ SimGear-0.3.10.new/simgear/props/props.hxx 2007-03-30 16:42:21.000000000 +0200
@@ -835,7 +835,40 @@
/**
* Get a double value for this node.
*/
- double getDoubleValue () const;
+ double getDoubleValue () const
+ {
+ // Shortcut for common case
+ if (_attr == (READ|WRITE) && _type == DOUBLE)
+ return get_double();
+
+ /* Commented to make getDoubleValue() independend if props.obj as
+ getDoubleValue() gets used by structure */
+ /* if (getAttribute(TRACE_READ))
+ trace_read(); */
+ if (!getAttribute(READ))
+ return 0.0L; /* SGRawValue<double>::DefaultValue */
+
+ switch (_type) {
+ case ALIAS:
+ return _value.alias->getDoubleValue();
+ case BOOL:
+ return double(get_bool());
+ case INT:
+ return double(get_int());
+ case LONG:
+ return double(get_long());
+ case FLOAT:
+ return double(get_float());
+ case DOUBLE:
+ return get_double();
+ case STRING:
+ case UNSPECIFIED:
+ return strtod(get_string(), 0);
+ case NONE:
+ default:
+ return 0.0L; /* SGRawValue<double>::DefaultValue */
+ }
+ }
/**
@@ -1149,12 +1182,54 @@
private:
// Get the raw value
- bool get_bool () const;
- int get_int () const;
- long get_long () const;
- float get_float () const;
- double get_double () const;
- const char * get_string () const;
+ inline bool get_bool () const
+ {
+ if (_tied)
+ return _value.bool_val->getValue();
+ else
+ return _local_val.bool_val;
+ }
+
+ inline int get_int () const
+ {
+ if (_tied)
+ return _value.int_val->getValue();
+ else
+ return _local_val.int_val;
+ }
+
+ inline long get_long () const
+ {
+ if (_tied)
+ return _value.long_val->getValue();
+ else
+ return _local_val.long_val;
+ }
+
+ inline float get_float () const
+ {
+ if (_tied)
+ return _value.float_val->getValue();
+ else
+ return _local_val.float_val;
+ }
+
+ inline double get_double () const
+ {
+ if (_tied)
+ return _value.double_val->getValue();
+ else
+ return _local_val.double_val;
+ }
+
+ inline const char * get_string () const
+ {
+ if (_tied)
+ return _value.string_val->getValue();
+ else
+ return _local_val.string_val;
+ }
+
// Set the raw value
bool set_bool (bool value);