diff --git a/include/ircd/conf.h b/include/ircd/conf.h index 86f9919fa..4d1b85b76 100644 --- a/include/ircd/conf.h +++ b/include/ircd/conf.h @@ -112,21 +112,10 @@ struct ircd::conf::item 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 :conf::item<> ,conf::value { - 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("default", false)} - {} + item(const json::members &members); }; template<> diff --git a/ircd/conf.cc b/ircd/conf.cc index 41aec1c66..53e9e2f29 100644 --- a/ircd/conf.cc +++ b/ircd/conf.cc @@ -194,3 +194,70 @@ catch(const std::exception &e) throw; } + +// +// Non-inline template specialization definitions +// + +// +// std::string +// + +ircd::conf::item::item(const json::members &members) +:conf::item<>{members} +,value{unquote(feature.get("default"))} +{ +} + +bool +ircd::conf::item::set(const string_view &s) +{ + _value = std::string{s}; + return true; +} + +ircd::string_view +ircd::conf::item::get(const mutable_buffer &out) +const +{ + return { data(out), _value.copy(data(out), size(out)) }; +} + +// +// bool +// + +ircd::conf::item::item(const json::members &members) +:conf::item<>{members} +,value{feature.get("default", false)} +{ +} + +bool +ircd::conf::item::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::get(const mutable_buffer &out) +const +{ + return _value? + strlcpy(out, "true"_sv): + strlcpy(out, "false"_sv); +}