aboutsummaryrefslogtreecommitdiff
path: root/lib/application-service/definitions/protocol.cpp
blob: 5e70ff16b86f727a037639a19bbfa3aa9c11d762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#include "protocol.h"

using namespace QMatrixClient;

QJsonObject QMatrixClient::toJson(const FieldType& pod)
{
    QJsonObject _json;
    addParam<IfNotEmpty>(_json, QStringLiteral("regexp"), pod.regexp);
    addParam<IfNotEmpty>(_json, QStringLiteral("placeholder"), pod.placeholder);
    return _json;
}

FieldType FromJson<FieldType>::operator()(const QJsonValue& jv)
{
    const auto& _json = jv.toObject();
    FieldType result;
    result.regexp =
        fromJson<QString>(_json.value("regexp"_ls));
    result.placeholder =
        fromJson<QString>(_json.value("placeholder"_ls));
    
    return result;
}

QJsonObject QMatrixClient::toJson(const FieldTypes& pod)
{
    QJsonObject _json;
    addParam<IfNotEmpty>(_json, QStringLiteral("fieldname"), pod.fieldname);
    return _json;
}

FieldTypes FromJson<FieldTypes>::operator()(const QJsonValue& jv)
{
    const auto& _json = jv.toObject();
    FieldTypes result;
    result.fieldname =
        fromJson<FieldType>(_json.value("fieldname"_ls));
    
    return result;
}

QJsonObject QMatrixClient::toJson(const ThirdPartyProtocol& pod)
{
    QJsonObject _json;
    addParam<IfNotEmpty>(_json, QStringLiteral("user_fields"), pod.userFields);
    addParam<IfNotEmpty>(_json, QStringLiteral("location_fields"), pod.locationFields);
    addParam<IfNotEmpty>(_json, QStringLiteral("icon"), pod.icon);
    addParam<IfNotEmpty>(_json, QStringLiteral("field_types"), pod.fieldTypes);
    addParam<IfNotEmpty>(_json, QStringLiteral("instances"), pod.instances);
    return _json;
}

ThirdPartyProtocol FromJson<ThirdPartyProtocol>::operator()(const QJsonValue& jv)
{
    const auto& _json = jv.toObject();
    ThirdPartyProtocol result;
    result.userFields =
        fromJson<QStringList>(_json.value("user_fields"_ls));
    result.locationFields =
        fromJson<QStringList>(_json.value("location_fields"_ls));
    result.icon =
        fromJson<QString>(_json.value("icon"_ls));
    result.fieldTypes =
        fromJson<FieldTypes>(_json.value("field_types"_ls));
    result.instances =
        fromJson<QVector<QJsonObject>>(_json.value("instances"_ls));
    
    return result;
}