5 #include <Quotient/converters.h>
20 struct JsonObjectConverter<FieldType> {
21 static void dumpTo(QJsonObject& jo,
const FieldType& pod)
23 addParam<>(jo,
"regexp"_L1, pod.regexp);
24 addParam<>(jo,
"placeholder"_L1, pod.placeholder);
26 static void fillFrom(
const QJsonObject& jo, FieldType& pod)
28 fillFromJson(jo.value(
"regexp"_L1), pod.regexp);
29 fillFromJson(jo.value(
"placeholder"_L1), pod.placeholder);
49 struct JsonObjectConverter<ProtocolInstance> {
50 static void dumpTo(QJsonObject& jo,
const ProtocolInstance& pod)
52 addParam<>(jo,
"desc"_L1, pod.desc);
53 addParam<>(jo,
"fields"_L1, pod.fields);
54 addParam<>(jo,
"network_id"_L1, pod.networkId);
55 addParam<IfNotEmpty>(jo,
"icon"_L1, pod.icon);
57 static void fillFrom(
const QJsonObject& jo, ProtocolInstance& pod)
59 fillFromJson(jo.value(
"desc"_L1), pod.desc);
60 fillFromJson(jo.value(
"fields"_L1), pod.fields);
61 fillFromJson(jo.value(
"network_id"_L1), pod.networkId);
62 fillFromJson(jo.value(
"icon"_L1), pod.icon);
71 QStringList userFields;
77 QStringList locationFields;
87 QHash<QString, FieldType> fieldTypes;
92 QVector<ProtocolInstance> instances;
96 struct JsonObjectConverter<ThirdPartyProtocol> {
97 static void dumpTo(QJsonObject& jo,
const ThirdPartyProtocol& pod)
99 addParam<>(jo,
"user_fields"_L1, pod.userFields);
100 addParam<>(jo,
"location_fields"_L1, pod.locationFields);
101 addParam<>(jo,
"icon"_L1, pod.icon);
102 addParam<>(jo,
"field_types"_L1, pod.fieldTypes);
103 addParam<>(jo,
"instances"_L1, pod.instances);
105 static void fillFrom(
const QJsonObject& jo, ThirdPartyProtocol& pod)
107 fillFromJson(jo.value(
"user_fields"_L1), pod.userFields);
108 fillFromJson(jo.value(
"location_fields"_L1), pod.locationFields);
109 fillFromJson(jo.value(
"icon"_L1), pod.icon);
110 fillFromJson(jo.value(
"field_types"_L1), pod.fieldTypes);
111 fillFromJson(jo.value(
"instances"_L1), pod.instances);