diff options
Diffstat (limited to 'src/filesystem')
-rw-r--r-- | src/filesystem/inifile.cc | 33 | ||||
-rw-r--r-- | src/filesystem/inifile.h | 2 |
2 files changed, 35 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(); diff --git a/src/filesystem/inifile.h b/src/filesystem/inifile.h index f5c903d..3efcfc4 100644 --- a/src/filesystem/inifile.h +++ b/src/filesystem/inifile.h @@ -73,6 +73,8 @@ public: bool got_key_vector3f(const char * keylabel, math::Vector3f & v); + bool got_key_bool(const char * keylabel, bool & b); + inline unsigned int line() const { return line_number; |