ircd:Ⓜ️:user::rooms: Simplify interface w/ util::closure_bool.
This commit is contained in:
parent
04559a28f6
commit
cf8e4092c9
|
@ -16,19 +16,17 @@ struct ircd::m::user::rooms
|
|||
{
|
||||
struct origins;
|
||||
|
||||
using closure = std::function<void (const m::room &, const string_view &)>;
|
||||
using closure_bool = std::function<bool (const m::room &, const string_view &)>;
|
||||
using closure_bool = util::closure_bool
|
||||
<
|
||||
std::function,
|
||||
const m::room &, const string_view &
|
||||
>;
|
||||
|
||||
m::user user;
|
||||
|
||||
public:
|
||||
// All rooms with specific membership
|
||||
bool for_each(const string_view &membership, const closure_bool &) const;
|
||||
void for_each(const string_view &membership, const closure &) const;
|
||||
|
||||
// All rooms with any membership
|
||||
bool for_each(const closure_bool &) const;
|
||||
void for_each(const closure &) const;
|
||||
|
||||
size_t count(const string_view &membership) const;
|
||||
size_t count() const;
|
||||
|
|
|
@ -67,18 +67,6 @@ const
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::user::rooms::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
for_each(closure_bool{[&closure]
|
||||
(const m::room &room, const string_view &membership)
|
||||
{
|
||||
closure(room, membership);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::rooms::for_each(const closure_bool &closure)
|
||||
const
|
||||
|
@ -86,19 +74,6 @@ const
|
|||
return for_each(string_view{}, closure);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::user::rooms::for_each(const string_view &membership,
|
||||
const closure &closure)
|
||||
const
|
||||
{
|
||||
for_each(membership, closure_bool{[&closure]
|
||||
(const m::room &room, const string_view &membership)
|
||||
{
|
||||
closure(room, membership);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::rooms::for_each(const string_view &membership_,
|
||||
const closure_bool &closure)
|
||||
|
|
|
@ -12724,13 +12724,13 @@ console_cmd__user__rooms(opt &out, const string_view &line)
|
|||
user
|
||||
};
|
||||
|
||||
rooms.for_each(membership, m::user::rooms::closure{[&out]
|
||||
rooms.for_each(membership, [&out]
|
||||
(const m::room &room, const string_view &membership)
|
||||
{
|
||||
out << room.room_id
|
||||
<< " " << membership
|
||||
<< std::endl;
|
||||
}});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -13697,7 +13697,7 @@ console_cmd__user__room_tags(opt &out, const string_view &line)
|
|||
user_id
|
||||
};
|
||||
|
||||
rooms.for_each(m::user::rooms::closure{[&user_id, &tag, &out]
|
||||
rooms.for_each([&user_id, &tag, &out]
|
||||
(const m::room &room, const string_view &membership)
|
||||
{
|
||||
const auto output
|
||||
|
@ -13718,7 +13718,7 @@ console_cmd__user__room_tags(opt &out, const string_view &line)
|
|||
room_tags.get(tag, output);
|
||||
else
|
||||
room_tags.for_each(output);
|
||||
}});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue