LibCore: read_bool_entry parse "true" / "false" strings in config files

`read_bool_entry()` can now interpret both integers (1 or 0) and
Boolean strings ("true" or "false") in configuration files.

All values other than "1" or "true" are considered false.
This commit is contained in:
Brendan Coles 2020-04-22 18:10:54 +00:00 committed by Andreas Kling
parent 7540203ae8
commit edd8abc4cf
Notes: sideshowbarker 2024-07-19 07:23:09 +09:00

View file

@ -138,7 +138,10 @@ int ConfigFile::read_num_entry(const String& group, const String& key, int defau
bool ConfigFile::read_bool_entry(const String& group, const String& key, bool default_value) const
{
return read_entry(group, key, default_value ? "1" : "0") == "1";
auto value = read_entry(group, key, default_value ? "1" : "0");
if (value == "1" || value.to_lowercase() == "true")
return 1;
return 0;
}
void ConfigFile::write_entry(const String& group, const String& key, const String& value)