]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGConfigFile.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGConfigFile.cpp
index 488ec0b616f175571e7bc8000c410ff6108c3382..f994aba06c8549061514569f5c20ade262c274b1 100644 (file)
@@ -21,6 +21,8 @@ INCLUDES
 #include <stdlib.h>
 #include <math.h>
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_CONFIGFILE;
 
@@ -30,7 +32,7 @@ CLASS IMPLEMENTATION
 
 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 );
@@ -38,7 +40,7 @@ FGConfigFile::FGConfigFile(string cfgFileName)
   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();
@@ -88,6 +90,9 @@ string FGConfigFile::GetNextConfigLine(void)
       comment_length = comment_ends_at + 2 - comment_starts_at + 1;
       LineComment = CurrentLine.substr(comment_starts_at+4, comment_length-4-3);
       CurrentLine.erase(comment_starts_at, comment_length);
+      if (CurrentLine.find_first_not_of(" ") == string::npos) {
+        CurrentLine.erase();
+      }
     } else if ( start_comment && !end_comment) {                       //  <!-- ...
       CommentsOn = true;
       comment_length = line_length - comment_starts_at;
@@ -108,11 +113,12 @@ string FGConfigFile::GetNextConfigLine(void)
       CommentString += CommentStringTemp + "\r\n";
       CurrentLine.erase(0, comment_length);
     }
-    
   } while (CommentsOn);
 
-  if (CurrentLine.length() == 0) GetNextConfigLine();
   CurrentIndex = 0;
+  if (CurrentLine.length() == 0) {
+    GetNextConfigLine();
+  }
   return CurrentLine;
 }
 
@@ -120,7 +126,7 @@ string FGConfigFile::GetNextConfigLine(void)
 
 string FGConfigFile::GetValue(string val)
 {
-  unsigned int pos, p1, p2, ptest;
+  string::size_type pos, p1, p2, ptest;
 
   if (val == "") {    // this call is to return the tag value
     pos = CurrentLine.find("<");
@@ -208,7 +214,7 @@ string FGConfigFile::GetLine(void)
       }
     } else {
       if ((test = cfgfile.get()) != EOF) { // get *next* character
-#if defined ( sgi ) && !defined( __GNUC__ )
+#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) || defined (_MSC_VER)
         if (test >= 0x20 || test == 0x09) cfgfile.putback(test);
 #else
         if (test >= 0x20 || test == 0x09) cfgfile.unget();
@@ -217,6 +223,12 @@ string FGConfigFile::GetLine(void)
       }
     }
   }
+
+  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;
 }
@@ -225,7 +237,7 @@ string FGConfigFile::GetLine(void)
 
 FGConfigFile& FGConfigFile::operator>>(double& val)
 {
-  unsigned int pos, end;
+  string::size_type pos, end;
 
   pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
   if (pos == CurrentLine.npos) pos = CurrentLine.length();
@@ -247,7 +259,7 @@ FGConfigFile& FGConfigFile::operator>>(double& val)
 
 FGConfigFile& FGConfigFile::operator>>(int& val)
 {
-  unsigned int pos, end;
+  string::size_type pos, end;
 
   pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
   if (pos == CurrentLine.npos) pos = CurrentLine.length();
@@ -267,31 +279,9 @@ FGConfigFile& FGConfigFile::operator>>(int& val)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGConfigFile& FGConfigFile::operator>>(eParam& val)
-{
-  unsigned int 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)
 {
-  unsigned int pos, end;
+  string::size_type pos, end;
 
   pos = CurrentLine.find_first_not_of(", ",CurrentIndex);
   if (pos == CurrentLine.npos) pos = CurrentLine.length();
@@ -357,4 +347,4 @@ void FGConfigFile::Debug(int from)
     }
   }
 }
-
+}