From d4edc5eb4eec92a96fcaf4eefc59943dfb59e02e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 4 Nov 2018 17:55:22 +0900 Subject: StateEventKey and std::hash to arrange state events in hashmaps --- lib/events/stateevent.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/events') diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h index e499bdff..76c749f5 100644 --- a/lib/events/stateevent.h +++ b/lib/events/stateevent.h @@ -37,6 +37,13 @@ namespace QMatrixClient { using StateEventPtr = event_ptr_tt; using StateEvents = EventsArray; + /** + * A combination of event type and state key uniquely identifies a piece + * of state in Matrix. + * \sa https://matrix.org/docs/spec/client_server/unstable.html#types-of-room-events + */ + using StateEventKey = std::pair; + template struct Prev { @@ -92,3 +99,13 @@ namespace QMatrixClient { std::unique_ptr> _prev; }; } // namespace QMatrixClient + +namespace std { + template <> struct hash + { + size_t operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT + { + return qHash(k); + } + }; +} -- cgit v1.2.3