Synced with Jon's table parsing fixes.
This commit is contained in:
parent
cec011503c
commit
238df6975a
2 changed files with 36 additions and 25 deletions
|
@ -218,27 +218,10 @@ string FGConfigFile::GetLine(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cfgfile.eof()) return string("EOF");
|
if (cfgfile.eof() && scratch.empty()) return string("EOF");
|
||||||
return scratch;
|
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)
|
FGConfigFile& FGConfigFile::operator>>(double& val)
|
||||||
|
@ -252,7 +235,12 @@ FGConfigFile& FGConfigFile::operator>>(double& val)
|
||||||
string str = CurrentLine.substr(pos, end - pos);
|
string str = CurrentLine.substr(pos, end - pos);
|
||||||
val = strtod(str.c_str(),NULL);
|
val = strtod(str.c_str(),NULL);
|
||||||
CurrentIndex = end+1;
|
CurrentIndex = end+1;
|
||||||
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
if (end == pos) {
|
||||||
|
GetNextConfigLine();
|
||||||
|
*this >> val;
|
||||||
|
} else {
|
||||||
|
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +257,12 @@ FGConfigFile& FGConfigFile::operator>>(int& val)
|
||||||
string str = CurrentLine.substr(pos, end - pos);
|
string str = CurrentLine.substr(pos, end - pos);
|
||||||
val = atoi(str.c_str());
|
val = atoi(str.c_str());
|
||||||
CurrentIndex = end+1;
|
CurrentIndex = end+1;
|
||||||
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
if (end == pos) {
|
||||||
|
GetNextConfigLine();
|
||||||
|
*this >> val;
|
||||||
|
} else {
|
||||||
|
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +279,12 @@ FGConfigFile& FGConfigFile::operator>>(eParam& val)
|
||||||
string str = CurrentLine.substr(pos, end - pos);
|
string str = CurrentLine.substr(pos, end - pos);
|
||||||
val = (eParam)atoi(str.c_str());
|
val = (eParam)atoi(str.c_str());
|
||||||
CurrentIndex = end+1;
|
CurrentIndex = end+1;
|
||||||
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
if (end == pos) {
|
||||||
|
GetNextConfigLine();
|
||||||
|
*this >> val;
|
||||||
|
} else {
|
||||||
|
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +300,12 @@ FGConfigFile& FGConfigFile::operator>>(string& str)
|
||||||
if (end == CurrentLine.npos) end = CurrentLine.length();
|
if (end == CurrentLine.npos) end = CurrentLine.length();
|
||||||
str = CurrentLine.substr(pos, end - pos);
|
str = CurrentLine.substr(pos, end - pos);
|
||||||
CurrentIndex = end+1;
|
CurrentIndex = end+1;
|
||||||
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
if (end == pos) {
|
||||||
|
GetNextConfigLine();
|
||||||
|
*this >> str;
|
||||||
|
} else {
|
||||||
|
if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,17 @@ using namespace std;
|
||||||
|
|
||||||
FGTable::FGTable(int NRows, int NCols) : nRows(NRows), nCols(NCols)
|
FGTable::FGTable(int NRows, int NCols) : nRows(NRows), nCols(NCols)
|
||||||
{
|
{
|
||||||
Type = tt2D;
|
if (NCols > 1) {
|
||||||
colCounter = 1;
|
Type = tt2D;
|
||||||
rowCounter = 0;
|
colCounter = 1;
|
||||||
|
rowCounter = 0;
|
||||||
|
} else if (NCols == 1) {
|
||||||
|
Type = tt1D;
|
||||||
|
colCounter = 0;
|
||||||
|
rowCounter = 1;
|
||||||
|
} else {
|
||||||
|
cerr << "FGTable cannot accept 'Rows=0'" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
Data = Allocate();
|
Data = Allocate();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue