#include <stdlib.h>
#include <math.h>
+namespace JSBSim {
+
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_CONFIGFILE;
FGConfigFile::FGConfigFile(string cfgFileName)
{
-#if defined ( sgi ) && !defined( __GNUC__ )
+#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740)
cfgfile.open(cfgFileName.c_str(), ios::in );
#else
cfgfile.open(cfgFileName.c_str(), ios::in | ios::binary );
CommentsOn = false;
CurrentIndex = 0;
Opened = true;
-#if defined ( sgi ) && !defined( __GNUC__ )
+#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740)
if (!cfgfile.fail() && !cfgfile.eof()) GetNextConfigLine();
#else
if (cfgfile.is_open()) GetNextConfigLine();
}
} else {
if ((test = cfgfile.get()) != EOF) { // get *next* character
-#if defined ( sgi ) && !defined( __GNUC__ )
+#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740)
if (test >= 0x20 || test == 0x09) cfgfile.putback(test);
#else
if (test >= 0x20 || test == 0x09) cfgfile.unget();
}
}
}
+
+ int index = scratch.find_last_not_of(" ");
+ if (index != string::npos && index < (scratch.size()-1)) {
+ scratch = scratch.substr(0,index+1);
+ }
+
if (cfgfile.eof() && scratch.empty()) return string("EOF");
return scratch;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGConfigFile& FGConfigFile::operator>>(eParam& val)
-{
- string::size_type pos, end;
-
- pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
- if (pos == CurrentLine.npos) pos = CurrentLine.length();
- end = CurrentLine.find_first_of(", ",pos+1);
- if (end == CurrentLine.npos) end = CurrentLine.length();
- string str = CurrentLine.substr(pos, end - pos);
- val = (eParam)atoi(str.c_str());
- CurrentIndex = end+1;
- if (end == pos) {
- GetNextConfigLine();
- *this >> val;
- } else {
- if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
- }
- return *this;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
FGConfigFile& FGConfigFile::operator>>(string& str)
{
string::size_type pos, end;
}
}
}
-
+}