0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-30 17:34:04 +01:00

ircd: Add exception message generation bypass constructor.

This commit is contained in:
Jason Volk 2016-10-17 12:15:26 -07:00
parent dffb39f8cc
commit 2c231ac187
2 changed files with 18 additions and 4 deletions

View file

@ -52,6 +52,8 @@ struct exception
:std::exception
{
protected:
IRCD_OVERLOAD(generate_skip)
char buf[BUFSIZE];
ssize_t generate(const char *const &name, const char *const &fmt, va_list ap) noexcept;
@ -63,7 +65,7 @@ struct exception
return buf;
}
exception() noexcept
exception(const generate_skip_t = {}) noexcept
{
buf[0] = '\0';
}
@ -106,24 +108,36 @@ struct name \
:parent \
{ \
name(const char *const fmt = " ", ...) noexcept AFP(2, 3) \
:parent{generate_skip} \
{ \
va_list ap; \
va_start(ap, fmt); \
generate(#name, fmt, ap); \
va_end(ap); \
} \
};
\
name(const generate_skip_t) noexcept \
:parent{generate_skip} \
{ \
} \
}; \
#define IRCD_EXCEPTION_HIDENAME(parent, name) \
struct name \
:parent \
{ \
name(const char *const fmt = " ", ...) noexcept AFP(2, 3) \
name(const char *const fmt, ...) noexcept AFP(2, 3) \
parent{generate_skip_t} \
{ \
va_list ap; \
va_start(ap, fmt); \
generate(fmt, ap); \
va_end(ap); \
} \
\
name(const generate_skip_t = {}) noexcept \
:parent{generate_skip} \
{ \
} \
};

View file

@ -41,7 +41,7 @@ noexcept
{
size_t size(0);
const bool empty(!fmt || !fmt[0] || fmt[0] == ' ');
size = rb_strlcpy(buf, name, sizeof(buf));
size = rb_strlcat(buf, name, sizeof(buf));
size = rb_strlcat(buf, empty? "." : ": ", sizeof(buf));
if(size < sizeof(buf))
size += vsnprintf(buf + size, sizeof(buf) - size, fmt, ap);