0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 08:24:08 +01:00

ircd::conf: Add templates for long integer items.

This commit is contained in:
Jason Volk 2018-03-02 23:54:35 -08:00
parent 1736a47068
commit 304f5422c6

View file

@ -17,6 +17,8 @@ namespace ircd::conf
template<class T> struct value; // abstraction for carrying item value
template<> struct item<void>; // base class of all conf items
template<> struct item<std::string>;
template<> struct item<uint64_t>;
template<> struct item<int64_t>;
template<> struct item<seconds>;
IRCD_EXCEPTION(ircd::error, error)
@ -99,6 +101,50 @@ struct ircd::conf::item<std::string>
{}
};
template<>
struct ircd::conf::item<uint64_t>
:conf::item<>
,conf::value<uint64_t>
{
string_view get(const mutable_buffer &out) const override
{
return lex_cast(_value, out);
}
bool set(const string_view &s) override
{
_value = lex_cast<uint64_t>(s);
return true;
}
item(const json::members &memb)
:conf::item<>{memb}
,value{feature.get("default", 0UL)}
{}
};
template<>
struct ircd::conf::item<int64_t>
:conf::item<>
,conf::value<int64_t>
{
string_view get(const mutable_buffer &out) const override
{
return lex_cast(_value, out);
}
bool set(const string_view &s) override
{
_value = lex_cast<int64_t>(s);
return true;
}
item(const json::members &memb)
:conf::item<>{memb}
,value{feature.get("default", 0L)}
{}
};
template<>
struct ircd::conf::item<ircd::seconds>
:conf::item<>