mirror of
https://github.com/matrix-construct/construct
synced 2024-11-10 20:11:07 +01:00
ircd:Ⓜ️:user::rooms: Simplify interface w/ util::closure_bool.
This commit is contained in:
parent
04559a28f6
commit
cf8e4092c9
3 changed files with 9 additions and 36 deletions
|
@ -16,19 +16,17 @@ struct ircd::m::user::rooms
|
||||||
{
|
{
|
||||||
struct origins;
|
struct origins;
|
||||||
|
|
||||||
using closure = std::function<void (const m::room &, const string_view &)>;
|
using closure_bool = util::closure_bool
|
||||||
using closure_bool = std::function<bool (const m::room &, const string_view &)>;
|
<
|
||||||
|
std::function,
|
||||||
|
const m::room &, const string_view &
|
||||||
|
>;
|
||||||
|
|
||||||
m::user user;
|
m::user user;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// All rooms with specific membership
|
|
||||||
bool for_each(const string_view &membership, const closure_bool &) const;
|
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;
|
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 string_view &membership) const;
|
||||||
size_t count() const;
|
size_t count() const;
|
||||||
|
|
|
@ -67,18 +67,6 @@ const
|
||||||
return ret;
|
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
|
bool
|
||||||
ircd::m::user::rooms::for_each(const closure_bool &closure)
|
ircd::m::user::rooms::for_each(const closure_bool &closure)
|
||||||
const
|
const
|
||||||
|
@ -86,19 +74,6 @@ const
|
||||||
return for_each(string_view{}, closure);
|
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
|
bool
|
||||||
ircd::m::user::rooms::for_each(const string_view &membership_,
|
ircd::m::user::rooms::for_each(const string_view &membership_,
|
||||||
const closure_bool &closure)
|
const closure_bool &closure)
|
||||||
|
|
|
@ -12724,13 +12724,13 @@ console_cmd__user__rooms(opt &out, const string_view &line)
|
||||||
user
|
user
|
||||||
};
|
};
|
||||||
|
|
||||||
rooms.for_each(membership, m::user::rooms::closure{[&out]
|
rooms.for_each(membership, [&out]
|
||||||
(const m::room &room, const string_view &membership)
|
(const m::room &room, const string_view &membership)
|
||||||
{
|
{
|
||||||
out << room.room_id
|
out << room.room_id
|
||||||
<< " " << membership
|
<< " " << membership
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13697,7 +13697,7 @@ console_cmd__user__room_tags(opt &out, const string_view &line)
|
||||||
user_id
|
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 m::room &room, const string_view &membership)
|
||||||
{
|
{
|
||||||
const auto output
|
const auto output
|
||||||
|
@ -13718,7 +13718,7 @@ console_cmd__user__room_tags(opt &out, const string_view &line)
|
||||||
room_tags.get(tag, output);
|
room_tags.get(tag, output);
|
||||||
else
|
else
|
||||||
room_tags.for_each(output);
|
room_tags.for_each(output);
|
||||||
}});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue