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:
@@ -51,54 +51,42 @@ PRResult PRDevice::LoadDefaultsFromYAML(const char *yamlFilePath)
|
|||||||
YAML::Node doc;
|
YAML::Node doc;
|
||||||
parser.GetNextDocument(doc);
|
parser.GetNextDocument(doc);
|
||||||
|
|
||||||
for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
|
try
|
||||||
std::string key;
|
{
|
||||||
it.first() >> key;
|
const YAML::Node& node = doc["PRGameName"];
|
||||||
DEBUG(PRLog("Parsing key %s...\n", key.c_str()));
|
std::string name; node >> name;
|
||||||
if (key.compare("PRGameName") == 0)
|
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;
|
std::string name;
|
||||||
it.second() >> name;
|
dictIt.first() >> key;
|
||||||
DEBUG(PRLog(" Machine name: %s\n", name.c_str()));
|
dictIt.second() >> name;
|
||||||
}
|
DEBUG(PRLog(" Switch: %s -> %s\n", key.c_str(), name.c_str()));
|
||||||
else if (key.compare("PRDriverGlobalConfig") == 0)
|
|
||||||
{
|
|
||||||
//const YAML::Node& dict = it.second();
|
|
||||||
}
|
|
||||||
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) {}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const YAML::Node& dict = doc["PRDrivers"];
|
||||||
|
for(YAML::Iterator dictIt = dict.begin(); dictIt != dict.end(); ++dictIt)
|
||||||
|
{
|
||||||
|
std::string key;
|
||||||
|
std::string name;
|
||||||
|
dictIt.first() >> key;
|
||||||
|
dictIt.second() >> name;
|
||||||
|
DEBUG(PRLog(" Driver: %s -> %s\n", key.c_str(), name.c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (YAML::KeyNotFound& ex) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (YAML::ParserException& ex)
|
catch (YAML::ParserException& ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user