mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +01:00
ircd::conf: Restructure virtuals to direct all entry through parent.
This commit is contained in:
parent
b964f9520f
commit
63aa8e310e
2 changed files with 37 additions and 14 deletions
|
@ -60,8 +60,13 @@ struct ircd::conf::item<void>
|
|||
json::object feature;
|
||||
string_view name;
|
||||
|
||||
virtual string_view get(const mutable_buffer &) const;
|
||||
virtual bool set(const string_view &);
|
||||
protected:
|
||||
virtual string_view on_get(const mutable_buffer &) const;
|
||||
virtual bool on_set(const string_view &);
|
||||
|
||||
public:
|
||||
string_view get(const mutable_buffer &) const;
|
||||
bool set(const string_view &);
|
||||
|
||||
item(const json::members &);
|
||||
item(item &&) = delete;
|
||||
|
@ -95,12 +100,12 @@ struct ircd::conf::lex_castable
|
|||
:conf::item<>
|
||||
,conf::value<T>
|
||||
{
|
||||
string_view get(const mutable_buffer &out) const override
|
||||
string_view on_get(const mutable_buffer &out) const override
|
||||
{
|
||||
return lex_cast(this->_value, out);
|
||||
}
|
||||
|
||||
bool set(const string_view &s) override
|
||||
bool on_set(const string_view &s) override
|
||||
{
|
||||
this->_value = lex_cast<T>(s);
|
||||
return true;
|
||||
|
@ -122,8 +127,8 @@ struct ircd::conf::item<std::string>
|
|||
return _value;
|
||||
}
|
||||
|
||||
string_view get(const mutable_buffer &out) const override;
|
||||
bool set(const string_view &s) override;
|
||||
string_view on_get(const mutable_buffer &out) const override;
|
||||
bool on_set(const string_view &s) override;
|
||||
|
||||
item(const json::members &members);
|
||||
};
|
||||
|
@ -133,8 +138,8 @@ struct ircd::conf::item<bool>
|
|||
:conf::item<>
|
||||
,conf::value<bool>
|
||||
{
|
||||
string_view get(const mutable_buffer &out) const override;
|
||||
bool set(const string_view &s) override;
|
||||
string_view on_get(const mutable_buffer &out) const override;
|
||||
bool on_set(const string_view &s) override;
|
||||
|
||||
item(const json::members &members);
|
||||
};
|
||||
|
|
30
ircd/conf.cc
30
ircd/conf.cc
|
@ -113,13 +113,31 @@ noexcept
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::conf::item<void>::set(const string_view &)
|
||||
ircd::conf::item<void>::set(const string_view &val)
|
||||
{
|
||||
const bool ret
|
||||
{
|
||||
on_set(val)
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::conf::item<void>::get(const mutable_buffer &buf)
|
||||
const
|
||||
{
|
||||
return on_get(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::conf::item<void>::on_set(const string_view &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::conf::item<void>::get(const mutable_buffer &)
|
||||
ircd::conf::item<void>::on_get(const mutable_buffer &)
|
||||
const
|
||||
{
|
||||
return {};
|
||||
|
@ -140,14 +158,14 @@ ircd::conf::item<std::string>::item(const json::members &members)
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::conf::item<std::string>::set(const string_view &s)
|
||||
ircd::conf::item<std::string>::on_set(const string_view &s)
|
||||
{
|
||||
_value = std::string{s};
|
||||
return true;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::conf::item<std::string>::get(const mutable_buffer &out)
|
||||
ircd::conf::item<std::string>::on_get(const mutable_buffer &out)
|
||||
const
|
||||
{
|
||||
return { data(out), _value.copy(data(out), size(out)) };
|
||||
|
@ -164,7 +182,7 @@ ircd::conf::item<bool>::item(const json::members &members)
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::conf::item<bool>::set(const string_view &s)
|
||||
ircd::conf::item<bool>::on_set(const string_view &s)
|
||||
{
|
||||
switch(hash(s))
|
||||
{
|
||||
|
@ -184,7 +202,7 @@ ircd::conf::item<bool>::set(const string_view &s)
|
|||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::conf::item<bool>::get(const mutable_buffer &out)
|
||||
ircd::conf::item<bool>::on_get(const mutable_buffer &out)
|
||||
const
|
||||
{
|
||||
return _value?
|
||||
|
|
Loading…
Reference in a new issue