1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-24 18:25:23 +01:00

Changed PRLoadConfigFromYAML() to use much clearer style.

This commit is contained in:
Adam Preble
2009-05-22 12:41:10 -04:00
parent 8b0eeecee3
commit 5f934a58f7

View File

@@ -51,54 +51,42 @@ PRResult PRDevice::LoadDefaultsFromYAML(const char *yamlFilePath)
YAML::Node doc;
parser.GetNextDocument(doc);
for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
std::string key;
it.first() >> key;
DEBUG(PRLog("Parsing key %s...\n", key.c_str()));
if (key.compare("PRGameName") == 0)
try
{
const YAML::Node& node = doc["PRGameName"];
std::string name; node >> name;
DEBUG(PRLog(" Game Name: %s\n", name.c_str()));
}
catch (YAML::KeyNotFound& ex) {}
try
{
const YAML::Node& dict = doc["PRSwitches"];
for(YAML::Iterator dictIt = dict.begin(); dictIt != dict.end(); ++dictIt)
{
std::string key;
std::string name;
it.second() >> name;
DEBUG(PRLog(" Machine name: %s\n", name.c_str()));
dictIt.first() >> key;
dictIt.second() >> name;
DEBUG(PRLog(" Switch: %s -> %s\n", key.c_str(), name.c_str()));
}
else if (key.compare("PRDriverGlobalConfig") == 0)
}
catch (YAML::KeyNotFound& ex) {}
try
{
const YAML::Node& dict = doc["PRDrivers"];
for(YAML::Iterator dictIt = dict.begin(); dictIt != dict.end(); ++dictIt)
{
//const YAML::Node& dict = it.second();
std::string key;
std::string name;
dictIt.first() >> key;
dictIt.second() >> name;
DEBUG(PRLog(" Driver: %s -> %s\n", key.c_str(), name.c_str()));
}
else if (key.compare("PRDriverGroupConfigs") == 0)
{
const YAML::Node& groups = it.second();
for(YAML::Iterator it=groups.begin();it!=groups.end();++it)
{
std::string key;
it.first() >> key;
}
}
else if (key.compare("PRDrivers") == 0)
{
const YAML::Node& dict = it.second();
for(YAML::Iterator dictIt=dict.begin(); dictIt != dict.end(); ++dictIt)
{
std::string driverKey;
std::string driverName;
dictIt.first() >> driverKey;
dictIt.second() >> driverName;
DEBUG(PRLog(" Driver: %s -> %s\n", driverKey.c_str(), driverName.c_str()));
}
}
else if (key.compare("PRSwitches") == 0)
{
const YAML::Node& dict = it.second();
for(YAML::Iterator dictIt=dict.begin(); dictIt != dict.end(); ++dictIt)
{
std::string driverKey;
std::string driverName;
dictIt.first() >> driverKey;
dictIt.second() >> driverName;
DEBUG(PRLog(" Switch: %s -> %s\n", driverKey.c_str(), driverName.c_str()));
}
}
}
}
catch (YAML::KeyNotFound& ex) {}
}
}
catch (YAML::ParserException& ex)