EmbeddedProto 4.0.0.dev19__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 (34) hide show
  1. EmbeddedProto/EmbeddedProto.py +63 -0
  2. EmbeddedProto/Field.py +578 -0
  3. EmbeddedProto/Oneof.py +78 -0
  4. EmbeddedProto/ProtoFile.py +188 -0
  5. EmbeddedProto/TypeDefinitions.py +255 -0
  6. EmbeddedProto/__init__.py +0 -0
  7. EmbeddedProto/__main__.py +35 -0
  8. EmbeddedProto/embedded_proto_options_pb2.py +37 -0
  9. EmbeddedProto/main.py +199 -0
  10. EmbeddedProto/templates/FieldBasic_Deserialize.h.jinja2 +33 -0
  11. EmbeddedProto/templates/FieldBasic_GetSet.h.jinja2 +92 -0
  12. EmbeddedProto/templates/FieldBasic_Serialize.h.jinja2 +37 -0
  13. EmbeddedProto/templates/FieldBytes_GetSet.h.jinja2 +86 -0
  14. EmbeddedProto/templates/FieldEnum_Deserialize.h.jinja2 +33 -0
  15. EmbeddedProto/templates/FieldEnum_GetSet.h.jinja2 +86 -0
  16. EmbeddedProto/templates/FieldEnum_Serialize.h.jinja2 +37 -0
  17. EmbeddedProto/templates/FieldErrorRecursive_GetSet.h.jinja2 +36 -0
  18. EmbeddedProto/templates/FieldMsg_Deserialize.h.jinja2 +33 -0
  19. EmbeddedProto/templates/FieldMsg_GetSet.h.jinja2 +100 -0
  20. EmbeddedProto/templates/FieldMsg_Serialize.h.jinja2 +37 -0
  21. EmbeddedProto/templates/FieldRepeated_GetSet.h.jinja2 +95 -0
  22. EmbeddedProto/templates/FieldRepeated_Serialize.h.jinja2 +33 -0
  23. EmbeddedProto/templates/FieldStringBytes_Serialize.h.jinja2 +37 -0
  24. EmbeddedProto/templates/FieldString_GetSet.h.jinja2 +86 -0
  25. EmbeddedProto/templates/Header.h.jinja2 +75 -0
  26. EmbeddedProto/templates/TypeDefEnum.h.jinja2 +35 -0
  27. EmbeddedProto/templates/TypeDefMsg.h.jinja2 +473 -0
  28. EmbeddedProto/templates/TypeOneof.h.jinja2 +180 -0
  29. EmbeddedProto/version.json +3 -0
  30. EmbeddedProto-4.0.0.dev19.dist-info/METADATA +210 -0
  31. EmbeddedProto-4.0.0.dev19.dist-info/RECORD +34 -0
  32. EmbeddedProto-4.0.0.dev19.dist-info/WHEEL +5 -0
  33. EmbeddedProto-4.0.0.dev19.dist-info/entry_points.txt +3 -0
  34. EmbeddedProto-4.0.0.dev19.dist-info/top_level.txt +1 -0
EmbeddedProto/main.py ADDED
@@ -0,0 +1,199 @@
1
+ #
2
+ # Copyright (C) 2020-2024 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/pricing/>.
20
+ #
21
+ # Embedded AMS B.V.
22
+ # Info:
23
+ # info at EmbeddedProto dot com
24
+ #
25
+ # Postal address:
26
+ # Atoomweg 2
27
+ # 1627 LE, Hoorn
28
+ # the Netherlands
29
+ #
30
+
31
+ import io
32
+ import sys
33
+ from EmbeddedProto.ProtoFile import ProtoFile
34
+ from google.protobuf.compiler import plugin_pb2 as plugin
35
+ import jinja2
36
+ from importlib.resources import path as resource_path
37
+
38
+
39
+ # -----------------------------------------------------------------------------
40
+
41
+
42
+ def generate_code(request, respones):
43
+ # Create definitions for al proto files in the request except for our own options file which is not required in cpp
44
+ # code. First also ignore the google descriptor file, only add it later if it is required by the user.
45
+ file_definitions = []
46
+ google_descriptor_file = None
47
+ add_google_descriptor_file = False
48
+ for proto_file in request.proto_file:
49
+ if ("embedded_proto_options.proto" not in proto_file.name) and \
50
+ ("google/protobuf/descriptor.proto" not in proto_file.name):
51
+ file_definitions.append(ProtoFile(proto_file))
52
+ if "google/protobuf/descriptor.proto" in file_definitions[-1].descriptor.dependency:
53
+ add_google_descriptor_file = True
54
+
55
+ # If we come by the descriptor just store it so we can easily use it when needed.
56
+ if "google/protobuf/descriptor.proto" in proto_file.name:
57
+ google_descriptor_file = proto_file
58
+
59
+ # See if we should include google/protobuf/descriptor.proto after all as it is directly include by one of user
60
+ # defined proto files.
61
+ if add_google_descriptor_file and google_descriptor_file:
62
+ # Insert it at the front so the header file will include it before the classes requiring it.
63
+ file_definitions.insert(0, ProtoFile(google_descriptor_file))
64
+
65
+ # Obtain all definitions made in all the files to properly link definitions with fields using them. This to properly
66
+ # create template parameters.
67
+ all_types_definitions = {"enums": [], "messages": []}
68
+ for fd in file_definitions:
69
+ nt = fd.get_all_nested_types()
70
+ all_types_definitions["enums"].extend(nt["enums"])
71
+ all_types_definitions["messages"].extend(nt["messages"])
72
+
73
+ # Match all fields with their respective type definition.
74
+ for fd in file_definitions:
75
+ fd.match_fields_with_definitions(all_types_definitions)
76
+
77
+ # Add template parameters to the fields that need them.
78
+ all_parameters_registered = True
79
+ for _ in range(3):
80
+ for fd in file_definitions:
81
+ all_parameters_registered = fd.register_template_parameters() and all_parameters_registered
82
+ if all_parameters_registered:
83
+ break
84
+
85
+ if not all_parameters_registered:
86
+ raise Exception("Messages with repeated, string or byte fields use template parameters to define their length."
87
+ "For some reason it was not to add all required template parameters.")
88
+
89
+ with resource_path("EmbeddedProto", "templates") as filepath:
90
+ template_loader = jinja2.FileSystemLoader(searchpath=filepath)
91
+ template_env = jinja2.Environment(loader=template_loader, trim_blocks=True, lstrip_blocks=True)
92
+
93
+ for fd in file_definitions:
94
+ file_str = fd.render(template_env)
95
+ if file_str:
96
+ f = respones.file.add()
97
+ f.name = fd.filename_with_folder + ".h"
98
+ f.content = file_str
99
+ else:
100
+ break
101
+
102
+
103
+ # -----------------------------------------------------------------------------
104
+
105
+ def main_plugin():
106
+ # The main function when running the scrip as a protoc plugin. It will read in the protoc data from the stdin and
107
+ # write back the output to stdout.
108
+
109
+ # Create the response object
110
+ response = plugin.CodeGeneratorResponse()
111
+ response.supported_features = plugin.CodeGeneratorResponse.FEATURE_PROTO3_OPTIONAL
112
+
113
+ # Read request message from stdin
114
+ data = io.open(sys.stdin.fileno(), "rb").read()
115
+ request = plugin.CodeGeneratorRequest.FromString(data)
116
+
117
+ # If desired output debug data.
118
+ if '--debug' in sys.argv:
119
+ # Write the requests to a file for easy debugging.
120
+ with open("./debug_embedded_proto.bin", 'wb') as file:
121
+ file.write(request.SerializeToString())
122
+
123
+ from google.protobuf.json_format import MessageToJson
124
+
125
+ with open("./debug_embedded_proto.json", 'w') as file:
126
+ file.write(MessageToJson(request))
127
+
128
+ # Generate code
129
+ try:
130
+ generate_code(request, response)
131
+ except jinja2.UndefinedError as e:
132
+ response.error = "Embedded Proto ERROR - Template Undefined Error exception: " + str(e)
133
+ except jinja2.TemplateRuntimeError as e:
134
+ response.error = "Embedded Proto ERROR - Template Runtime Error exception: " + str(e)
135
+ except jinja2.TemplateAssertionError as e:
136
+ response.error = "Embedded Proto ERROR - TemplateAssertionError exception: " + str(e)
137
+ except jinja2.TemplateSyntaxError as e:
138
+ response.error = "Embedded Proto ERROR - TemplateSyntaxError exception: " + str(e)
139
+ except jinja2.TemplateError as e:
140
+ response.error = "Embedded Proto ERROR - TemplateError exception: " + str(e)
141
+ except Exception as e:
142
+ response.error = "Embedded Proto ERROR - " + str(e)
143
+
144
+ # Serialize response message
145
+ output = response.SerializeToString()
146
+
147
+ # Write to stdout
148
+ io.open(sys.stdout.fileno(), "wb").write(output)
149
+
150
+
151
+ # -----------------------------------------------------------------------------
152
+
153
+ def main_cli():
154
+ # The main function when running from the command line and debugging. Instead of receiving data from protoc this
155
+ # will read in a binary file stored the previous time main_plugin() is ran.
156
+
157
+ with open("debug_embedded_proto.bin", 'rb') as file:
158
+ # Create the response object
159
+ response = plugin.CodeGeneratorResponse()
160
+ response.supported_features = plugin.CodeGeneratorResponse.FEATURE_PROTO3_OPTIONAL
161
+
162
+ data = file.read()
163
+ request = plugin.CodeGeneratorRequest.FromString(data)
164
+
165
+ # Generate code
166
+ try:
167
+ generate_code(request, response)
168
+ except jinja2.UndefinedError as e:
169
+ response.error = "Embedded Proto ERROR - Template Undefined Error exception: " + str(e)
170
+ except jinja2.TemplateRuntimeError as e:
171
+ response.error = "Embedded Proto ERROR - Template Runtime Error exception: " + str(e)
172
+ except jinja2.TemplateAssertionError as e:
173
+ response.error = "Embedded Proto ERROR - TemplateAssertionError exception: " + str(e)
174
+ except jinja2.TemplateSyntaxError as e:
175
+ response.error = "Embedded Proto ERROR - TemplateSyntaxError exception: " + str(e)
176
+ except jinja2.TemplateError as e:
177
+ response.error = "Embedded Proto ERROR - TemplateError exception: " + str(e)
178
+ except Exception as e:
179
+ response.error = "Embedded Proto ERROR - " + str(e)
180
+
181
+ # For debugging purposes print the result to the console.
182
+ for response_file in response.file:
183
+ print(response_file.name)
184
+ print(response_file.content)
185
+
186
+ if response.error:
187
+ print(response.error)
188
+
189
+ # -----------------------------------------------------------------------------
190
+ def main():
191
+ # Check if we are running as a plugin under protoc
192
+ if '--protoc-plugin' in sys.argv:
193
+ main_plugin()
194
+ else:
195
+ main_cli()
196
+
197
+ # -----------------------------------------------------------------------------
198
+ if __name__ == "__main__":
199
+ main()
@@ -0,0 +1,33 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
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_check_type(buffer, wire_type);
@@ -0,0 +1,92 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
29
+ #}
30
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
31
+ {% if field.oneof is not none %}
32
+ inline bool has_{{field.get_name()}}() const
33
+ {
34
+ return FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}};
35
+ }
36
+ inline void clear_{{field.get_name()}}()
37
+ {
38
+ if(FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
39
+ {
40
+ {{field.get_which_oneof()}} = FieldNumber::NOT_SET;
41
+ ::EmbeddedProto::destroy_at(&{{field.get_variable_name()}});
42
+ }
43
+ }
44
+ inline void set_{{field.get_name()}}(const {{field.get_cstdint_type()}}& value)
45
+ {
46
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
47
+ {
48
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
49
+ }
50
+ {{field.get_variable_name()}} = value;
51
+ }
52
+ inline void set_{{field.get_name()}}(const {{field.get_cstdint_type()}}&& value)
53
+ {
54
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
55
+ {
56
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
57
+ }
58
+ {{field.get_variable_name()}} = value;
59
+ }
60
+ {% elif field.optional %}
61
+ inline bool has_{{field.get_name()}}() const
62
+ {
63
+ return 0 != (presence::mask(presence::fields::{{field.get_name().upper()}}) & presence_[presence::index(presence::fields::{{field.get_name().upper()}})]);
64
+ }
65
+ inline void clear_{{field.get_name()}}()
66
+ {
67
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] &= ~(presence::mask(presence::fields::{{field.get_name().upper()}}));
68
+ {{field.get_variable_name()}}.clear();
69
+ }
70
+ inline void set_{{field.get_name()}}(const {{field.get_cstdint_type()}}& value)
71
+ {
72
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
73
+ {{field.get_variable_name()}} = value;
74
+ }
75
+ inline void set_{{field.get_name()}}(const {{field.get_cstdint_type()}}&& value)
76
+ {
77
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
78
+ {{field.get_variable_name()}} = value;
79
+ }
80
+ inline {{field.get_cstdint_type()}}& mutable_{{field.get_name()}}()
81
+ {
82
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
83
+ return {{field.get_variable_name()}}.get();
84
+ }
85
+ {% else %}
86
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
87
+ inline void set_{{field.get_name()}}(const {{field.get_cstdint_type()}}& value) { {{field.get_variable_name()}} = value; }
88
+ inline void set_{{field.get_name()}}(const {{field.get_cstdint_type()}}&& value) { {{field.get_variable_name()}} = value; }
89
+ inline {{field.get_cstdint_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}.get(); }
90
+ {% endif %}
91
+ inline const {{field.get_cstdint_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}.get(); }
92
+ inline {{field.get_cstdint_type()}} {{field.get_name()}}() const { return {{field.get_variable_name()}}.get(); }
@@ -0,0 +1,37 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
29
+ #}
30
+ {% if (field.optional or (field.oneof is not none)) %}
31
+ if(has_{{field.get_name()}}() && (::EmbeddedProto::Error::NO_ERRORS == return_value))
32
+ {% else %}
33
+ if(({{field.get_default_value()}} != {{field.get_variable_name()}}.get()) && (::EmbeddedProto::Error::NO_ERRORS == return_value))
34
+ {% endif %}
35
+ {
36
+ return_value = {{field.get_variable_name()}}.serialize_with_id(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, {{ "true" if (field.optional or (field.oneof is not none)) else "false" }});
37
+ }
@@ -0,0 +1,86 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
29
+ #}
30
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
31
+ {% if field.oneof is not none %}
32
+ inline bool has_{{field.get_name()}}() const
33
+ {
34
+ return FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}};
35
+ }
36
+ inline void clear_{{field.get_name()}}()
37
+ {
38
+ if(FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
39
+ {
40
+ {{field.get_which_oneof()}} = FieldNumber::NOT_SET;
41
+ {{field.get_variable_name()}}.~{{field.get_short_type()}}();
42
+ }
43
+ }
44
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}()
45
+ {
46
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
47
+ {
48
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
49
+ }
50
+ return {{field.get_variable_name()}};
51
+ }
52
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs)
53
+ {
54
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
55
+ {
56
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
57
+ }
58
+ {{field.get_variable_name()}}.set(rhs);
59
+ }
60
+ {% elif field.optional %}
61
+ inline bool has_{{field.get_name()}}() const
62
+ {
63
+ return 0 != (presence::mask(presence::fields::{{field.get_name().upper()}}) & presence_[presence::index(presence::fields::{{field.get_name().upper()}})]);
64
+ }
65
+ inline void clear_{{field.get_name()}}()
66
+ {
67
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] &= ~(presence::mask(presence::fields::{{field.get_name().upper()}}));
68
+ {{field.get_variable_name()}}.clear();
69
+ }
70
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}()
71
+ {
72
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
73
+ return {{field.get_variable_name()}};
74
+ }
75
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs)
76
+ {
77
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
78
+ {{field.get_variable_name()}}.set(rhs);
79
+ }
80
+ {% else %}
81
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
82
+ inline {{field.get_type()}}& mutable_{{field.get_name()}}() { return {{field.get_variable_name()}}; }
83
+ inline void set_{{field.get_name()}}(const {{field.get_type()}}& rhs) { {{field.get_variable_name()}}.set(rhs); }
84
+ {% endif %}
85
+ inline const {{field.get_type()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}; }
86
+ inline const uint8_t* {{field.get_name()}}() const { return {{field.get_variable_name()}}.get_const(); }
@@ -0,0 +1,33 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
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_check_type(buffer, wire_type);
@@ -0,0 +1,86 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
29
+ #}
30
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
31
+ {% if field.oneof is not none %}
32
+ inline bool has_{{field.get_name()}}() const
33
+ {
34
+ return FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}};
35
+ }
36
+ inline void clear_{{field.get_name()}}()
37
+ {
38
+ if(FieldNumber::{{field.get_variable_id_name()}} == {{field.get_which_oneof()}})
39
+ {
40
+ {{field.get_which_oneof()}} = FieldNumber::NOT_SET;
41
+ {{field.get_variable_name()}}.clear();
42
+ }
43
+ }
44
+ inline void set_{{field.get_name()}}(const {{field.get_type_as_defined()}}& value)
45
+ {
46
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
47
+ {
48
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
49
+ }
50
+ {{field.get_variable_name()}} = value;
51
+ }
52
+ inline void set_{{field.get_name()}}(const {{field.get_type_as_defined()}}&& value)
53
+ {
54
+ if(FieldNumber::{{field.get_variable_id_name()}} != {{field.get_which_oneof()}})
55
+ {
56
+ init_{{field.get_oneof_name()}}(FieldNumber::{{field.get_variable_id_name()}});
57
+ }
58
+ {{field.get_variable_name()}} = value;
59
+ }
60
+ {% elif field.optional %}
61
+ inline bool has_{{field.get_name()}}() const
62
+ {
63
+ return 0 != (presence::mask(presence::fields::{{field.get_name().upper()}}) & presence_[presence::index(presence::fields::{{field.get_name().upper()}})]);
64
+ }
65
+ inline void clear_{{field.get_name()}}()
66
+ {
67
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] &= ~(presence::mask(presence::fields::{{field.get_name().upper()}}));
68
+ {{field.get_variable_name()}}.clear();
69
+ }
70
+ inline void set_{{field.get_name()}}(const {{field.get_type_as_defined()}}& value)
71
+ {
72
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
73
+ {{field.get_variable_name()}} = value;
74
+ }
75
+ inline void set_{{field.get_name()}}(const {{field.get_type_as_defined()}}&& value)
76
+ {
77
+ presence_[presence::index(presence::fields::{{field.get_name().upper()}})] |= presence::mask(presence::fields::{{field.get_name().upper()}});
78
+ {{field.get_variable_name()}} = value;
79
+ }
80
+ {% else %}
81
+ inline void clear_{{field.get_name()}}() { {{field.get_variable_name()}}.clear(); }
82
+ inline void set_{{field.get_name()}}(const {{field.get_type_as_defined()}}& value) { {{field.get_variable_name()}} = value; }
83
+ inline void set_{{field.get_name()}}(const {{field.get_type_as_defined()}}&& value) { {{field.get_variable_name()}} = value; }
84
+ {% endif %}
85
+ inline const {{field.get_type_as_defined()}}& get_{{field.get_name()}}() const { return {{field.get_variable_name()}}.get(); }
86
+ inline {{field.get_type_as_defined()}} {{field.get_name()}}() const { return {{field.get_variable_name()}}.get(); }
@@ -0,0 +1,37 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
29
+ #}
30
+ {% if (field.optional or (field.oneof is not none)) %}
31
+ if(has_{{field.get_name()}}() && (::EmbeddedProto::Error::NO_ERRORS == return_value))
32
+ {% else %}
33
+ if(({{field.get_default_value()}} != {{field.get_variable_name()}}.get()) && (::EmbeddedProto::Error::NO_ERRORS == return_value))
34
+ {% endif %}
35
+ {
36
+ return_value = {{field.get_variable_name()}}.serialize_with_id(static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, {{ "true" if (field.optional or (field.oneof is not none)) else "false" }});
37
+ }
@@ -0,0 +1,36 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
29
+ #}
30
+ #warning "You have a recursive inclusion with the field: '{{field.get_name()}}'. Embedded Proto is unable to determine the template parameters in this case. We could only generate this message by leaving it out."
31
+ static constexpr char const* {{field.get_name()|upper}}_NAME = "{{field.get_name()}}";
32
+ inline void clear_{{field.get_name()}}() { }
33
+ inline void set_{{field.get_name()}}(const uint8_t& value) { }
34
+ inline void set_{{field.get_name()}}(const uint8_t&& value) { }
35
+ inline const uint8_t get_{{field.get_name()}}() const { return 0; }
36
+ inline uint8_t {{field.get_name()}}() const { return 0; }
@@ -0,0 +1,33 @@
1
+ {#
2
+ Copyright (C) 2020-2024 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/pricing/>.
20
+
21
+ Embedded AMS B.V.
22
+ Info:
23
+ info at EmbeddedProto dot com
24
+
25
+ Postal address:
26
+ Atoomweg 2
27
+ 1627 LE, Hoorn
28
+ the Netherlands
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_check_type(buffer, wire_type);