mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd:Ⓜ️🆔:event: Add non-throwing static tests of v3/v4 id from string.
This commit is contained in:
parent
6c62515a6d
commit
9ca019f03e
2 changed files with 32 additions and 0 deletions
|
@ -179,6 +179,8 @@ struct ircd::m::id::event
|
|||
struct ircd::m::id::event::v3
|
||||
:ircd::m::id::event
|
||||
{
|
||||
static bool is(const string_view &) noexcept;
|
||||
|
||||
v3(const mutable_buffer &out, const m::event &);
|
||||
v3(const string_view &id);
|
||||
v3() = default;
|
||||
|
@ -188,6 +190,8 @@ struct ircd::m::id::event::v3
|
|||
struct ircd::m::id::event::v4
|
||||
:ircd::m::id::event
|
||||
{
|
||||
static bool is(const string_view &) noexcept;
|
||||
|
||||
v4(const mutable_buffer &out, const m::event &);
|
||||
v4(const string_view &id);
|
||||
v4() = default;
|
||||
|
|
28
ircd/m_id.cc
28
ircd/m_id.cc
|
@ -732,6 +732,20 @@ ircd::m::id::event::v3::v3(const mutable_buffer &out,
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::id::event::v3::is(const string_view &id)
|
||||
noexcept
|
||||
{
|
||||
static const parser::rule<> &valid
|
||||
{
|
||||
parser.event_id_v3
|
||||
};
|
||||
|
||||
auto *start(std::begin(id));
|
||||
auto *const stop(std::end(id));
|
||||
return qi::parse(start, stop, valid);
|
||||
}
|
||||
|
||||
//
|
||||
// id::event::v4
|
||||
//
|
||||
|
@ -785,6 +799,20 @@ ircd::m::id::event::v4::v4(const mutable_buffer &out,
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::id::event::v4::is(const string_view &id)
|
||||
noexcept
|
||||
{
|
||||
static const parser::rule<> &valid
|
||||
{
|
||||
parser.event_id_v4
|
||||
};
|
||||
|
||||
auto *start(std::begin(id));
|
||||
auto *const stop(std::end(id));
|
||||
return qi::parse(start, stop, valid);
|
||||
}
|
||||
|
||||
//
|
||||
// util
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue