mirror of
https://github.com/matrix-construct/construct
synced 2024-11-13 21:41:06 +01:00
ircd:Ⓜ️:room::state: Add a type prefix-domain iteration to state interface.
This commit is contained in:
parent
a441c77b6b
commit
7c09123a3c
2 changed files with 22 additions and 0 deletions
|
@ -28,6 +28,7 @@ struct ircd::m::room::state
|
||||||
using keys_bool = std::function<bool (const string_view &)>;
|
using keys_bool = std::function<bool (const string_view &)>;
|
||||||
using types = std::function<void (const string_view &)>;
|
using types = std::function<void (const string_view &)>;
|
||||||
using types_bool = std::function<bool (const string_view &)>;
|
using types_bool = std::function<bool (const string_view &)>;
|
||||||
|
IRCD_STRONG_TYPEDEF(string_view, type_prefix)
|
||||||
|
|
||||||
static conf::item<bool> disable_history;
|
static conf::item<bool> disable_history;
|
||||||
static conf::item<size_t> readahead_size;
|
static conf::item<size_t> readahead_size;
|
||||||
|
@ -45,6 +46,7 @@ struct ircd::m::room::state
|
||||||
// Iterate the state
|
// Iterate the state
|
||||||
bool for_each(const types_bool &) const;
|
bool for_each(const types_bool &) const;
|
||||||
void for_each(const types &) const;
|
void for_each(const types &) const;
|
||||||
|
bool for_each(const type_prefix &pref, const types_bool &) const;
|
||||||
bool for_each(const string_view &type, const keys_bool &view) const;
|
bool for_each(const string_view &type, const keys_bool &view) const;
|
||||||
void for_each(const string_view &type, const keys &) const;
|
void for_each(const string_view &type, const keys &) const;
|
||||||
bool for_each(const string_view &type, const string_view &lower_bound, const keys_bool &view) const;
|
bool for_each(const string_view &type, const string_view &lower_bound, const keys_bool &view) const;
|
||||||
|
|
|
@ -1468,6 +1468,26 @@ const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::room::state::for_each(const type_prefix &prefix,
|
||||||
|
const types_bool &closure)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
bool ret(true), cont(true);
|
||||||
|
for_each(types_bool([&prefix, &closure, &ret, &cont]
|
||||||
|
(const string_view &type)
|
||||||
|
{
|
||||||
|
if(!startswith(type, string_view(prefix)))
|
||||||
|
return cont;
|
||||||
|
|
||||||
|
cont = false;
|
||||||
|
ret = closure(type);
|
||||||
|
return ret;
|
||||||
|
}));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::m::room::state::for_each(const types &closure)
|
ircd::m::room::state::for_each(const types &closure)
|
||||||
const
|
const
|
||||||
|
|
Loading…
Reference in a new issue