0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd:Ⓜ️ Add reverse reflection for event::conforms code.

This commit is contained in:
Jason Volk 2018-02-21 15:00:02 -08:00
parent 4f4b53416c
commit bae8e3b869
2 changed files with 19 additions and 1 deletions

View file

@ -150,6 +150,7 @@ struct ircd::m::event::conforms
conforms(const event &);
conforms(const event &, const uint64_t &skip);
static code reflect(const string_view &);
friend string_view reflect(const code &);
friend std::ostream &operator<<(std::ostream &, const conforms &);
};

View file

@ -553,6 +553,23 @@ catch(const std::out_of_range &e)
return "??????"_sv;
}
ircd::m::event::conforms::code
ircd::m::event::conforms::reflect(const string_view &name)
{
const auto it
{
std::find(begin(event_conforms_reflects), end(event_conforms_reflects), name)
};
if(it == end(event_conforms_reflects))
throw std::out_of_range
{
"There is no event::conforms code by that name."
};
return code(std::distance(begin(event_conforms_reflects), it));
}
ircd::m::event::conforms::conforms(const event &e,
const uint64_t &skip)
:conforms{e}
@ -652,7 +669,7 @@ const
if(begin(buf) != begin(out))
consume(buf, copy(buf, " "_sv));
consume(buf, copy(buf, reflect(code(i))));
consume(buf, copy(buf, m::reflect(code(i))));
}
return { data(out), begin(buf) };