mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 13:01:07 +01:00
ircd:Ⓜ️ Elaborate the event::prev interface with pattern conveniences.
This commit is contained in:
parent
535232603c
commit
3597d1eb6b
2 changed files with 78 additions and 0 deletions
|
@ -99,6 +99,14 @@ struct ircd::m::event::prev
|
|||
{
|
||||
enum cond :int;
|
||||
|
||||
std::tuple<event::id, string_view> auth_events(const uint &idx) const;
|
||||
std::tuple<event::id, string_view> prev_states(const uint &idx) const;
|
||||
std::tuple<event::id, string_view> prev_events(const uint &idx) const;
|
||||
|
||||
event::id auth_event(const uint &idx) const;
|
||||
event::id prev_state(const uint &idx) const;
|
||||
event::id prev_event(const uint &idx) const;
|
||||
|
||||
using super_type::tuple;
|
||||
using super_type::operator=;
|
||||
};
|
||||
|
|
|
@ -337,6 +337,76 @@ ircd::m::event::event(const id &id,
|
|||
new (this) m::event(obj);
|
||||
}
|
||||
|
||||
//
|
||||
// event::prev
|
||||
//
|
||||
|
||||
ircd::m::event::id
|
||||
ircd::m::event::prev::auth_event(const uint &idx)
|
||||
const
|
||||
{
|
||||
return std::get<0>(auth_events(idx));
|
||||
}
|
||||
|
||||
ircd::m::event::id
|
||||
ircd::m::event::prev::prev_state(const uint &idx)
|
||||
const
|
||||
{
|
||||
return std::get<0>(prev_states(idx));
|
||||
}
|
||||
|
||||
ircd::m::event::id
|
||||
ircd::m::event::prev::prev_event(const uint &idx)
|
||||
const
|
||||
{
|
||||
return std::get<0>(prev_events(idx));
|
||||
}
|
||||
|
||||
std::tuple<ircd::m::event::id, ircd::string_view>
|
||||
ircd::m::event::prev::auth_events(const uint &idx)
|
||||
const
|
||||
{
|
||||
const json::array &auth_event
|
||||
{
|
||||
at<"auth_events"_>(*this).at(idx)
|
||||
};
|
||||
|
||||
return
|
||||
{
|
||||
unquote(auth_event.at(0)), unquote(auth_event[1])
|
||||
};
|
||||
}
|
||||
|
||||
std::tuple<ircd::m::event::id, ircd::string_view>
|
||||
ircd::m::event::prev::prev_states(const uint &idx)
|
||||
const
|
||||
{
|
||||
const json::array &state_event
|
||||
{
|
||||
at<"prev_state"_>(*this).at(idx)
|
||||
};
|
||||
|
||||
return
|
||||
{
|
||||
unquote(state_event.at(0)), unquote(state_event[1])
|
||||
};
|
||||
}
|
||||
|
||||
std::tuple<ircd::m::event::id, ircd::string_view>
|
||||
ircd::m::event::prev::prev_events(const uint &idx)
|
||||
const
|
||||
{
|
||||
const json::array &prev_event
|
||||
{
|
||||
at<"prev_events"_>(*this).at(idx)
|
||||
};
|
||||
|
||||
return
|
||||
{
|
||||
unquote(prev_event.at(0)), unquote(prev_event[1])
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// event::fetch
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue