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 {% macro assign(_oneof) %}
31 if(rhs.get_which_{{_oneof.get_name()}}() != {{_oneof.get_which_oneof()}})
34 clear_{{_oneof.get_name()}}();
37 switch(rhs.get_which_{{_oneof.get_name()}}())
39 {%
for field in _oneof.get_fields() %}
40 case id::{{field.get_variable_id_name()}}:
41 set_{{field.get_name()}}(rhs.get_{{field.name}}());
50 {# ------------------------------------------------------------------------------------------------------------------ #}
52 {% macro init(_oneof) %}
53 void init_{{_oneof.get_name()}}(
const id field_id)
55 if(id::NOT_SET != {{_oneof.get_which_oneof()}})
58 clear_{{_oneof.get_name()}}();
61 {%
if _oneof.oneof_allocation_required() %}
65 {%
for field in _oneof.get_fields() %}
66 {%
if field.oneof_allocation_required() %}
67 case id::{{field.get_variable_id_name()}}:
68 new(&{{field.get_variable_name()}}) {{field.get_type()}};
69 {{_oneof.get_which_oneof()}} = id::{{field.get_variable_id_name()}};
79 {{_oneof.get_which_oneof()}} = field_id;
83 {# ------------------------------------------------------------------------------------------------------------------ #}
85 {% macro clear(_oneof) %}
86 void clear_{{_oneof.get_name()}}()
88 switch({{_oneof.get_which_oneof()}})
90 {%
for field in _oneof.get_fields() %}
91 case id::{{field.get_variable_id_name()}}:
92 {%
if field.oneof_allocation_required() %}
93 {{field.get_variable_name()}}.~{{field.get_short_type()}}();
94 {% elif field.of_type_enum %}
95 {{field.get_variable_name()}} = {{field.get_default_value()}};
97 {{field.get_variable_name()}}.set(0);
104 {{_oneof.get_which_oneof()}} = id::NOT_SET;