diff --git a/include/ircd/conf.h b/include/ircd/conf.h index bfe64c9c5..da6594b3b 100644 --- a/include/ircd/conf.h +++ b/include/ircd/conf.h @@ -14,12 +14,17 @@ namespace ircd::conf { template struct item; // doesn't exist - template struct value; // abstraction for carrying item value template<> struct item; // base class of all conf items template<> struct item; template<> struct item; template<> struct item; + template<> struct item; template<> struct item; + template<> struct item; + template<> struct item; + + template struct value; // abstraction for carrying item value + template struct lex_castable; // abstraction for lex_cast compatible IRCD_EXCEPTION(ircd::error, error) IRCD_EXCEPTION(error, not_found) @@ -70,7 +75,29 @@ struct ircd::conf::value template value(A&&... a) - :_value{std::forward(a)...} + :_value(std::forward(a)...) + {} +}; + +template +struct ircd::conf::lex_castable +:conf::item<> +,conf::value +{ + string_view get(const mutable_buffer &out) const override + { + return lex_cast(this->_value, out); + } + + bool set(const string_view &s) override + { + this->_value = lex_cast(s); + return true; + } + + lex_castable(const json::members &members) + :conf::item<>{members} + ,conf::value(feature.get("default", long(0))) {} }; @@ -95,74 +122,50 @@ struct ircd::conf::item return true; } - item(const json::members &memb) - :conf::item<>{memb} + item(const json::members &members) + :conf::item<>{members} ,value{unquote(feature.get("default"))} {} }; template<> struct ircd::conf::item -:conf::item<> -,conf::value +:lex_castable { - string_view get(const mutable_buffer &out) const override - { - return lex_cast(_value, out); - } - - bool set(const string_view &s) override - { - _value = lex_cast(s); - return true; - } - - item(const json::members &memb) - :conf::item<>{memb} - ,value{feature.get("default", 0UL)} - {} + using lex_castable::lex_castable; }; template<> struct ircd::conf::item -:conf::item<> -,conf::value +:lex_castable { - string_view get(const mutable_buffer &out) const override - { - return lex_cast(_value, out); - } + using lex_castable::lex_castable; +}; - bool set(const string_view &s) override - { - _value = lex_cast(s); - return true; - } - - item(const json::members &memb) - :conf::item<>{memb} - ,value{feature.get("default", 0L)} - {} +template<> +struct ircd::conf::item +:lex_castable +{ + using lex_castable::lex_castable; }; template<> struct ircd::conf::item -:conf::item<> -,conf::value +:lex_castable { - string_view get(const mutable_buffer &out) const override - { - return lex_cast(_value, out); - } - - bool set(const string_view &s) override - { - _value = lex_cast(s); - return true; - } - - item(const json::members &memb) - :conf::item<>{memb} - ,value{feature.get("default", 0L)} - {} + using lex_castable::lex_castable; +}; + +template<> +struct ircd::conf::item +:lex_castable +{ + using lex_castable::lex_castable; +}; + +template<> +struct ircd::conf::item +:lex_castable +{ + using lex_castable::lex_castable; }; diff --git a/ircd/Makefile.am b/ircd/Makefile.am index 3c01fe4f1..ac97e8fb2 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -72,8 +72,9 @@ libircd_la_LIBADD = \ # the units that compile spirit grammars otherwise they thrash weaker # systems. libircd_la_SOURCES = \ - http.cc \ exception.cc \ + lexical.cc \ + json.cc \ locale.cc \ logger.cc \ info.cc \ @@ -82,7 +83,6 @@ libircd_la_SOURCES = \ rfc1459.cc \ rand.cc \ hash.cc \ - lexical.cc \ base.cc \ parse.cc \ openssl.cc \ @@ -95,7 +95,7 @@ libircd_la_SOURCES = \ fmt.cc \ db.cc \ net.cc \ - json.cc \ + http.cc \ server.cc \ client.cc \ resource.cc \