aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-01 13:52:23 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-01 20:46:52 +0900
commit203a6b61480f726fae341d119f09f9dc83b8829a (patch)
treebe7fbf67b1119c355cf306f4ddecb3162d46bc87
parent6a73f99fc71df74b1c60e6e202cd4d6787d0cb07 (diff)
downloadlibquotient-203a6b61480f726fae341d119f09f9dc83b8829a.tar.gz
libquotient-203a6b61480f726fae341d119f09f9dc83b8829a.zip
Integrate converters with EventPtr partially
So that events can be created from JSON in the same way as all other types.
-rw-r--r--lib/events/event.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/events/event.h b/lib/events/event.h
index d614115a..68e598ad 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -18,15 +18,9 @@
#pragma once
-#include <QtCore/QString>
-#include <QtCore/QDateTime>
-#include <QtCore/QJsonObject>
-#include <QtCore/QJsonArray>
-
+#include "converters.h"
#include "util.h"
-#include <memory>
-
namespace QMatrixClient
{
template <typename EventT>
@@ -110,6 +104,14 @@ namespace QMatrixClient
EventPtr doMakeEvent<Event>(const QJsonObject& obj);
}
+ template <> struct FromJson<EventPtr>
+ {
+ EventPtr operator()(const QJsonValue& jv) const
+ {
+ return makeEvent<Event>(jv.toObject());
+ }
+ };
+
/**
* \brief A vector of pointers to events with deserialisation capabilities
*