December 2017
Intermediate to advanced
316 pages
6h 58m
English
Enumerations provide the ordering of numbers for a given set of elements. The default order of values is from zero to n. So, in protocol buffer messages, we can have an enumeration type. Let us see an example of the enum:
syntax 'proto3'; message Schedule{ enum Days{ SUNDAY = 0; MONDAY = 1; TUESDAY = 2; WEDNESDAY = 3; THURSDAY = 4; FRIDAY = 5; SATURDAY = 6; }}
What if we need to assign the same values for the multiple enumeration members. Protobuf3 allows an option called allow aliases to assign two different members the same value. For example:
enum EnumAllowingAlias {
option allow_alias = true;
UNKNOWN = 0;
STARTED = 1;
RUNNING = 1;
}
Here, STARTED and RUNNING both have a 1 tag. This means that both can ...