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);
|
String str = GetString(section, key);
|
||||||
if (!str.empty())
|
if (!str.empty())
|
||||||
{
|
{
|
||||||
if (str == "true")
|
if (str == "true" || str == "1")
|
||||||
return true;
|
return true;
|
||||||
else if (str == "false")
|
else if (str == "false" || str == "0")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return default_value;
|
return default_value;
|
||||||
|
|
@ -324,6 +324,24 @@ void ConfigIni::SetBool(const String& section, const String& key, bool value)
|
||||||
SetString(section, key, value ? "true" : "false");
|
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)
|
void ConfigIni::ParseLine(StringView line, String* section)
|
||||||
{
|
{
|
||||||
line = Trim(line);
|
line = Trim(line);
|
||||||
|
|
|
||||||
|
|
@ -165,15 +165,9 @@ public:
|
||||||
/// @param value ֵ
|
/// @param value ֵ
|
||||||
void SetBool(const String& section, const String& key, bool value);
|
void SetBool(const String& section, const String& key, bool value);
|
||||||
|
|
||||||
inline ValueMap& operator[](const String& section)
|
ValueMap& operator[](const String& section);
|
||||||
{
|
|
||||||
return sections_[section];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ValueMap& operator[](const String& section) const
|
const ValueMap& operator[](const String& section) const;
|
||||||
{
|
|
||||||
return sections_.at(section);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseLine(StringView line, String* section);
|
void ParseLine(StringView line, String* section);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue