|Did you know ...||Search Documentation:|
The wire-stream consists of six primitive payload types, two of which have been deprecated. A primitive in the wire-stream is a multi-byte string that provides three pieces of information: a wire-type, a user-specified tag (field number), and the raw payload. Except for the tag and its wire-type, protobuf payloads are not instantaneously recognizable because the wire-stream contains no payload type information. The interpreter uses the tag to associate the raw payload with a local host type specified by the template. Hence, the message can only be properly decoded using the template that was used to encode it. Note also that the primitive is interpreted according to the needs of a local host. Local word-size and endianness are dealt with at this level.
The following table shows the association between the types in the .proto file and the primitives used in the wire-stream. For how these correspond to other programming languages, such as C++, Java, etc. see Protocol Buffers Scalar Value Types, which also has advice on how to choose between the various integer types. (Python3 types are also given here, because Python is used in some of the interoperability tests.)
Prolog Wirestream .proto file C++ Python3 Notes double fixed64 double double float integer64 fixed64 fixed64 uint64 int 11 integer64 fixed64 sfixed64 int64 float fixed32 float float float integer32 fixed32 fixed32 uint32 int 11 integer32 fixed32 sfixed32 int32 integer varint sint32 int32 int 1, 2, 9 integer varint sint64 int64 int 1, 2, 9 signed64 varint int32 int32 int 2, 3, 10 signed64 varint int64 int64 int 2, 3, 10 unsigned varint uint32 uint32 int 2, 3 unsigned varint uint64 uint64 int 2, 3 boolean varint bool bool bool 2, 8 enum varint (enum) (enum) (enum) atom length delimited string str (unicode) codes length delimited bytes bytes utf8_codes length delimited string str (unicode) string length delimited string string str (unicode) embedded length delimited message (class) repeated length delimited repeated (list) packed length delimited packed repeated (list)
repeated(Tag,Type([...,...])), where Type is =unsigned,
repeated ... [packed=true]in proto2. Can not contain "length delimited" types.
boolean(Tag,false)maps to 0 and
boolean(Tag,true)maps to 1.
integer64are not checked for negative values; if you use a negative value, it will be treated as the 2s complement (this is the same as C++ behavior; Python throws an exception).