blob: a7447d6922aa39ede8988838f24db39709143f0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// generated file, do not modify!
// {{ dateTime }}
#include "{{ moduleName }}.hpp"
{% for t in definitions %}
template<> json toJSON<{{ t.value.dataName }}>({{ t.value.dataName }} &v) {
json obj;
switch (v.tag) { {% for c in t.value.constructors %}
case ::{{ t.value.dataName }}::tag::{{ c.value.name }}:
obj["tag"] = "{{ c.value.name }}";{% if !(c.value.fields | empty) %}
{
auto tv = static_cast<::data::{{ c.value.name }}&>(v);{% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %}
obj["{{ f.value.fieldName }}"] = toJSON(tv.{{ f.value.fieldName }});{% else %}
obj["arg{{ f.index0 }}"] = toJSON(tv._{{ f.index0 }});{% endif %}{% endfor %}
}{% endif %}
break;{% endfor %}
}
return obj;
}
{% endfor %}
|