aboutsummaryrefslogtreecommitdiff
path: root/lib/events/stateevent.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-11-04 17:55:22 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-11-04 17:55:22 +0900
commitd4edc5eb4eec92a96fcaf4eefc59943dfb59e02e (patch)
tree1655342cfca21eecca0a8838193f42b826db153a /lib/events/stateevent.h
parent2fe086f4e8f15cf366fc2cf1c9942c7b7541cec7 (diff)
downloadlibquotient-d4edc5eb4eec92a96fcaf4eefc59943dfb59e02e.tar.gz
libquotient-d4edc5eb4eec92a96fcaf4eefc59943dfb59e02e.zip
StateEventKey and std::hash<StateEventKey> to arrange state events in hashmaps
Diffstat (limited to 'lib/events/stateevent.h')
-rw-r--r--lib/events/stateevent.h17
1 files changed, 17 insertions, 0 deletions
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<StateEventBase>;
using StateEvents = EventsArray<StateEventBase>;
+ /**
+ * 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<Event::Type, QString>;
+
template <typename ContentT>
struct Prev
{
@@ -92,3 +99,13 @@ namespace QMatrixClient {
std::unique_ptr<Prev<ContentT>> _prev;
};
} // namespace QMatrixClient
+
+namespace std {
+ template <> struct hash<QMatrixClient::StateEventKey>
+ {
+ size_t operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT
+ {
+ return qHash(k);
+ }
+ };
+}