diff --git a/src/kiwano/utils/ConfigIni.cpp b/src/kiwano/utils/ConfigIni.cpp index 8af2a499..1b70c758 100644 --- a/src/kiwano/utils/ConfigIni.cpp +++ b/src/kiwano/utils/ConfigIni.cpp @@ -261,9 +261,9 @@ bool ConfigIni::GetBool(const String& section, const String& key, bool default_v String str = GetString(section, key); if (!str.empty()) { - if (str == "true") + if (str == "true" || str == "1") return true; - else if (str == "false") + else if (str == "false" || str == "0") return false; } return default_value; @@ -324,6 +324,24 @@ void ConfigIni::SetBool(const String& section, const String& key, bool value) SetString(section, key, value ? "true" : "false"); } +ConfigIni::ValueMap& ConfigIni::operator[](const String& section) +{ + if (!HasSection(section)) + { + sections_.insert(std::make_pair(section, ValueMap())); + } + return sections_[section]; +} + +const ConfigIni::ValueMap& ConfigIni::operator[](const String& section) const +{ + if (!HasSection(section)) + { + const_cast(sections_).insert(std::make_pair(section, ValueMap())); + } + return sections_.at(section); +} + void ConfigIni::ParseLine(StringView line, String* section) { line = Trim(line); diff --git a/src/kiwano/utils/ConfigIni.h b/src/kiwano/utils/ConfigIni.h index dac12b6c..e83434f2 100644 --- a/src/kiwano/utils/ConfigIni.h +++ b/src/kiwano/utils/ConfigIni.h @@ -165,15 +165,9 @@ public: /// @param value ֵ void SetBool(const String& section, const String& key, bool value); - inline ValueMap& operator[](const String& section) - { - return sections_[section]; - } + ValueMap& operator[](const String& section); - inline const ValueMap& operator[](const String& section) const - { - return sections_.at(section); - } + const ValueMap& operator[](const String& section) const; private: void ParseLine(StringView line, String* section);