aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-07-06 19:59:34 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-07-06 19:59:34 +0900
commitcbb4f219d5c79f81706019c0679222d5ccee4a4c (patch)
tree3bd75f2baa8abca1e6ed792781a071e67398bffb /lib
parent01cce0e39d255cbcf39f6a1aa58c6d7ab1d995d1 (diff)
downloadlibquotient-cbb4f219d5c79f81706019c0679222d5ccee4a4c.tar.gz
libquotient-cbb4f219d5c79f81706019c0679222d5ccee4a4c.zip
loadStateEvent()
Diffstat (limited to 'lib')
-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)