diff --git a/include/ircd/m/state.h b/include/ircd/m/state.h index 642eb2ca6..9db0d11c2 100644 --- a/include/ircd/m/state.h +++ b/include/ircd/m/state.h @@ -61,6 +61,10 @@ namespace ircd::m::state bool test(const string_view &root, const iter_bool_closure &); bool test(const string_view &root, const string_view &type, const iter_bool_closure &); + + void for_each(const string_view &root, const iter_closure &); + void for_each(const string_view &root, const string_view &type, const iter_closure &); + size_t count(const string_view &root, const iter_bool_closure &); size_t count(const string_view &root); diff --git a/ircd/m/state.cc b/ircd/m/state.cc index 2acf60d35..79f0da5b6 100644 --- a/ircd/m/state.cc +++ b/ircd/m/state.cc @@ -107,16 +107,35 @@ ircd::m::state::count(const string_view &root, const iter_bool_closure &closure) { size_t ret{0}; - test(root, [&ret, &closure] + for_each(root, [&ret, &closure] (const json::array &key, const string_view &val) { ret += closure(key, val); - return false; }); return ret; } +void +ircd::m::state::for_each(const string_view &root, + const iter_closure &closure) +{ + for_each(root, string_view{}, closure); +} + +void +ircd::m::state::for_each(const string_view &root, + const string_view &type, + const iter_closure &closure) +{ + test(root, type, [&closure] + (const json::array &key, const string_view &val) + { + closure(key, val); + return false; + }); +} + bool ircd::m::state::test(const string_view &root, const iter_bool_closure &closure)