]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGConfigFile.cpp
Check return value of FDM::init().
[flightgear.git] / src / FDM / JSBSim / FGConfigFile.cpp
index ae020ec21dad6341d9833a91d14425d48f8ea325..28432622762fda79e75e0a0992fd71e66513cc82 100644 (file)
@@ -21,6 +21,9 @@ INCLUDES
 #include <stdlib.h>
 #include <math.h>
 
+static const char *IdSrc = "$Header$";
+static const char *IdHdr = "ID_CONFIGFILE";
+
 /*******************************************************************************
 ************************************ CODE **************************************
 *******************************************************************************/
@@ -171,10 +174,7 @@ FGConfigFile& FGConfigFile::operator>>(double& val)
   string str = CurrentLine.substr(pos, end - pos);
   val = strtod(str.c_str(),NULL);
   CurrentIndex = end+1;
-  // EXPERIMENTAL
-  if (CurrentIndex >= CurrentLine.length())
-    GetNextConfigLine();
-  // END EXPERIMENTAL
+  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
   return *this;
 }
 
@@ -189,10 +189,7 @@ FGConfigFile& FGConfigFile::operator>>(float& val)
   string str = CurrentLine.substr(pos, end - pos);
   val = strtod(str.c_str(),NULL);
   CurrentIndex = end+1;
-  // EXPERIMENTAL
-  if (CurrentIndex >= CurrentLine.length())
-    GetNextConfigLine();
-  // END EXPERIMENTAL
+  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
   return *this;
 }
 
@@ -207,10 +204,22 @@ FGConfigFile& FGConfigFile::operator>>(int& val)
   string str = CurrentLine.substr(pos, end - pos);
   val = atoi(str.c_str());
   CurrentIndex = end+1;
-  // EXPERIMENTAL
-  if (CurrentIndex >= CurrentLine.length())
-    GetNextConfigLine();
-  // END EXPERIMENTAL
+  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  return *this;
+}
+
+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 (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
   return *this;
 }
 
@@ -224,10 +233,7 @@ FGConfigFile& FGConfigFile::operator>>(string& str)
   if (end == CurrentLine.npos) end = CurrentLine.length();
   str = CurrentLine.substr(pos, end - pos);
   CurrentIndex = end+1;
-  // EXPERIMENTAL
-  if (CurrentIndex >= CurrentLine.length())
-    GetNextConfigLine();
-  // END EXPERIMENTAL
+  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
   return *this;
 }