EmbeddedProto 4.0.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. EmbeddedProto/EmbeddedProto.py +122 -0
  2. EmbeddedProto/Features.py +255 -0
  3. EmbeddedProto/Field.py +1295 -0
  4. EmbeddedProto/Oneof.py +74 -0
  5. EmbeddedProto/ProtoFile.py +210 -0
  6. EmbeddedProto/TypeDefinitions.py +367 -0
  7. EmbeddedProto/__init__.py +0 -0
  8. EmbeddedProto/__main__.py +28 -0
  9. EmbeddedProto/config.py +173 -0
  10. EmbeddedProto/custom_header.py +513 -0
  11. EmbeddedProto/embedded_proto_options.proto +62 -0
  12. EmbeddedProto/embedded_proto_options_pb2.py +37 -0
  13. EmbeddedProto/field_options.py +344 -0
  14. EmbeddedProto/main.py +316 -0
  15. EmbeddedProto/src/EmbeddedProto/BytesStringCallback.h +476 -0
  16. EmbeddedProto/src/EmbeddedProto/Defines.h +118 -0
  17. EmbeddedProto/src/EmbeddedProto/EmptyArray.h +81 -0
  18. EmbeddedProto/src/EmbeddedProto/Errors.h +53 -0
  19. EmbeddedProto/src/EmbeddedProto/FieldStringBytes.h +793 -0
  20. EmbeddedProto/src/EmbeddedProto/Fields.h +832 -0
  21. EmbeddedProto/src/EmbeddedProto/Functional.h +412 -0
  22. EmbeddedProto/src/EmbeddedProto/MessageCallback.h +688 -0
  23. EmbeddedProto/src/EmbeddedProto/MessageInterface.h +792 -0
  24. EmbeddedProto/src/EmbeddedProto/MessageSizeCalculator.h +109 -0
  25. EmbeddedProto/src/EmbeddedProto/MessageState.h +207 -0
  26. EmbeddedProto/src/EmbeddedProto/ReadBufferFixedSize.h +204 -0
  27. EmbeddedProto/src/EmbeddedProto/ReadBufferInterface.h +181 -0
  28. EmbeddedProto/src/EmbeddedProto/ReadBufferSection.h +232 -0
  29. EmbeddedProto/src/EmbeddedProto/RepeatedField.h +1053 -0
  30. EmbeddedProto/src/EmbeddedProto/RepeatedFieldCallback.h +432 -0
  31. EmbeddedProto/src/EmbeddedProto/RepeatedFieldFixedSize.h +367 -0
  32. EmbeddedProto/src/EmbeddedProto/Version.h +39 -0
  33. EmbeddedProto/src/EmbeddedProto/WireFormatter.h +852 -0
  34. EmbeddedProto/src/EmbeddedProto/WriteBufferFixedSize.h +114 -0
  35. EmbeddedProto/src/EmbeddedProto/WriteBufferInterface.h +134 -0
  36. EmbeddedProto/src/EmbeddedProto.h +55 -0
  37. EmbeddedProto/templates/FieldBasic_Deserialize.h.jinja2 +26 -0
  38. EmbeddedProto/templates/FieldBasic_GetSet.h.jinja2 +89 -0
  39. EmbeddedProto/templates/FieldBytes_GetSet.h.jinja2 +86 -0
  40. EmbeddedProto/templates/FieldEnum_Deserialize.h.jinja2 +50 -0
  41. EmbeddedProto/templates/FieldEnum_GetSet.h.jinja2 +93 -0
  42. EmbeddedProto/templates/FieldErrorRecursive_GetSet.h.jinja2 +29 -0
  43. EmbeddedProto/templates/FieldMap_GetSet.h.jinja2 +203 -0
  44. EmbeddedProto/templates/FieldMsg_Deserialize.h.jinja2 +44 -0
  45. EmbeddedProto/templates/FieldMsg_GetSet.h.jinja2 +93 -0
  46. EmbeddedProto/templates/FieldRepeated_GetSet.h.jinja2 +94 -0
  47. EmbeddedProto/templates/FieldString_GetSet.h.jinja2 +86 -0
  48. EmbeddedProto/templates/Field_DeserializePartial.h.jinja2 +33 -0
  49. EmbeddedProto/templates/Field_Serialize.h.jinja2 +112 -0
  50. EmbeddedProto/templates/Field_SerializePartial.h.jinja2 +119 -0
  51. EmbeddedProto/templates/Header.h.jinja2 +108 -0
  52. EmbeddedProto/templates/TypeDefEnum.h.jinja2 +45 -0
  53. EmbeddedProto/templates/TypeDefMsg.h.jinja2 +791 -0
  54. EmbeddedProto/templates/TypeOneof.h.jinja2 +178 -0
  55. EmbeddedProto/version.json +3 -0
  56. embeddedproto-4.0.0b1.dist-info/METADATA +141 -0
  57. embeddedproto-4.0.0b1.dist-info/RECORD +63 -0
  58. embeddedproto-4.0.0b1.dist-info/WHEEL +5 -0
  59. embeddedproto-4.0.0b1.dist-info/entry_points.txt +3 -0
  60. embeddedproto-4.0.0b1.dist-info/licenses/LICENSE +30 -0
  61. embeddedproto-4.0.0b1.dist-info/licenses/LICENSES/GPL-3.0-only.txt +674 -0
  62. embeddedproto-4.0.0b1.dist-info/licenses/LICENSES/LicenseRef-EmbeddedProto-Commercial.txt +12 -0
  63. embeddedproto-4.0.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,203 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ {#
24
+ The accessors of a map field. A map is stored as a repeated field of entry messages, this template
25
+ puts the map shaped API on top of that: look a key up, read and write its value and remove it.
26
+
27
+ Key lookup scans the entries backwards. Protobuf requires the last value to win when a key occurs
28
+ more than once, which only a peer can produce; scanning from the back gives that for free without
29
+ touching the deserialize path.
30
+
31
+ A map streaming its entries through callbacks holds no entries to search, so it only exposes the
32
+ binding accessors.
33
+ #}
34
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
35
+ {% if field.has_callback_storage() %}
36
+ {# Streaming storage: entries flow through the bound source and sink one at a time, there is no
37
+ resident collection to look a key up in. #}
38
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
39
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs) { {{field.get_variable_name()}}.set(rhs); }
40
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
41
+ {% else %}
42
+ //! The number of entries currently held in this map.
43
+ inline uint32_t {{field.get_name()}}_size() const { return {{field.get_variable_name()}}.get_length(); }
44
+
45
+ //! The number of entries this map can at most hold.
46
+ inline uint32_t {{field.get_name()}}_max_size() const { return {{field.get_variable_name()}}.get_max_length(); }
47
+
48
+ //! Return the index of the entry with the given key, or the number of entries when the key is absent.
49
+ /*!
50
+ The entries are scanned backwards so the last entry with this key is found first. That is what
51
+ protobuf prescribes when a peer sends the same key more than once.
52
+ */
53
+ inline uint32_t find_{{field.get_name()}}({{field.get_key_param_type()}} key) const
54
+ {
55
+ uint32_t index = {{field.get_variable_name()}}.get_length();
56
+ bool found = false;
57
+ while((0U < index) && !found)
58
+ {
59
+ --index;
60
+ found = ({{field.get_variable_name()}}.get_const(index).get_key() == key);
61
+ }
62
+ return found ? index : {{field.get_variable_name()}}.get_length();
63
+ }
64
+
65
+ //! Is there an entry with the given key in this map?
66
+ inline bool has_{{field.get_name()}}({{field.get_key_param_type()}} key) const
67
+ {
68
+ return find_{{field.get_name()}}(key) < {{field.get_variable_name()}}.get_length();
69
+ }
70
+ {% if field.value_is_returned_by_value() %}
71
+
72
+ //! Return the value stored under the given key, or the default value when the key is absent.
73
+ {% if field.value_is_string() %}
74
+ /*!
75
+ The returned pointer points into this message and stays valid until the entry is changed or
76
+ removed. An absent key yields an empty string.
77
+ */
78
+ {% endif %}
79
+ inline {{field.get_value_return_type()}} get_{{field.get_name()}}({{field.get_key_param_type()}} key) const
80
+ {
81
+ {{field.get_value_return_type()}} result = {{field.get_value_absent_default()}};
82
+ const uint32_t index = find_{{field.get_name()}}(key);
83
+ if(index < {{field.get_variable_name()}}.get_length())
84
+ {
85
+ result = {{field.get_value_read_expression(field.get_variable_name() + ".get_const(index)")}};
86
+ }
87
+ return result;
88
+ }
89
+ {% endif %}
90
+
91
+ //! Copy the value stored under the given key into the given object.
92
+ /*!
93
+ \param[in] key The key to look up.
94
+ \param[out] value Written only when the key is present.
95
+ \return NO_ERRORS when the key was found, INDEX_OUT_OF_BOUND when it is absent.
96
+ */
97
+ inline ::EmbeddedProto::Error get_{{field.get_name()}}({{field.get_key_param_type()}} key, {{field.get_value_out_type()}}& value) const
98
+ {
99
+ ::EmbeddedProto::Error return_value = ::EmbeddedProto::Error::INDEX_OUT_OF_BOUND;
100
+ const uint32_t index = find_{{field.get_name()}}(key);
101
+ if(index < {{field.get_variable_name()}}.get_length())
102
+ {
103
+ value = {{field.get_variable_name()}}.get_const(index).get_value();
104
+ return_value = ::EmbeddedProto::Error::NO_ERRORS;
105
+ }
106
+ return return_value;
107
+ }
108
+
109
+ //! Store the given value under the given key, replacing the value when the key is already present.
110
+ /*!
111
+ \param[in] key The key to store the value under.
112
+ \param[in] value The value to store.
113
+ \return NO_ERRORS when stored. ARRAY_FULL when the key is new and the map is full, or when a
114
+ string key or value is longer than its maximum; the map is then left unchanged.
115
+ */
116
+ inline ::EmbeddedProto::Error set_{{field.get_name()}}({{field.get_key_param_type()}} key, {{field.get_value_param_type()}} value)
117
+ {
118
+ ::EmbeddedProto::Error return_value = ::EmbeddedProto::Error::NO_ERRORS;
119
+ {% if field.key_is_string() or field.value_is_string() %}
120
+ // A string longer than its maximum would be stored cut short: a key that could never be found
121
+ // again, or a value that silently differs from what was given. Refuse either before anything is
122
+ // touched, so a rejected call leaves the map exactly as it was.
123
+ {% endif %}
124
+ {% if field.key_is_string() %}
125
+ if(!{{field.get_key_field().get_type()}}::fits(key))
126
+ {
127
+ return_value = ::EmbeddedProto::Error::ARRAY_FULL;
128
+ }
129
+ {% endif %}
130
+ {% if field.value_is_string() %}
131
+ if(!{{field.get_value_field().get_type()}}::fits(value))
132
+ {
133
+ return_value = ::EmbeddedProto::Error::ARRAY_FULL;
134
+ }
135
+ {% endif %}
136
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
137
+ {
138
+ const uint32_t index = find_{{field.get_name()}}(key);
139
+ if(index < {{field.get_variable_name()}}.get_length())
140
+ {
141
+ {{field.get_value_assign_statement(field.get_variable_name() + "[index]", "value")}}
142
+ }
143
+ else
144
+ {
145
+ {{field.get_entry_type()}} entry;
146
+ {{field.get_key_assign_statement("entry", "key")}}
147
+ {{field.get_value_assign_statement("entry", "value")}}
148
+ return_value = {{field.get_variable_name()}}.add(entry);
149
+ }
150
+ }
151
+ return return_value;
152
+ }
153
+
154
+ //! Remove the entry with the given key from this map.
155
+ /*!
156
+ Every entry with this key is removed, a peer may have sent the same key more than once.
157
+
158
+ \param[in] key The key to remove.
159
+ \return NO_ERRORS when at least one entry was removed, INDEX_OUT_OF_BOUND when the key is absent.
160
+ */
161
+ inline ::EmbeddedProto::Error remove_{{field.get_name()}}({{field.get_key_param_type()}} key)
162
+ {
163
+ ::EmbeddedProto::Error return_value = ::EmbeddedProto::Error::INDEX_OUT_OF_BOUND;
164
+ bool more = true;
165
+ while(more)
166
+ {
167
+ const uint32_t index = find_{{field.get_name()}}(key);
168
+ if(index < {{field.get_variable_name()}}.get_length())
169
+ {
170
+ more = (::EmbeddedProto::Error::NO_ERRORS == {{field.get_variable_name()}}.erase(index));
171
+ if(more)
172
+ {
173
+ return_value = ::EmbeddedProto::Error::NO_ERRORS;
174
+ }
175
+ }
176
+ else
177
+ {
178
+ more = false;
179
+ }
180
+ }
181
+ return return_value;
182
+ }
183
+
184
+ //! Remove all entries from this map.
185
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
186
+
187
+ //! Access one entry by index, to iterate over the map.
188
+ inline const {{field.get_entry_type()}}& {{field.get_name()}}(uint32_t index) const { return {{field.get_variable_name()}}[index]; }
189
+
190
+ //! Access one entry by index for modification, to iterate over the map.
191
+ inline {{field.get_entry_type()}}& mutable_{{field.get_name()}}(uint32_t index) { return {{field.get_variable_name()}}[index]; }
192
+
193
+ //! Append an entry as is, without checking whether its key is already present.
194
+ inline ::EmbeddedProto::Error add_{{field.get_name()}}(const {{field.get_entry_type()}}& value) { return {{field.get_variable_name()}}.add(value); }
195
+
196
+ //! Replace all entries at once, used among others by the copy constructor.
197
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& values) { {{field.get_variable_name()}} = values; }
198
+
199
+ //! Access the entries as the repeated field they are stored in.
200
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
201
+ {% endif %}
202
+ inline const {{field.get_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}; }
203
+ inline const {{field.get_type()}}& {{field.get_name()}}() const { return {{field.get_variable_name()}}; }
@@ -0,0 +1,44 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ {% if field.is_delimited() %}
24
+ {# DELIMITED message_encoding: the field must arrive framed as a START_GROUP tag.
25
+ Reject any other wire type instead of misreading the bytes as group content.
26
+ When valid, the inner fields are decoded until the matching END_GROUP (consumed
27
+ by the nested deserialize). #}
28
+ if(::EmbeddedProto::WireFormatter::WireType::START_GROUP == deserialize_wire_type_)
29
+ {
30
+ {% if field.optional %}
31
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
32
+ {% endif %}
33
+ return_value = {{field.get_variable_name()}}.deserialize(buffer);
34
+ }
35
+ else
36
+ {
37
+ return_value = ::EmbeddedProto::Error::INVALID_WIRETYPE;
38
+ }
39
+ {% else %}
40
+ {% if field.optional %}
41
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
42
+ {% endif %}
43
+ return_value = {{field.get_variable_name()}}.deserialize_check_type(buffer, deserialize_wire_type_);
44
+ {% endif %}
@@ -0,0 +1,93 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
24
+ {% if field.oneof is not none %}
25
+ inline bool has_{{field.get_name()}}() const
26
+ {
27
+ return FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}};
28
+ }
29
+ inline void clear_{{field.get_name()}}()
30
+ {
31
+ if(FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
32
+ {
33
+ {{field.get_which_oneof()}} = FieldNumber::NOT_SET;
34
+ ::EmbeddedProto::destroy_at(&{{field.get_variable_name()}});
35
+ }
36
+ }
37
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& value)
38
+ {
39
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
40
+ {
41
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
42
+ }
43
+ {{field.get_variable_name()}} = value;
44
+ }
45
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}&& value)
46
+ {
47
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
48
+ {
49
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
50
+ }
51
+ {{field.get_variable_name()}} = value;
52
+ }
53
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}()
54
+ {
55
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
56
+ {
57
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
58
+ }
59
+ return {{field.get_variable_name()}};
60
+ }
61
+ {% elif field.optional %}
62
+ inline bool has_{{field.get_name()}}() const
63
+ {
64
+ return 0 != (presence::mask(presence::fields::{{field.get_name().upper()}}) & presence_[presence::index(presence::fields::{{field.get_name().upper()}})]);
65
+ }
66
+ inline void clear_{{field.get_name()}}()
67
+ {
68
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] &= ~(presence::mask(presence::fields::{{field.get_name().upper()}}));
69
+ {{field.get_variable_name()}}.clear();
70
+ }
71
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& value)
72
+ {
73
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
74
+ {{field.get_variable_name()}} = value;
75
+ }
76
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}&& value)
77
+ {
78
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
79
+ {{field.get_variable_name()}} = value;
80
+ }
81
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}()
82
+ {
83
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
84
+ return {{field.get_variable_name()}};
85
+ }
86
+ {% else %}
87
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
88
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& value) { {{field.get_variable_name()}} = value; }
89
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}&& value) { {{field.get_variable_name()}} = value; }
90
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
91
+ {% endif %}
92
+ inline const {{field.get_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}; }
93
+ inline const {{field.get_type()}}& {{field.get_name()}}() const { return {{field.get_variable_name()}}; }
@@ -0,0 +1,94 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
24
+ {% if field.oneof is not none %}
25
+ inline bool has_{{field.get_name()}}() const
26
+ {
27
+ return FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}};
28
+ }
29
+ inline void clear_{{field.get_name()}}()
30
+ {
31
+ if(FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
32
+ {
33
+ {{field.get_which_oneof()}} = FieldNumber::NOT_SET;
34
+ ::EmbeddedProto::destroy_at(&{{field.get_variable_name()}});
35
+ }
36
+ }
37
+ inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_type()}}& value)
38
+ {
39
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
40
+ {
41
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
42
+ }
43
+ {{field.get_variable_name()}}.set(index, value);
44
+ }
45
+ inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_type()}}&& value)
46
+ {
47
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
48
+ {
49
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
50
+ }
51
+ {{field.get_variable_name()}}.set(index, value);
52
+ }
53
+ inline void set_{{field.get_name()}}(const {{field.repeated_type}}& values)
54
+ {
55
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
56
+ {
57
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
58
+ }
59
+ {{field.get_variable_name()}} = values;
60
+ }
61
+ inline void add_{{field.get_name()}}(const {{field.get_type()}}& value)
62
+ {
63
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
64
+ {
65
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
66
+ }
67
+ {{field.get_variable_name()}}.add(value);
68
+ }
69
+ inline {{field.repeated_type}}& mutable_{{field.get_name()}}()
70
+ {
71
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
72
+ {
73
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
74
+ }
75
+ return {{field.get_variable_name()}};
76
+ }
77
+ {% elif field.callback_is_message() %}
78
+ {# A repeated message callback owns no element array: it streams through bound source/sink handles.
79
+ Only the whole-field accessors are emitted (no indexed get/set/add); set_ copies the bindings. #}
80
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
81
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs) { {{field.get_variable_name()}}.set(rhs); }
82
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
83
+ {% else %}
84
+ inline const {{field.get_base_type()}}& {{field.get_name()}}(uint32_t index) const { return {{field.get_variable_name()}}[index]; }
85
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
86
+ inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_base_type()}}& value) { {{field.get_variable_name()}}.set(index, value); }
87
+ inline void set_{{field.get_name()}}(uint32_t index, const {{field.get_base_type()}}&& value) { {{field.get_variable_name()}}.set(index, value); }
88
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& values) { {{field.get_variable_name()}} = values; }
89
+ inline void add_{{field.get_name()}}(const {{field.get_base_type()}}& value) { {{field.get_variable_name()}}.add(value); }
90
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
91
+ inline {{field.get_base_type()}}& mutable_{{field.get_name()}}(uint32_t index) { return {{field.get_variable_name()}}[index]; }
92
+ {% endif %}
93
+ inline const {{field.get_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}; }
94
+ inline const {{field.get_type()}}& {{field.get_name()}}() const { return {{field.get_variable_name()}}; }
@@ -0,0 +1,86 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
24
+ {% if field.oneof is not none %}
25
+ inline bool has_{{field.get_name()}}() const
26
+ {
27
+ return FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}};
28
+ }
29
+ inline void clear_{{field.get_name()}}()
30
+ {
31
+ if(FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
32
+ {
33
+ {{field.get_which_oneof()}} = FieldNumber::NOT_SET;
34
+ ::EmbeddedProto::destroy_at(&{{field.get_variable_name()}});
35
+ }
36
+ }
37
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}()
38
+ {
39
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
40
+ {
41
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
42
+ }
43
+ return {{field.get_variable_name()}};
44
+ }
45
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs)
46
+ {
47
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
48
+ {
49
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
50
+ }
51
+ {{field.get_variable_name()}}.set(rhs);
52
+ }
53
+ {% elif field.optional %}
54
+ inline bool has_{{field.get_name()}}() const
55
+ {
56
+ return 0 != (presence::mask(presence::fields::{{field.get_name().upper()}}) & presence_[presence::index(presence::fields::{{field.get_name().upper()}})]);
57
+ }
58
+ inline void clear_{{field.get_name()}}()
59
+ {
60
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] &= ~(presence::mask(presence::fields::{{field.get_name().upper()}}));
61
+ {{field.get_variable_name()}}.clear();
62
+ }
63
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}()
64
+ {
65
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
66
+ return {{field.get_variable_name()}};
67
+ }
68
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs)
69
+ {
70
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
71
+ {{field.get_variable_name()}}.set(rhs);
72
+ }
73
+ {% else %}
74
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
75
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
76
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs) { {{field.get_variable_name()}}.set(rhs); }
77
+ {% endif %}
78
+ inline const {{field.get_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}; }
79
+ {% if field.has_callback_storage() %}
80
+ inline void set_{{field.get_name()}}_on_serialize_chunk(const {{field.get_type()}}::ChunkCallback& callback) { {{field.get_variable_name()}}.set_on_serialize_chunk(callback); }
81
+ inline void set_{{field.get_name()}}_on_deserialize_chunk(const {{field.get_type()}}::ChunkCallback& callback) { {{field.get_variable_name()}}.set_on_deserialize_chunk(callback); }
82
+ inline void set_{{field.get_name()}}_window(const {{field.get_type()}}::VIEW& window) { {{field.get_variable_name()}}.set_window(window); }
83
+ inline void set_{{field.get_name()}}_length(const uint32_t length) { {{field.get_variable_name()}}.set_length(length); }
84
+ {% else %}
85
+ inline const char* {{field.get_name()}}() const { return {{field.get_variable_name()}}.get_const(); }
86
+ {% endif %}
@@ -0,0 +1,33 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ {% if field.optional %}
24
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
25
+ {% endif %}
26
+ {% if field.is_delimited() %}
27
+ return_value = {{field.get_variable_name()}}.deserialize_partial_as_group(buffer, state);
28
+ {% elif field.uses_serialize_len() %}
29
+ return_value = {{field.get_variable_name()}}.deserialize_partial_as_field(buffer, state);
30
+ {% else %}
31
+ return_value = {{field.get_variable_name()}}.deserialize_partial_check_type(
32
+ buffer, state, ::EmbeddedProto::WireFormatter::WireType::{{field.get_wire_type_str()}});
33
+ {% endif %}
@@ -0,0 +1,112 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ {# Unified serialize template for all field types.
24
+ - Basic types and enums use serialize_with_id() (FieldTemplate)
25
+ - Messages, strings, bytes use serialize_len()
26
+ - Packed repeated fields use serialize_len()
27
+ - Unpacked repeated fields iterate and call serialize_len() on each element
28
+ #}
29
+ {% if field.uses_serialize_len() %}
30
+ {# Field types that use serialize_len(): messages, strings, bytes, repeated #}
31
+ {% if field.callback_is_len_expanded() %}
32
+ {# Map callback storage: pull each entry from the bound source and emit it length delimited, the same framing a resident map uses. #}
33
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
34
+ {
35
+ return_value = {{field.get_variable_name()}}.serialize_expanded_len(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer);
36
+ }
37
+ {% elif field.callback_is_expanded() %}
38
+ {# Repeated callback storage: pull elements from the bound source and emit each EXPANDED (one tag+value per element) in a single call. #}
39
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
40
+ {
41
+ return_value = {{field.get_variable_name()}}.serialize_expanded(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer);
42
+ }
43
+ {% elif field.is_packed is defined and not field.is_packed() and field.element_is_length_delimited() %}
44
+ {# Unpacked repeated message/string/bytes field - iterate over elements. Use true for optional so empty elements are still serialized. #}
45
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
46
+ {
47
+ for(uint32_t i = 0; (i < {{field.get_variable_name()}}.get_length()) && (::EmbeddedProto::Error::NO_ERRORS == return_value); ++i)
48
+ {
49
+ return_value = {{field.get_variable_name()}}.get_const(i).serialize_len(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), {{field.get_variable_name()}}.get_const(i).serialized_size(), buffer, true);
50
+ }
51
+ }
52
+ {% elif field.is_packed is defined and not field.is_packed() %}
53
+ {# Expanded (EXPANDED feature) repeated scalar/enum field - one tag+value per element. #}
54
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
55
+ {
56
+ for(uint32_t i = 0; (i < {{field.get_variable_name()}}.get_length()) && (::EmbeddedProto::Error::NO_ERRORS == return_value); ++i)
57
+ {
58
+ return_value = {{field.get_variable_name()}}.get_const(i).serialize_with_id(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, true);
59
+ }
60
+ }
61
+ {% elif (field.optional or (field.oneof is not none)) %}
62
+ if(has_{{field.get_name()}}() && (::EmbeddedProto::Error::NO_ERRORS == return_value))
63
+ {
64
+ {% if field.is_delimited() %}
65
+ {# DELIMITED message_encoding: single-pass group framing, no size pre-pass. #}
66
+ return_value = {{field.get_variable_name()}}.serialize_as_group(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer);
67
+ {% else %}
68
+ return_value = {{field.get_variable_name()}}.serialize_len(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), {{field.get_size_expression()}}, buffer, true);
69
+ {% endif %}
70
+ }
71
+ {% elif field.always_serialize %}
72
+ {# LEGACY_REQUIRED field: always serialize, even at the default value. #}
73
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
74
+ {
75
+ {% if field.is_delimited() %}
76
+ return_value = {{field.get_variable_name()}}.serialize_as_group(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer);
77
+ {% else %}
78
+ return_value = {{field.get_variable_name()}}.serialize_len(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), {{field.get_size_expression()}}, buffer, true);
79
+ {% endif %}
80
+ }
81
+ {% elif field.is_delimited() %}
82
+ {# DELIMITED message_encoding on an implicit-presence message field. #}
83
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
84
+ {
85
+ return_value = {{field.get_variable_name()}}.serialize_as_group(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer);
86
+ }
87
+ {% else %}
88
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
89
+ {
90
+ return_value = {{field.get_variable_name()}}.serialize_len(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), {{field.get_size_expression()}}, buffer, false);
91
+ }
92
+ {% endif %}
93
+ {% else %}
94
+ {# Basic types and enums use serialize_with_id() #}
95
+ {% if (field.optional or (field.oneof is not none)) %}
96
+ if(has_{{field.get_name()}}() && (::EmbeddedProto::Error::NO_ERRORS == return_value))
97
+ {
98
+ return_value = {{field.get_variable_name()}}.serialize_with_id(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, true);
99
+ }
100
+ {% elif field.always_serialize %}
101
+ {# LEGACY_REQUIRED field: always serialize, even at the default value. #}
102
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
103
+ {
104
+ return_value = {{field.get_variable_name()}}.serialize_with_id(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, true);
105
+ }
106
+ {% else %}
107
+ if(::EmbeddedProto::Error::NO_ERRORS == return_value)
108
+ {
109
+ return_value = {{field.get_variable_name()}}.serialize_with_id(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, false);
110
+ }
111
+ {% endif %}
112
+ {% endif %}