EmbeddedProto  2.0.0
EmbeddedProto is a C++ Protocol Buffer implementation specifically suitable for microcontrollers.
FieldRepeated_GetSet.h
Go to the documentation of this file.
1 {#
2 Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
3 
4 This file is part of Embedded Proto.
5 
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.
9 
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.
14 
15 You should have received a copy of the GNU General Public License
16 along with Embedded Proto. If not, see <https://www.gnu.org/licenses/>.
17 
18 For commercial and closed source application please visit:
19 <https://EmbeddedProto.com/license/>.
20 
21 Embedded AMS B.V.
22 Info:
23  info at EmbeddedProto dot com
24 
25 Postal address:
26  Johan Huizingalaan 763a
27  1066 VH, Amsterdam
28  the Netherlands
29 #}
30 {% if field.oneof is not none %}
31 inline void clear_{{field.get_name()}}()
32 {
33  if(id::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
34  {
35  {{field.get_which_oneof}} = id::NOT_SET;
36  {{field.get_variable_name()}}.~{{field.get_short_type()}}();
37  }
38 }
39 inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_type()}}& value)
40 {
41  if(id::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
42  {
43  init_{{field.get_oneof_name()}}(id::{{field.get_variable_id_name()}});
44  }
45  {{field.get_variable_name()}}.set(index, value);
46 }
47 inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_type()}}&& value)
48 {
49  if(id::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
50  {
51  init_{{field.get_oneof_name()}}(id::{{field.get_variable_id_name()}});
52  }
53  {{field.get_variable_name()}}.set(index, value);
54 }
55 inline void set_{{field.get_name()}}(const {{field.repeated_type}}& values)
56 {
57  if(id::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
58  {
59  init_{{field.get_oneof_name()}}(id::{{field.get_variable_id_name()}});
60  }
61  {{field.get_variable_name()}} = values;
62 }
63 inline void add_{{field.get_name()}}(const {{field.get_type()}}& value)
64 {
65  if(id::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
66  {
67  init_{{field.get_oneof_name()}}(id::{{field.get_variable_id_name()}});
68  }
69  {{field.get_variable_name()}}.add(value);
70 }
71 inline {{field.repeated_type}}& mutable_{{field.get_name()}}()
72 {
73  if(id::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
74  {
75  init_{{field.get_oneof_name()}}(id::{{field.get_variable_id_name()}});
76  }
77  return {{field.get_variable_name()}};
78 }
79 {% else %}
80 inline const {{field.get_base_type()}}& {{field.get_name()}}(uint32_t index) const { return {{field.get_variable_name()}}[index]; }
81 inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
82 inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_base_type()}}& value) { {{field.get_variable_name()}}.set(index, value); }
83 inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_base_type()}}&& value) { {{field.get_variable_name()}}.set(index, value); }
84 inline void set_{{field.get_name()}}(const {{field.get_type()}}& values) { {{field.get_variable_name()}} = values; }
85 inline void add_{{field.get_name()}}(const {{field.get_base_type()}}& value) { {{field.get_variable_name()}}.add(value); }
86 inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
87 inline {{field.get_base_type()}}& mutable_{{field.get_name()}}(uint32_t index) { return {{field.get_variable_name()}}[index]; }
88 {% endif %}
89 inline const {{field.get_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}; }
90 inline const {{field.get_type()}}& {{field.get_name()}}() const { return {{field.get_variable_name()}}; }
EmbeddedProto
Definition: Errors.h:34
not
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with Embedded Proto If not
Definition: FieldRepeated_GetSet.h:1