mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
remove ini config parsing
This commit is contained in:
parent
420743097d
commit
6c1d31fefe
@ -28,9 +28,9 @@ namespace OIUtils {
|
|||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
bool processConfigFileToml(const std::string& configFilePath,
|
bool processConfigFile(const std::string& configFilePath,
|
||||||
OICompiler::Config& compilerConfig,
|
OICompiler::Config& compilerConfig,
|
||||||
OICodeGen::Config& generatorConfig) {
|
OICodeGen::Config& generatorConfig) {
|
||||||
toml::table config;
|
toml::table config;
|
||||||
try {
|
try {
|
||||||
config = toml::parse_file(configFilePath);
|
config = toml::parse_file(configFilePath);
|
||||||
@ -109,49 +109,4 @@ bool processConfigFileToml(const std::string& configFilePath,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool processConfigFileIni(const std::string& configFilePath,
|
|
||||||
OICompiler::Config& compilerConfig,
|
|
||||||
OICodeGen::Config& generatorConfig) {
|
|
||||||
boost::property_tree::ptree pt;
|
|
||||||
|
|
||||||
try {
|
|
||||||
boost::property_tree::ini_parser::read_ini(configFilePath, pt);
|
|
||||||
} catch (const boost::property_tree::ini_parser_error& ex) {
|
|
||||||
LOG(ERROR) << "processConfigFileIni: " << configFilePath << " : "
|
|
||||||
<< ex.message();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX Obviously we don't require the fields so handle non-existent entries
|
|
||||||
auto userHeaderPaths = pt.get<std::string>("headers.userPath", "");
|
|
||||||
boost::split(compilerConfig.userHeaderPaths, userHeaderPaths,
|
|
||||||
boost::is_any_of(":"));
|
|
||||||
|
|
||||||
auto systemHeaderPaths = pt.get<std::string>("headers.systemPath", "");
|
|
||||||
boost::split(compilerConfig.sysHeaderPaths, systemHeaderPaths,
|
|
||||||
boost::is_any_of(":"));
|
|
||||||
|
|
||||||
std::string configHeaders = pt.get<std::string>("codegen.defaultHeaders", "");
|
|
||||||
boost::algorithm::split(generatorConfig.defaultHeaders, configHeaders,
|
|
||||||
boost::algorithm::is_any_of(":"));
|
|
||||||
generatorConfig.defaultHeaders.erase("");
|
|
||||||
|
|
||||||
std::string configNamespaces =
|
|
||||||
pt.get<std::string>("codegen.defaultNamespaces", "");
|
|
||||||
boost::algorithm::split(generatorConfig.defaultNamespaces, configNamespaces,
|
|
||||||
boost::algorithm::is_any_of("+"));
|
|
||||||
generatorConfig.defaultNamespaces.erase("");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool processConfigFile(const std::string& configFilePath,
|
|
||||||
OICompiler::Config& compilerConfig,
|
|
||||||
OICodeGen::Config& generatorConfig) {
|
|
||||||
// TODO: remove the option to parse as INI entirely
|
|
||||||
return processConfigFileToml(configFilePath, compilerConfig,
|
|
||||||
generatorConfig) ||
|
|
||||||
processConfigFileIni(configFilePath, compilerConfig, generatorConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace OIUtils
|
} // namespace OIUtils
|
||||||
|
Loading…
Reference in New Issue
Block a user