aboutsummaryrefslogtreecommitdiff
path: root/lib/events/eventloader.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events/eventloader.h')
-rw-r--r--lib/events/eventloader.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/events/eventloader.h b/lib/events/eventloader.h
index da663392..d0fa60a2 100644
--- a/lib/events/eventloader.h
+++ b/lib/events/eventloader.h
@@ -32,7 +32,8 @@ namespace QMatrixClient {
}
}
- /** Create an event with proper type from a JSON object
+ /*! Create an event with proper type from a JSON object
+ *
* Use this factory template to detect the type from the JSON object
* contents (the detected event type should derive from the template
* parameter type) and create an event object of that type.
@@ -44,7 +45,8 @@ namespace QMatrixClient {
fullJson[TypeKeyL].toString());
}
- /** Create an event from a type string and content JSON
+ /*! Create an event from a type string and content JSON
+ *
* Use this factory template to resolve the C++ type from the Matrix
* type string in \p matrixType and create an event of that type that has
* its content part set to \p content.
@@ -57,6 +59,20 @@ namespace QMatrixClient {
matrixType);
}
+ /*! Create a state event from a type string, content JSON and state key
+ *
+ * Use this factory to resolve the C++ type from the Matrix type string
+ * in \p matrixType and create a state event of that type with content part
+ * set to \p content and state key set to \p stateKey (empty by default).
+ */
+ inline StateEventPtr loadStateEvent(const QString& matrixType,
+ const QJsonObject& content,
+ const QString& stateKey = {})
+ {
+ return _impl::loadEvent<StateEventBase>(
+ basicStateEventJson(matrixType, content, stateKey), matrixType);
+ }
+
template <typename EventT> struct JsonConverter<event_ptr_tt<EventT>>
{
static auto load(const QJsonValue& jv)