AK: Make string-to-number conversion helpers return Optional

Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
This commit is contained in:
Andreas Kling 2020-06-12 21:07:52 +02:00
parent 15f4043a7a
commit fdfda6dec2
Notes: sideshowbarker 2024-07-19 05:41:49 +09:00
55 changed files with 354 additions and 455 deletions

View file

@ -129,11 +129,7 @@ int ConfigFile::read_num_entry(const String& group, const String& key, int defau
return default_value;
}
bool ok;
int value = read_entry(group, key).to_int(ok);
if (!ok)
return default_value;
return value;
return read_entry(group, key).to_int().value_or(default_value);
}
bool ConfigFile::read_bool_entry(const String& group, const String& key, bool default_value) const