update ConfigIni
This commit is contained in:
parent
f5c9e5e226
commit
bd8b328d01
|
|
@ -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<SectionMap&>(sections_).insert(std::make_pair(section, ValueMap()));
|
||||
}
|
||||
return sections_.at(section);
|
||||
}
|
||||
|
||||
void ConfigIni::ParseLine(StringView line, String* section)
|
||||
{
|
||||
line = Trim(line);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue