diff options
Diffstat (limited to 'src/filesystem/inifile.cc')
-rw-r--r-- | src/filesystem/inifile.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc index 0cc690f..47baebf 100644 --- a/src/filesystem/inifile.cc +++ b/src/filesystem/inifile.cc @@ -187,6 +187,39 @@ bool IniFile::got_key_color(const char * keylabel, math::Color & color) { } } +bool IniFile::got_key_bool(const char * keylabel, bool & b) +{ + if (last_read_was_key && (key_current.compare(keylabel) == 0 )) { + std::istringstream is(value_current); + + unsigned int i; + if (is >> i) { + if (i) b = true; else b = false; + return true; + } + + std::string val(value_current); + aux::trim(val); + aux::lowercase(val); + + if (val.compare("yes") == 0) { + b = true; + return true; + } else if (val.compare("true") == 0) { + b = true; + return true; + } else if (val.compare("no") == 0) { + b = false; + return true; + } else if (val.compare("false") == 0) { + b = false; + return true; + } + } + + return false; +} + void IniFile::close() { inifile_ifs.close(); |