1
0
Fork 0

Synced with Jon's table parsing fixes.

This commit is contained in:
curt 2001-12-04 13:59:38 +00:00
parent cec011503c
commit 238df6975a
2 changed files with 36 additions and 25 deletions

View 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;
}

View 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();