diff options
Diffstat (limited to 'src/cfgparser.h')
| -rw-r--r-- | src/cfgparser.h | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/cfgparser.h b/src/cfgparser.h index c7f0063..10bd1cd 100644 --- a/src/cfgparser.h +++ b/src/cfgparser.h @@ -18,6 +18,8 @@ extern "C" #include <MESA_prof_load.h> } +#include "util.h" + class TfeConfigParser { public: @@ -35,34 +37,6 @@ private: std::string str_cfgfile_; }; -struct tfe_expection_cfg_invalid_format : std::runtime_error -{ - explicit tfe_expection_cfg_invalid_format( - const std::string &file, - const std::string §ion, - const std::string &item, - const std::string &what) : file(file), section(section), item(item), runtime_error(what) - {} - - std::string file; - std::string section; - std::string item; -}; - -struct tfe_expection_cfg_lost_entry : std::runtime_error -{ - explicit tfe_expection_cfg_lost_entry( - const std::string &file, - const std::string §ion, - const std::string &item, - const std::string &what) : file(file), section(section), item(item), runtime_error(what) - {} - - std::string file; - std::string section; - std::string item; -}; - template<> std::string TfeConfigParser::GetValue(const std::string &str_section, const std::string &str_entry) { @@ -70,10 +44,10 @@ std::string TfeConfigParser::GetValue(const std::string &str_section, const std: memset(__str_buffer, 0, sizeof(__str_buffer)); int ret = MESA_load_profile_string_nodef(str_cfgfile_.c_str(), str_section.c_str(), str_entry.c_str(), - __str_buffer, sizeof(__str_buffer)); + __str_buffer, sizeof(__str_buffer)); if (ret < 0) - throw tfe_expection_cfg_lost_entry(str_cfgfile_, str_section, str_entry, ""); + throw cfg_lost_entry(str_cfgfile_, str_section, str_entry, ""); return std::string(__str_buffer); } @@ -87,8 +61,8 @@ unsigned long TfeConfigParser::GetValue(const std::string &str_section, const st unsigned long __value = strtoul(__str_value.c_str(), &__ptr, 0); if (__ptr == __str_value.c_str()) { - throw tfe_expection_cfg_invalid_format(str_cfgfile_, str_section, str_entry, - __str_value + " is not valid unsigned number. "); + throw cfg_invalid_format(str_cfgfile_, str_section, str_entry, + __str_value + " is not valid unsigned number. "); } return __value; |
