From a85c3ca1ff34775f2fc93013306dec21b34b0359 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 17 Sep 2010 23:05:58 +0000 Subject: Initial inventory loading, ships docking ships --- src/filesystem/inifile.cc | 21 +++++++++++++++++++++ src/filesystem/inifile.h | 8 ++++++++ 2 files changed, 29 insertions(+) (limited to 'src/filesystem') diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc index e9ab283..8cf186c 100644 --- a/src/filesystem/inifile.cc +++ b/src/filesystem/inifile.cc @@ -159,6 +159,17 @@ bool IniFile::got_key_string(const char * keylabel, std::string & valuestring) } } +bool IniFile::got_key_label(const char * keylabel, std::string & labelstring) +{ + if (last_read_was_key && (key_current.compare(keylabel) == 0)) { + labelstring.assign(value_current); + aux::to_label(labelstring); + return true; + } else { + return false; + } +} + bool IniFile::got_key_vector3f(const char * keylabel, math::Vector3f & v) { if (last_read_was_key && (key_current.compare(keylabel) == 0)) { @@ -298,6 +309,16 @@ void IniFile::unknown_section() const con_warn << name() << " unknown section '" << section() << "' at line " << line() << std::endl; } +void IniFile::unknown_error(const char *text) const +{ + con_warn << name() << " " << (text && text[0] ? text : "unknown error") << " at line " << line() << std::endl; +} + +void IniFile::unknown_error(const std::string &text) const +{ + con_warn << name() << " " << text << " at line " << line() << std::endl; +} + void IniFile::close() { inifile_stream.close(); diff --git a/src/filesystem/inifile.h b/src/filesystem/inifile.h index e5423aa..4b94dcd 100644 --- a/src/filesystem/inifile.h +++ b/src/filesystem/inifile.h @@ -72,6 +72,9 @@ public: /// check if the last read key=value pair matches keylabel and store the value in valuestring bool got_key_string(const char * keylabel, std::string & valuestring); + /// check if the last read key=value pair matches keylabel and store the value in valuestring, converted to label + bool got_key_label(const char * keylabel, std::string & labelstring); + bool got_key_color(const char * keylabel, math::Color & color); bool got_key_float(const char * keylabel, float & f); @@ -97,6 +100,11 @@ public: /// print a default unkown section error void unknown_section() const; + + /// print a generic error message + void unknown_error(const char *text = 0) const; + + void unknown_error(const std::string &text) const; /// return true of the ini file is open for reading inline bool is_open() { -- cgit v1.2.3