diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-07-09 11:49:05 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-07-09 11:49:05 +0900 |
commit | 31e28e2a99e6815da407d201e7287423a4956138 (patch) | |
tree | 049f3b156ad2cca3f328d163c9267ae90d984485 /lib/events/eventloader.h | |
parent | b5dd30189df0d7515116b2abac1f93fc0f8a1989 (diff) | |
parent | 651478c1681ba6f93e22c20328a048dbbc263ffe (diff) | |
download | libquotient-31e28e2a99e6815da407d201e7287423a4956138.tar.gz libquotient-31e28e2a99e6815da407d201e7287423a4956138.zip |
Merge branch 'master' into use-clang-format
Diffstat (limited to 'lib/events/eventloader.h')
-rw-r--r-- | lib/events/eventloader.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/events/eventloader.h b/lib/events/eventloader.h index 9c797701..a203eaa3 100644 --- a/lib/events/eventloader.h +++ b/lib/events/eventloader.h @@ -34,7 +34,8 @@ namespace _impl } } // namespace _impl -/** 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. @@ -45,7 +46,8 @@ inline event_ptr_tt<BaseEventT> loadEvent(const QJsonObject& fullJson) return _impl::loadEvent<BaseEventT>(fullJson, 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. @@ -58,6 +60,20 @@ inline event_ptr_tt<BaseEventT> loadEvent(const QString& matrixType, 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>> { |