mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibConfig+LibCore+ConfigServer: Support u32 configuration entries
This commit is contained in:
parent
49f697ed56
commit
69beda23c3
10 changed files with 88 additions and 16 deletions
|
@ -42,13 +42,29 @@ public:
|
|||
size_t num_groups() const { return m_groups.size(); }
|
||||
|
||||
DeprecatedString read_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& default_value = DeprecatedString()) const;
|
||||
int read_num_entry(DeprecatedString const& group, DeprecatedString const& key, int default_value = 0) const;
|
||||
bool read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value = false) const;
|
||||
|
||||
template<Integral T = int>
|
||||
T read_num_entry(DeprecatedString const& group, DeprecatedString const& key, T default_value = 0) const
|
||||
{
|
||||
if (!has_key(group, key))
|
||||
return default_value;
|
||||
|
||||
if constexpr (IsSigned<T>)
|
||||
return read_entry(group, key).to_int<T>().value_or(default_value);
|
||||
else
|
||||
return read_entry(group, key).to_uint<T>().value_or(default_value);
|
||||
}
|
||||
|
||||
void write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value);
|
||||
void write_num_entry(DeprecatedString const& group, DeprecatedString const& key, int value);
|
||||
void write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value);
|
||||
|
||||
template<Integral T = int>
|
||||
void write_num_entry(DeprecatedString const& group, DeprecatedString const& key, T value)
|
||||
{
|
||||
write_entry(group, key, DeprecatedString::number(value));
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
|
||||
bool is_dirty() const { return m_dirty; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue