1 Google's Protocol Buffers
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Google's Protocol Buffers Library
        • Google's Protocol Buffers
          • Overview
          • The SWI-Prolog Implementation
          • Wiretypes
          • Tags
          • Basic Usage
          • Alternation, Aggregation, Encapsulation, and Enumeration
          • Groups (deprecated)
          • Advanced Topics

1.3 Wiretypes

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, 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 various "host types" used by several peer languages, and the primitives used in the wire-stream:

Prolog Wirestream C++Java Notes
doublefixed64doubledouble
integer64fixed64int64long
floatfixed32floatfloat
integer32fixed32int32int
integervarintint32/64int/long1, 2
unsignedvarintuint32/64int/long2, 3
booleanvarintboolboolean2
enumvarintintint2
atomlength delimitedstringString4
codeslength delimitedstringByteString
utf8_codeslength delimitedstringByteString4
stringlength delimitedstringString4

Notes:

  1. Encoded using a compression technique known as zig-zagging.
  2. Encoded as a modulo 128 string. Its length is proprotional to its magnitude. The intrinsic word length is decoupled between parties.
  3. Prolog's unbounded integer may be expressed as unsigned. This is not portable across languages.
  4. Encoded as UTF8 in the wire-stream.