0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

ircd::json: Massage away json::value template ctor.

This commit is contained in:
Jason Volk 2018-02-09 20:09:37 -08:00
parent 063644feaa
commit 0bf053197c
4 changed files with 9 additions and 66 deletions

View file

@ -85,9 +85,11 @@ struct ircd::json::value
explicit operator int64_t() const;
explicit operator std::string() const; ///< NOTE full stringify() of value
template<class T> explicit value(const T &specialized);
value(const string_view &sv, const enum type &);
template<size_t N> value(const char (&)[N]);
explicit value(const int64_t &);
explicit value(const double &);
explicit value(const bool &);
value(const char *const &s);
value(const string_view &sv);
value(const struct member *const &, const size_t &len);
@ -117,20 +119,6 @@ struct ircd::json::value
friend std::ostream &operator<<(std::ostream &, const value &);
};
namespace ircd::json
{
template<> value::value(const double &floating);
template<> value::value(const uint64_t &integer);
template<> value::value(const int64_t &integer);
template<> value::value(const float &floating);
template<> value::value(const uint32_t &integer);
template<> value::value(const int32_t &integer);
template<> value::value(const uint16_t &integer);
template<> value::value(const int16_t &integer);
template<> value::value(const bool &boolean);
template<> value::value(const std::string &str);
}
static_assert(sizeof(ircd::json::value) == 16, "");
inline
@ -174,24 +162,11 @@ ircd::json::value::value(const char (&str)[N])
,floats{false}
{}
template<> inline
ircd::json::value::value(const std::string &str)
:value{string_view{str}}
{}
inline
ircd::json::value::value(const string_view &sv)
:value{sv, json::type(sv, std::nothrow)}
{}
template<class T>
ircd::json::value::value(const T &t)
:value{static_cast<string_view>(t)}
{
static_assert(std::is_base_of<ircd::string_view, T>() ||
std::is_convertible<ircd::string_view, T>(), "");
}
inline
ircd::json::value::value(const nullptr_t &)
:value
@ -199,7 +174,7 @@ ircd::json::value::value(const nullptr_t &)
literal_null, type::LITERAL
}{}
template<> inline
inline
ircd::json::value::value(const bool &boolean)
:value
{
@ -255,7 +230,7 @@ ircd::json::value::value(std::unique_ptr<const struct member[]> object,
object.release();
}
template<> inline
inline
ircd::json::value::value(const int64_t &integer)
:integer{integer}
,len{0}
@ -265,7 +240,7 @@ ircd::json::value::value(const int64_t &integer)
,floats{false}
{}
template<> inline
inline
ircd::json::value::value(const double &floating)
:floating{floating}
,len{0}
@ -275,38 +250,6 @@ ircd::json::value::value(const double &floating)
,floats{true}
{}
template<>
__attribute__((warning("uint64_t narrows to int64_t when used in json::value")))
inline
ircd::json::value::value(const uint64_t &integer)
:value{int64_t(integer)}
{}
template<> inline
ircd::json::value::value(const float &floating)
:value{double(floating)}
{}
template<> inline
ircd::json::value::value(const int32_t &integer)
:value{int64_t(integer)}
{}
template<> inline
ircd::json::value::value(const uint32_t &integer)
:value{int64_t(integer)}
{}
template<> inline
ircd::json::value::value(const int16_t &integer)
:value{int64_t(integer)}
{}
template<> inline
ircd::json::value::value(const uint16_t &integer)
:value{int64_t(integer)}
{}
inline
ircd::json::value::value(value &&other)
noexcept

View file

@ -178,7 +178,7 @@ ircd::m::init_listener(const json::object &conf,
{
{ "name", name },
{ "host", host },
{ "port", opts.get("port", 8448) },
{ "port", opts.get("port", 8448L) },
{ "ssl_certificate_file_pem", conf["tls_certificate_path"] },
{ "ssl_private_key_file_pem", conf["tls_private_key_path"] },
{ "ssl_tmp_dh_file", conf["tls_dh_params_path"] },

View file

@ -56,7 +56,7 @@ ircd::m::create(const id::room &room_id,
json::iov::set _set[]
{
{ event, { "depth", 1 }},
{ event, { "depth", 0L }},
{ event, { "type", "m.room.create" }},
{ event, { "state_key", "" }},
};

View file

@ -107,7 +107,7 @@ void foop()
std::cout <<
test(json::strung(json::members
{
{ "one", 1 },
{ "one", 1L },
{ "two", "Two" }
}))
<< std::endl;