From d389a31f9816b55d8c7685ec24b9ab814252d693 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 28 Jul 2008 19:37:31 +0000 Subject: zone support --- src/filesystem/inifile.cc | 33 +++++++++++++++++++++++++++++++++ src/filesystem/inifile.h | 2 ++ 2 files changed, 35 insertions(+) (limited to 'src/filesystem') 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; -- cgit v1.2.3