]> git.mxchange.org Git - flightgear.git/commitdiff
Synced with Jon's table parsing fixes.
authorcurt <curt>
Tue, 4 Dec 2001 13:59:38 +0000 (13:59 +0000)
committercurt <curt>
Tue, 4 Dec 2001 13:59:38 +0000 (13:59 +0000)
src/FDM/JSBSim/FGConfigFile.cpp
src/FDM/JSBSim/FGTable.cpp

index 13948a8f88cd03553c8634cc773fe6a4bd70f3e3..4816cb2917b21edb42ee2f2e9a764a15bf6596f6 100644 (file)
@@ -218,27 +218,10 @@ string FGConfigFile::GetLine(void)
       }
     }
   }
-  if (cfgfile.eof()) return string("EOF");
+  if (cfgfile.eof() && scratch.empty()) return string("EOF");
   return scratch;
 }
 
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-/*
-FGConfigFile& FGConfigFile::operator>>(double& 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 = strtod(str.c_str(),NULL);
-  CurrentIndex = end+1;
-  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
-  return *this;
-}
-*/
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 FGConfigFile& FGConfigFile::operator>>(double& val)
@@ -252,7 +235,12 @@ FGConfigFile& FGConfigFile::operator>>(double& val)
   string str = CurrentLine.substr(pos, end - pos);
   val = strtod(str.c_str(),NULL);
   CurrentIndex = end+1;
-  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  if (end == pos) {
+    GetNextConfigLine();
+    *this >> val;
+  } else {
+    if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  }
   return *this;
 }
 
@@ -269,7 +257,12 @@ FGConfigFile& FGConfigFile::operator>>(int& val)
   string str = CurrentLine.substr(pos, end - pos);
   val = atoi(str.c_str());
   CurrentIndex = end+1;
-  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  if (end == pos) {
+    GetNextConfigLine();
+    *this >> val;
+  } else {
+    if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  }
   return *this;
 }
 
@@ -286,7 +279,12 @@ FGConfigFile& FGConfigFile::operator>>(eParam& val)
   string str = CurrentLine.substr(pos, end - pos);
   val = (eParam)atoi(str.c_str());
   CurrentIndex = end+1;
-  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  if (end == pos) {
+    GetNextConfigLine();
+    *this >> val;
+  } else {
+    if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  }
   return *this;
 }
 
@@ -302,7 +300,12 @@ FGConfigFile& FGConfigFile::operator>>(string& str)
   if (end == CurrentLine.npos) end = CurrentLine.length();
   str = CurrentLine.substr(pos, end - pos);
   CurrentIndex = end+1;
-  if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  if (end == pos) {
+    GetNextConfigLine();
+    *this >> str;
+  } else {
+    if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
+  }
   return *this;
 }
 
index 450fcd2919c59670713e721dbfe90a6795fdd279..58e7e688b2f940846da2d62e275648aafdfddb76 100644 (file)
@@ -55,9 +55,17 @@ using namespace std;
 
 FGTable::FGTable(int NRows, int NCols) : nRows(NRows), nCols(NCols)
 {
-  Type = tt2D;
-  colCounter = 1;
-  rowCounter = 0;
+  if (NCols > 1) {
+    Type = tt2D;
+    colCounter = 1;
+    rowCounter = 0;
+  } else if (NCols == 1) {
+    Type = tt1D;
+    colCounter = 0;
+    rowCounter = 1;
+  } else {
+    cerr << "FGTable cannot accept 'Rows=0'" << endl;
+  }
 
   Data = Allocate();