mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::exception: Add hide_name construction overload to macro.
This commit is contained in:
parent
6f60b9bed8
commit
b95a7a8a9e
2 changed files with 41 additions and 20 deletions
|
@ -89,9 +89,10 @@ struct ircd::exception
|
|||
512UL
|
||||
};
|
||||
|
||||
protected:
|
||||
IRCD_OVERLOAD(generate_skip)
|
||||
IRCD_OVERLOAD(hide_name)
|
||||
|
||||
protected:
|
||||
char buf[BUFSIZE];
|
||||
|
||||
ssize_t generate(const char *const &name, const string_view &fmt, const va_rtti &ap) noexcept;
|
||||
|
@ -156,6 +157,20 @@ struct name \
|
|||
:parent \
|
||||
{ \
|
||||
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 \
|
||||
:parent{generate_skip} \
|
||||
{ \
|
||||
|
|
44
ircd/json.cc
44
ircd/json.cc
|
@ -1784,27 +1784,21 @@ ircd::string_view
|
|||
ircd::json::stringify(mutable_buffer &buf,
|
||||
const iov &iov)
|
||||
{
|
||||
const ctx::critical_assertion ca;
|
||||
thread_local const member *m[iov::max_size];
|
||||
if(unlikely(size_t(iov.size()) > iov.max_size))
|
||||
throw iov::oversize
|
||||
static const auto addressof //TODO: XXX
|
||||
{
|
||||
[](const member &m) noexcept
|
||||
{
|
||||
"IOV has %zd members but maximum is %zu",
|
||||
iov.size(),
|
||||
iov.max_size
|
||||
};
|
||||
return std::addressof(m);
|
||||
}
|
||||
};
|
||||
|
||||
std::transform(std::begin(iov), std::end(iov), m, []
|
||||
(const member &m)
|
||||
static const auto less_member
|
||||
{
|
||||
return &m;
|
||||
});
|
||||
|
||||
std::sort(m, m + iov.size(), []
|
||||
(const member *const &a, const member *const &b)
|
||||
{
|
||||
return *a < *b;
|
||||
});
|
||||
[](const member *const &a, const member *const &b) noexcept
|
||||
{
|
||||
return *a < *b;
|
||||
}
|
||||
};
|
||||
|
||||
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::list_protocol(buf, m, m + iov.size(), print_member);
|
||||
printer(buf, printer.object_end);
|
||||
|
|
Loading…
Reference in a new issue