0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️:events::type: Add has()/has_prefix() to interface.

This commit is contained in:
Jason Volk 2019-08-20 18:48:35 -07:00
parent 204989802d
commit fd953d4b10
2 changed files with 34 additions and 0 deletions

View file

@ -40,6 +40,10 @@ namespace ircd::m::events::type
// Iterate the events for a specific type.
bool for_each_in(const string_view &, const closure &);
// Test if type name is known to the server.
bool has_prefix(const string_view &);
bool has(const string_view &);
}
/// Interface to the senders of all events known to the server.

View file

@ -259,6 +259,36 @@ ircd::m::events::for_each(const range &range,
// events::type
//
bool
IRCD_MODULE_EXPORT
ircd::m::events::type::has(const string_view &type)
{
bool ret{false};
for_each(type, [&ret, &type]
(const string_view &type_)
{
ret = type == type_;
return false; // uncond break out of loop after first result
});
return ret;
}
bool
IRCD_MODULE_EXPORT
ircd::m::events::type::has_prefix(const string_view &type)
{
bool ret{false};
for_each(type, [&ret, &type]
(const string_view &type_)
{
ret = startswith(type_, type);
return false; // uncond break out of loop after first result
});
return ret;
}
bool
IRCD_MODULE_EXPORT
ircd::m::events::type::for_each_in(const string_view &type,