3 #include <Quotient/converters.h>
7 namespace EventContent {
8 template <
typename T,
const QLatin1String& KeyStr>
9 struct SingleKeyValue {
10 Q_IMPLICIT SingleKeyValue(
const T& v = {}) : value(v) {}
11 Q_IMPLICIT SingleKeyValue(T&& v) : value(std::move(v)) {}
16 template <
typename ValueT,
const QLatin1String& KeyStr>
17 struct JsonConverter<EventContent::SingleKeyValue<ValueT, KeyStr>> {
18 using content_type = EventContent::SingleKeyValue<ValueT, KeyStr>;
19 static content_type load(
const QJsonValue& jv)
21 return fromJson<ValueT>(jv.toObject().value(JsonKey));
23 static QJsonObject dump(
const content_type& c)
25 return { { JsonKey, toJson(c.value) } };
27 static inline const auto JsonKey = toSnakeCase(KeyStr);