aboutsummaryrefslogtreecommitdiff
path: root/gtad/data.h.mustache
blob: a219338053f907147dbcdb27cb0ef575e7ad9cdd (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
{{!
SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
SPDX-License-Identifier: LGPL-2.1-or-later
}}
{{>preamble}}
#pragma once

#include "converters.h"
{{#imports}}
#include {{_}}{{/imports}}

namespace Quotient {
{{#models}}
    {{#model}}
{{>docCommentShort}}
struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{>cjoin}}{{/parents}}{{/parents?}}
{       {{#vars}}

    {{>docCommentShort}}
    {{>maybeOmittableType}} {{nameCamelCase}};
        {{/vars}}{{#propertyMap}}

    {{>docCommentShort}}
    {{>maybeOmittableType}} {{nameCamelCase}};
        {{/propertyMap}}
};

template <> struct JsonObjectConverter<{{name}}>
{
        {{#in?}}
    static void dumpTo(QJsonObject& jo, const {{name}}& pod)
    {       {{#propertyMap}}
        fillJson(jo, pod.{{nameCamelCase}});
            {{/propertyMap}}{{#parents}}
        fillJson<{{name}}>(jo, pod);
            {{/parents}}{{#vars}}
        addParam<{{^required?}}IfNotEmpty{{/required?}}>(jo,
                QStringLiteral("{{baseName}}"), pod.{{nameCamelCase}});
            {{/vars}}
        }
        {{/in?}}
        {{#out?}}
    static void fillFrom({{>maybeCrefJsonObject}} jo, {{name}}& pod)
    {       {{#parents}}
        fillFromJson<{{qualifiedName}}>(jo, pod);
            {{/parents}}{{#vars}}
        fromJson(jo.{{>takeOrValue}}("{{baseName}}"_ls), pod.{{nameCamelCase}});
            {{/vars}}{{#propertyMap}}
        fromJson(jo, pod.{{nameCamelCase}});
            {{/propertyMap}}
    }
        {{/out?}}
};

    {{/model}}
{{/models}}
} // namespace Quotient