0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

modules/console: Add event refs count cmd.

This commit is contained in:
Jason Volk 2020-12-10 03:32:04 -08:00
parent 42f7b05775
commit c8ab0ce239

View file

@ -8423,6 +8423,50 @@ console_cmd__event__refs(opt &out, const string_view &line)
return true;
}
bool
console_cmd__event__refs__count(opt &out, const string_view &line)
{
const params param{line, " ",
{
"event_id", "type"
}};
const m::event::id &event_id
{
param.at("event_id")
};
const m::event::refs refs
{
index(event_id)
};
const string_view &typestr
{
param["type"]
};
m::dbs::ref type
{
empty(typestr)?
m::dbs::ref(-1):
m::dbs::ref(0)
};
if(!empty(typestr))
for(; uint8_t(type) < sizeof(m::dbs::ref) * 256; type = m::dbs::ref(uint8_t(type) + 1))
if(reflect(type) == typestr)
break;
const auto count
{
refs.count(type)
};
out << count << std::endl;
return true;
}
bool
console_cmd__event__refs__next(opt &out, const string_view &line)
{