mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:Ⓜ️:events::type: Add has()/has_prefix() to interface.
This commit is contained in:
parent
204989802d
commit
fd953d4b10
2 changed files with 34 additions and 0 deletions
|
@ -40,6 +40,10 @@ namespace ircd::m::events::type
|
||||||
|
|
||||||
// Iterate the events for a specific type.
|
// Iterate the events for a specific type.
|
||||||
bool for_each_in(const string_view &, const closure &);
|
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.
|
/// Interface to the senders of all events known to the server.
|
||||||
|
|
|
@ -259,6 +259,36 @@ ircd::m::events::for_each(const range &range,
|
||||||
// events::type
|
// 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
|
bool
|
||||||
IRCD_MODULE_EXPORT
|
IRCD_MODULE_EXPORT
|
||||||
ircd::m::events::type::for_each_in(const string_view &type,
|
ircd::m::events::type::for_each_in(const string_view &type,
|
||||||
|
|
Loading…
Reference in a new issue