0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-04 21:08:57 +01:00

ircd:Ⓜ️🆔 Add event::id version gauge method.

This commit is contained in:
Jason Volk 2019-06-26 03:35:34 -07:00
parent 7c142b9519
commit fcfc28c6e4
2 changed files with 34 additions and 0 deletions

View file

@ -161,6 +161,8 @@ struct ircd::m::id::event
using closure = std::function<void (const id::event &)>;
using closure_bool = std::function<bool (const id::event &)>;
string_view version() const; // static view
template<class... args>
event(args&&... a)
:m::id{EVENT, std::forward<args>(a)...}

View file

@ -648,6 +648,38 @@ const
return ret;
}
//
// id::event
//
ircd::string_view
ircd::m::id::event::version()
const
{
static const parser::rule<> &is_v4
{
parser.event_id_v4
};
static const parser::rule<> &is_v3
{
parser.event_id_v3
};
const auto &local(this->local());
auto *start(std::begin(local));
auto *const stop(std::end(local));
return
qi::parse(start, stop, is_v4)? "4":
qi::parse(start, stop, is_v3)? "3":
"1";
}
//
// util
//
bool
ircd::m::my(const id &id)
{