libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
single_key_value.h
Go to the documentation of this file.
1
#
pragma
once
2
3
#
include
<
Quotient
/
converters
.
h
>
4
5
namespace
Quotient
{
6
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
)) {}
12
T
value
;
13
};
14
}
// namespace EventContent
15
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)
20
{
21
return
fromJson<ValueT>(jv.toObject().value(JsonKey));
22
}
23
static
QJsonObject dump(
const
content_type& c)
24
{
25
return
{ { JsonKey, toJson(c.value) } };
26
}
27
static
inline
const
auto
JsonKey =
toSnakeCase
(
KeyStr
);
28
};
29
}
// namespace Quotient
Quotient::EventContent
Definition
eventcontent.h:27
Quotient
Definition
accountregistry.h:13
Quotient::EventContent::SingleKeyValue
Definition
single_key_value.h:9
Quotient::EventContent::SingleKeyValue::value
T value
Definition
single_key_value.h:12
Quotient::JsonConverter
The switchboard for extra conversion algorithms behind from/toJson.
Definition
converters.h:78
Quotient
events
single_key_value.h
Generated by
1.9.8