X-Git-Url: https://git.stg.codes/ssmd.git/blobdiff_plain/ae26516a8828d54ab7c0e0bca92031a54a15ed62..HEAD:/src/settingsfileparser.cpp diff --git a/src/settingsfileparser.cpp b/src/settingsfileparser.cpp index 64f0d0b..0066269 100644 --- a/src/settingsfileparser.cpp +++ b/src/settingsfileparser.cpp @@ -16,7 +16,7 @@ typedef std::map PairsType; typedef std::map SectionsType; template -struct IniGrammar +struct IniGrammar : qi::grammar { IniGrammar() @@ -42,12 +42,6 @@ struct IniGrammar qi::rule comment, space, eol; }; -inline -bool sectionExists(const SectionsType & data, const std::string & sectionName) throw() -{ - return data.find(sectionName) != data.end(); -} - inline bool fieldExists(const SectionsType & data, const std::string & sectionName, const std::string & fieldName) throw() { @@ -72,14 +66,13 @@ bool fieldValue(const SectionsType & data, const std::string & sectionName, cons } -using GTS::SettingsParser; +using SSMD::SettingsParser; void SettingsParser::parseFile(const std::string & fileName) { std::ifstream in(fileName.c_str()); - if (!in) { + if (!in) throw std::runtime_error("Can't open file"); - } std::string text; while(!in.eof()) { @@ -101,25 +94,23 @@ void SettingsParser::parseFile(const std::string & fileName) std::string res; _settings._isDaemon = fieldExists(data, "general", "daemon"); _settings._isDebug = fieldExists(data, "general", "debug"); - if (fieldValue(data, "general", "log_file", res)){ + if (fieldValue(data, "general", "log_file", res)) _settings._logFile = res; - } - if (fieldValue(data, "general", "pid_file", res)){ + if (fieldValue(data, "general", "pid_file", res)) _settings._PIDFile = res; - } - if (fieldValue(data, "sync", "switch_interval", res)){ + if (fieldValue(data, "sync", "switch_interval", res)) _settings._switchSyncInterval = boost::lexical_cast(res); - } - if (fieldValue(data, "sync", "info_interval", res)){ + if (fieldValue(data, "sync", "info_interval", res)) _settings._infoSyncInterval = boost::lexical_cast(res); - } - if (fieldValue(data, "sync", "up_profile_id", res)){ + if (fieldValue(data, "sync", "up_profile_id", res)) _settings._upProfileId = boost::lexical_cast(res); - } - if (fieldValue(data, "sync", "down_profile_id", res)){ + if (fieldValue(data, "sync", "down_profile_id", res)) _settings._downProfileId = boost::lexical_cast(res); - } - if (fieldValue(data, "sync", "data_url", res)){ + if (fieldValue(data, "sync", "max_acl_per_pdu", res)) + _settings._maxACLPerPDU = boost::lexical_cast(res); + if (fieldValue(data, "sync", "data_url", res)) _settings._dataURL = res; - } + if (fieldValue(data, "sync", "script_base", res)) + _settings._scriptBase = res; + _settings._dumpScripts = fieldExists(data, "sync", "dump_scripts"); }