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

ircd::exception: Add hide_name construction overload to macro.

This commit is contained in:
Jason Volk 2019-08-26 11:00:14 -07:00
parent 6f60b9bed8
commit b95a7a8a9e
2 changed files with 41 additions and 20 deletions

View file

@ -89,9 +89,10 @@ struct ircd::exception
512UL 512UL
}; };
protected:
IRCD_OVERLOAD(generate_skip) IRCD_OVERLOAD(generate_skip)
IRCD_OVERLOAD(hide_name)
protected:
char buf[BUFSIZE]; char buf[BUFSIZE];
ssize_t generate(const char *const &name, const string_view &fmt, const va_rtti &ap) noexcept; ssize_t generate(const char *const &name, const string_view &fmt, const va_rtti &ap) noexcept;
@ -156,6 +157,20 @@ struct name \
:parent \ :parent \
{ \ { \
template<class... args> \ template<class... args> \
name(hide_name_t, const string_view &fmt, args&&... ap) noexcept \
:parent{generate_skip} \
{ \
generate(fmt, ircd::va_rtti{std::forward<args>(ap)...}); \
} \
\
template<class... args> \
name(hide_name_t, const string_view &fmt = " ") noexcept \
:parent{generate_skip} \
{ \
generate(fmt, ircd::va_rtti{}); \
} \
\
template<class... args> \
name(const string_view &fmt, args&&... ap) noexcept \ name(const string_view &fmt, args&&... ap) noexcept \
:parent{generate_skip} \ :parent{generate_skip} \
{ \ { \

View file

@ -1784,27 +1784,21 @@ ircd::string_view
ircd::json::stringify(mutable_buffer &buf, ircd::json::stringify(mutable_buffer &buf,
const iov &iov) const iov &iov)
{ {
const ctx::critical_assertion ca; static const auto addressof //TODO: XXX
thread_local const member *m[iov::max_size]; {
if(unlikely(size_t(iov.size()) > iov.max_size)) [](const member &m) noexcept
throw iov::oversize
{ {
"IOV has %zd members but maximum is %zu", return std::addressof(m);
iov.size(), }
iov.max_size };
};
std::transform(std::begin(iov), std::end(iov), m, [] static const auto less_member
(const member &m)
{ {
return &m; [](const member *const &a, const member *const &b) noexcept
}); {
return *a < *b;
std::sort(m, m + iov.size(), [] }
(const member *const &a, const member *const &b) };
{
return *a < *b;
});
static const auto print_member static const auto print_member
{ {
@ -1815,7 +1809,19 @@ ircd::json::stringify(mutable_buffer &buf,
} }
}; };
char *const start{begin(buf)}; thread_local const member *m[iov::max_size];
const ctx::critical_assertion ca;
if(unlikely(size_t(iov.size()) > iov.max_size))
throw iov::oversize
{
"IOV has %zd members but maximum is %zu",
iov.size(),
iov.max_size
};
const auto start(begin(buf));
std::transform(std::begin(iov), std::end(iov), m, addressof);
std::sort(m, m + iov.size(), less_member);
printer(buf, printer.object_begin); printer(buf, printer.object_begin);
printer::list_protocol(buf, m, m + iov.size(), print_member); printer::list_protocol(buf, m, m + iov.size(), print_member);
printer(buf, printer.object_end); printer(buf, printer.object_end);