From 6c1d31fefe6af013a8ad80b8eb1d71ff8b6c5a21 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Mon, 19 Dec 2022 18:52:55 +0000 Subject: [PATCH] remove ini config parsing --- src/OIUtils.cpp | 51 +++---------------------------------------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/src/OIUtils.cpp b/src/OIUtils.cpp index 5bd0e54..cc49ed8 100644 --- a/src/OIUtils.cpp +++ b/src/OIUtils.cpp @@ -28,9 +28,9 @@ namespace OIUtils { using namespace std::literals; -bool processConfigFileToml(const std::string& configFilePath, - OICompiler::Config& compilerConfig, - OICodeGen::Config& generatorConfig) { +bool processConfigFile(const std::string& configFilePath, + OICompiler::Config& compilerConfig, + OICodeGen::Config& generatorConfig) { toml::table config; try { config = toml::parse_file(configFilePath); @@ -109,49 +109,4 @@ bool processConfigFileToml(const std::string& configFilePath, 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("headers.userPath", ""); - boost::split(compilerConfig.userHeaderPaths, userHeaderPaths, - boost::is_any_of(":")); - - auto systemHeaderPaths = pt.get("headers.systemPath", ""); - boost::split(compilerConfig.sysHeaderPaths, systemHeaderPaths, - boost::is_any_of(":")); - - std::string configHeaders = pt.get("codegen.defaultHeaders", ""); - boost::algorithm::split(generatorConfig.defaultHeaders, configHeaders, - boost::algorithm::is_any_of(":")); - generatorConfig.defaultHeaders.erase(""); - - std::string configNamespaces = - pt.get("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