simplify parsing of equilibrium data

This commit is contained in:
Axel Kohlmeyer 2020-05-29 08:21:45 -04:00
parent 7d62fd5106
commit 99c0c1ace1
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 5 additions and 6 deletions

View File

@ -210,14 +210,13 @@ void TestConfigReader::angle_coeff(const yaml_event_t & event) {
} }
void TestConfigReader::equilibrium(const yaml_event_t & event) { void TestConfigReader::equilibrium(const yaml_event_t & event) {
std::string vals = (char *)event.data.scalar.value; std::stringstream data((char *)event.data.scalar.value);
config.equilibrium.clear(); config.equilibrium.clear();
std::size_t found = vals.find_first_of(" \t"); double value;
while (found != std::string::npos) { while (1) {
double value = atof(vals.substr(0,found).c_str()); data >> value;
if (data.eof()) break;
config.equilibrium.push_back(value); config.equilibrium.push_back(value);
vals = vals.substr(found+1);
found = vals.find_first_of(" \t");
} }
} }