2 Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
4 This file is part of Embedded Proto.
6 Embedded Proto is open source software: you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as published
8 by the Free Software Foundation, version 3 of the license.
10 Embedded Proto is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License
for more details.
15 You should have received a copy of the GNU General Public License
16 along with Embedded Proto. If
not, see <https:
18 For commercial and closed source application please visit:
26 Johan Huizingalaan 763a
30 {%
import 'TypeOneof.h' as TypeOneof %}
31 {%
for tmpl_param in
typedef.get_templates() %}
32 {{
"template<" if loop.first}}{{tmpl_param[
'type']}} {{tmpl_param[
'name']}}{{
", " if not loop.last}}{{
">" if loop.last}}
34 class {{
typedef.get_name() }}
final: public ::EmbeddedProto::MessageInterface
37 {{
typedef.get_name() }}(){%
if (
typedef.fields or
typedef.oneofs) %} :
39 {%
for field in
typedef.fields %}
40 {{field.get_variable_name()}}({{field.get_default_value()}}){{
"," if not loop.last}}{{
"," if loop.last and
typedef.oneofs}}
42 {%
for oneof in
typedef.oneofs %}
43 {{oneof.get_which_oneof()}}(id::NOT_SET){{
"," if not loop.last}}
48 ~{{
typedef.get_name() }}()
override =
default;
50 {%
for enum in
typedef.nested_enum_definitions %}
51 {{
enum.render(environment)|indent(4) }}
54 {%
for msg in
typedef.nested_msg_definitions %}
55 {{ msg.render(environment)|indent(4) }}
61 {%
for id_set in
typedef.field_ids %}
62 {{id_set[1]}} = {{id_set[0]}}{{
"," if not loop.last }}
66 {{
typedef.name }}& operator=(
const {{
typedef.name }}& rhs)
68 {%
for field in
typedef.fields %}
69 set_{{ field.get_name() }}(rhs.get_{{ field.get_name() }}());
71 {%
for oneof in
typedef.oneofs %}
72 {{ TypeOneof.assign(oneof)|indent(6) }}
77 {%
for field in
typedef.fields %}
78 {{ field.render_get_set(environment)|indent(4) }}
81 {%
for oneof in
typedef.oneofs %}
82 id get_which_{{oneof.get_name()}}()
const {
return {{oneof.get_which_oneof()}}; }
84 {%
for field in oneof.fields %}
85 {{ field.render_get_set(environment)|indent(4) }}
94 {%
for field in
typedef.fields %}
95 {{ field.render_serialize(environment)|indent(6) }}
98 {%
for oneof in
typedef.oneofs %}
99 switch({{oneof.get_which_oneof()}})
101 {%
for field in oneof.get_fields() %}
102 case id::{{field.variable_id_name}}:
103 {{ field.render_serialize(environment)|indent(10) }}
119 uint32_t id_number = 0;
126 {%
for field in
typedef.fields %}
127 case static_cast<uint32_t
>(id::{{field.get_variable_id_name()}}):
129 {{ field.render_deserialize(environment)|indent(12) }}
134 {%
for oneof in
typedef.oneofs %}
135 {%
for field in oneof.get_fields() %}
136 case static_cast<uint32_t
>(id::{{field.get_variable_id_name()}}):
138 {{ field.render_deserialize(environment)|indent(12) }}
160 return_value = tag_value;
168 {%
for field in
typedef.fields %}
169 clear_{{field.get_name()}}();
171 {%
for oneof in
typedef.oneofs %}
172 clear_{{oneof.get_name()}}();
179 {%
for field in
typedef.fields %}
180 {{field.get_type()}} {{field.get_variable_name()}};
183 {%
for oneof in
typedef.oneofs %}
184 id {{oneof.get_which_oneof()}};
185 union {{oneof.get_name()}}
187 {{oneof.get_name()}}() {}
188 ~{{oneof.get_name()}}() {}
189 {%
for field in oneof.fields %}
190 {# Here we use the field name variable instead of the get_
function as the get
function will add the oneof
191 name. This is the only place where
this is required. #}
192 {{field.get_type()}} {{field.variable_name}};
195 {{oneof.get_name()}} {{oneof.get_variable_name()}};
197 {{ TypeOneof.init(oneof)|indent(6) }}
198 {{ TypeOneof.clear(oneof)|indent(6) }}