mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::conf: Deinline some specialized definitions.
This commit is contained in:
parent
3774b61cb8
commit
32549bc9ae
2 changed files with 73 additions and 43 deletions
|
@ -112,21 +112,10 @@ struct ircd::conf::item<std::string>
|
|||
return _value;
|
||||
}
|
||||
|
||||
string_view get(const mutable_buffer &out) const override
|
||||
{
|
||||
return { data(out), _value.copy(data(out), size(out)) };
|
||||
}
|
||||
string_view get(const mutable_buffer &out) const override;
|
||||
bool set(const string_view &s) override;
|
||||
|
||||
bool set(const string_view &s) override
|
||||
{
|
||||
_value = std::string{s};
|
||||
return true;
|
||||
}
|
||||
|
||||
item(const json::members &members)
|
||||
:conf::item<>{members}
|
||||
,value{unquote(feature.get("default"))}
|
||||
{}
|
||||
item(const json::members &members);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -134,36 +123,10 @@ struct ircd::conf::item<bool>
|
|||
:conf::item<>
|
||||
,conf::value<bool>
|
||||
{
|
||||
string_view get(const mutable_buffer &out) const override
|
||||
{
|
||||
return _value?
|
||||
strlcpy(out, "true"_sv):
|
||||
strlcpy(out, "false"_sv);
|
||||
}
|
||||
string_view get(const mutable_buffer &out) const override;
|
||||
bool set(const string_view &s) override;
|
||||
|
||||
bool set(const string_view &s) override
|
||||
{
|
||||
switch(hash(s))
|
||||
{
|
||||
case "true"_:
|
||||
_value = true;
|
||||
return true;
|
||||
|
||||
case "false"_:
|
||||
_value = false;
|
||||
return true;
|
||||
|
||||
default: throw bad_value
|
||||
{
|
||||
"Conf item '%s' not assigned a bool literal", name
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
item(const json::members &members)
|
||||
:conf::item<>{members}
|
||||
,value{feature.get<bool>("default", false)}
|
||||
{}
|
||||
item(const json::members &members);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
67
ircd/conf.cc
67
ircd/conf.cc
|
@ -194,3 +194,70 @@ catch(const std::exception &e)
|
|||
|
||||
throw;
|
||||
}
|
||||
|
||||
//
|
||||
// Non-inline template specialization definitions
|
||||
//
|
||||
|
||||
//
|
||||
// std::string
|
||||
//
|
||||
|
||||
ircd::conf::item<std::string>::item(const json::members &members)
|
||||
:conf::item<>{members}
|
||||
,value{unquote(feature.get("default"))}
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::conf::item<std::string>::set(const string_view &s)
|
||||
{
|
||||
_value = std::string{s};
|
||||
return true;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::conf::item<std::string>::get(const mutable_buffer &out)
|
||||
const
|
||||
{
|
||||
return { data(out), _value.copy(data(out), size(out)) };
|
||||
}
|
||||
|
||||
//
|
||||
// bool
|
||||
//
|
||||
|
||||
ircd::conf::item<bool>::item(const json::members &members)
|
||||
:conf::item<>{members}
|
||||
,value{feature.get<bool>("default", false)}
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::conf::item<bool>::set(const string_view &s)
|
||||
{
|
||||
switch(hash(s))
|
||||
{
|
||||
case "true"_:
|
||||
_value = true;
|
||||
return true;
|
||||
|
||||
case "false"_:
|
||||
_value = false;
|
||||
return true;
|
||||
|
||||
default: throw bad_value
|
||||
{
|
||||
"Conf item '%s' not assigned a bool literal", name
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::conf::item<bool>::get(const mutable_buffer &out)
|
||||
const
|
||||
{
|
||||
return _value?
|
||||
strlcpy(out, "true"_sv):
|
||||
strlcpy(out, "false"_sv);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue