JaiaBot 3.0.0
JaiaBot micro-AUV software
Loading...
Searching...
No Matches
nanopb.proto
Go to the documentation of this file.
1// This file contains definitions of custom options used to control the
2// code generator in nanopb protocol buffers library.
3//
4// Most commonly used options are max_count and max_size, which allow
5// the generator to allocate static arrays for repeated and string fields.
6//
7// There are three ways to use these options:
8// 1. Use a separate <protofile>.options file
9// 2. Use command line switches to nanopb_generator.py
10// 3. Use [(nanopb).option = value] in your <protofile>.proto file
11//
12// For detailed documentation, refer to "Generator options" in docs/reference.md
13
14syntax = "proto2";
15import "google/protobuf/descriptor.proto";
16
17option java_package = "fi.kapsi.koti.jpa.nanopb";
18
19enum FieldType {
20 FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible.
21 FT_CALLBACK = 1; // Always generate a callback field.
22 FT_POINTER = 4; // Always generate a dynamically allocated field.
23 FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
24 FT_IGNORE = 3; // Ignore the field completely.
25 FT_INLINE = 5; // Legacy option, use the separate 'fixed_length' option instead
26}
27
28enum IntSize {
29 IS_DEFAULT = 0; // Default, 32/64bit based on type in .proto
30 IS_8 = 8;
31 IS_16 = 16;
32 IS_32 = 32;
33 IS_64 = 64;
34}
35
36enum TypenameMangling {
37 M_NONE = 0; // Default, no typename mangling
38 M_STRIP_PACKAGE = 1; // Strip current package name
39 M_FLATTEN = 2; // Only use last path component
40 M_PACKAGE_INITIALS = 3; // Replace the package name by the initials
41}
42
43enum DescriptorSize {
44 DS_AUTO = 0; // Select minimal size based on field type
45 DS_1 = 1; // 1 word; up to 15 byte fields, no arrays
46 DS_2 = 2; // 2 words; up to 4095 byte fields, 4095 entry arrays
47 DS_4 = 4; // 4 words; up to 2^32-1 byte fields, 2^16-1 entry arrays
48 DS_8 = 8; // 8 words; up to 2^32-1 entry arrays
49}
50
51// This is the inner options message, which basically defines options for
52// a field. When it is used in message or file scope, it applies to all
53// fields.
54message NanoPBOptions {
55 // Allocated size for 'bytes' and 'string' fields.
56 // For string fields, this should include the space for null terminator.
57 optional int32 max_size = 1;
58
59 // Maximum length for 'string' fields. Setting this is equivalent
60 // to setting max_size to a value of length+1.
61 optional int32 max_length = 14;
62
63 // Allocated number of entries in arrays ('repeated' fields)
64 optional int32 max_count = 2;
65
66 // Size of integer fields. Can save some memory if you don't need
67 // full 32 bits for the value.
68 optional IntSize int_size = 7 [default = IS_DEFAULT];
69
70 // Size for enum fields. Supported by C++11 and C23 standards.
71 optional IntSize enum_intsize = 34 [default = IS_DEFAULT];
72
73 // Force type of field (callback or static allocation)
74 optional FieldType type = 3 [default = FT_DEFAULT];
75
76 // Use long names for enums, i.e. EnumName_EnumValue.
77 optional bool long_names = 4 [default = true];
78
79 // Add 'packed' attribute to generated structs.
80 // Note: this cannot be used on CPUs that break on unaligned
81 // accesses to variables.
82 optional bool packed_struct = 5 [default = false];
83
84 // Add 'packed' attribute to generated enums.
85 optional bool packed_enum = 10 [default = false];
86
87 // Skip this message
88 optional bool skip_message = 6 [default = false];
89
90 // Generate oneof fields as normal optional fields instead of union.
91 optional bool no_unions = 8 [default = false];
92
93 // integer type tag for a message
94 optional uint32 msgid = 9;
95
96 // decode oneof as anonymous union
97 optional bool anonymous_oneof = 11 [default = false];
98
99 // Proto3 singular field does not generate a "has_" flag
100 optional bool proto3 = 12 [default = false];
101
102 // Force proto3 messages to have no "has_" flag.
103 // This was default behavior until nanopb-0.4.0.
104 optional bool proto3_singular_msgs = 21 [default = false];
105
106 // Generate an enum->string mapping function (can take up lots of space).
107 optional bool enum_to_string = 13 [default = false];
108
109 // Generate validation methods for enums
110 optional bool enum_validate = 32 [default = false];
111
112 // Generate bytes arrays with fixed length
113 optional bool fixed_length = 15 [default = false];
114
115 // Generate repeated field with fixed count
116 optional bool fixed_count = 16 [default = false];
117
118 // Generate message-level callback that is called before decoding submessages.
119 // This can be used to set callback fields for submsgs inside oneofs.
120 optional bool submsg_callback = 22 [default = false];
121
122 // Shorten or remove package names from type names.
123 // This option applies only on the file level.
124 optional TypenameMangling mangle_names = 17 [default = M_NONE];
125
126 // Data type for storage associated with callback fields.
127 optional string callback_datatype = 18 [default = "pb_callback_t"];
128
129 // Callback function used for encoding and decoding.
130 // Prior to nanopb-0.4.0, the callback was specified in per-field pb_callback_t
131 // structure. This is still supported, but does not work inside e.g. oneof or pointer
132 // fields. Instead, a new method allows specifying a per-message callback that
133 // will be called for all callback fields in a message type.
134 optional string callback_function = 19 [default = "pb_default_field_callback"];
135
136 // Select the size of field descriptors. This option has to be defined
137 // for the whole message, not per-field. Usually automatic selection is
138 // ok, but if it results in compilation errors you can increase the field
139 // size here.
140 optional DescriptorSize descriptorsize = 20 [default = DS_AUTO];
141
142 // Set default value for has_ fields.
143 optional bool default_has = 23 [default = false];
144
145 // Extra files to include in generated `.pb.h`
146 repeated string include = 24;
147
148 // Automatic includes to exclude from generated `.pb.h`
149 // Same as nanopb_generator.py command line flag -x.
150 repeated string exclude = 26;
151
152 // Package name that applies only for nanopb.
153 optional string package = 25;
154
155 // Override type of the field in generated C code. Only to be used with related field types
156 optional google.protobuf.FieldDescriptorProto.Type type_override = 27;
157
158 // Override of the label of the field (see FieldDescriptorProto.Label). Can be used to create
159 // fields which nanopb considers required in proto3, or whether nanopb treats the field as
160 // optional/required/repeated.
161 optional google.protobuf.FieldDescriptorProto.Label label_override = 31;
162
163 // Due to historical reasons, nanopb orders fields in structs by their tag number
164 // instead of the order in .proto. Set this to false to keep the .proto order.
165 // The default value will probably change to false in nanopb-0.5.0.
166 optional bool sort_by_tag = 28 [default = true];
167
168 // Set the FT_DEFAULT field conversion strategy.
169 // A field that can become a static member of a c struct (e.g. int, bool, etc)
170 // will be a a static field.
171 // Fields with dynamic length are converted to either a pointer or a callback.
172 optional FieldType fallback_type = 29 [default = FT_CALLBACK];
173
174 // Override initializer used in generated MyMessage_init_zero and MyMessage_init_default macros
175 // By default decided automatically based on field default value and datatype.
176 optional string initializer = 30;
177
178 // Discard unused types that are automatically generated by protoc if they are not actually
179 // needed. Currently this applies to map< > types when the field is ignored by options.
180 optional bool discard_unused_automatic_types = 33 [default = true];
181
182 // Discard messages and fields marked with [deprecated = true] in the proto file.
183 optional bool discard_deprecated = 35 [default = false];
184}
185
186// Extensions to protoc 'Descriptor' type in order to define options
187// inside a .proto file.
188//
189// Protocol Buffers extension number registry
190// --------------------------------
191// Project: Nanopb
192// Contact: Petteri Aimonen <jpa@kapsi.fi>
193// Web site: http://kapsi.fi/~jpa/nanopb
194// Extensions: 1010 (all types)
195// --------------------------------
196
197extend google.protobuf.FileOptions {
198 optional NanoPBOptions nanopb_fileopt = 1010;
199}
200
201extend google.protobuf.MessageOptions {
202 optional NanoPBOptions nanopb_msgopt = 1010;
203}
204
205extend google.protobuf.EnumOptions {
206 optional NanoPBOptions nanopb_enumopt = 1010;
207}
208
209extend google.protobuf.FieldOptions {
210 optional NanoPBOptions nanopb = 1010;
211}
212
213