JASSv2
Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
JASS::protobuf Class Reference

Functions to read a protobuf buffer. More...

#include <protobuf.h>

Public Types

enum  wire_type {
  VARINT = 0, SIXTY_FOUR_BIT = 1, BLOB = 2, GROUP_START = 3,
  GROUP_END = 4, THIRTY_TWO_BIT = 5
}
 The known protobuf types for protobuf 3. More...
 

Static Public Member Functions

static uint64_t get_uint64_t (const uint8_t *&stream)
 
static uint64_t get_int64_t (const uint8_t *&stream)
 
static uint32_t get_uint32_t (const uint8_t *&stream)
 
static int32_t get_int32_t (const uint8_t *&stream)
 
static slice get_blob (const uint8_t *&stream)
 
static uint64_t get_64_t (const uint8_t *&stream)
 
static uint32_t get_32_t (const uint8_t *&stream)
 
static double get_double (const uint8_t *&stream)
 
static uint8_t get_type_and_field (wire_type &type, const uint8_t *&stream)
 Extract the field number and its type from the stream. More...
 

Static Private Member Functions

static int64_t un_zigzag (uint64_t bits)
 Turn unsigned ZigZaged integer into a signed integer. More...
 

Detailed Description

Functions to read a protobuf buffer.

For details of the encoding see: https://developers.google.com/protocol-buffers/docs/encoding This class is written to be standalone from JASSv2 so that others can use it without including all of JASSv2

Member Enumeration Documentation

◆ wire_type

The known protobuf types for protobuf 3.

Enumerator
VARINT 

Variable byte encoded integer of up-to 64 bits, signed or unsigned.

SIXTY_FOUR_BIT 

Little endian 64-bit number, integer or floating point types.

BLOB 

Blob or string. length VARINT then data.

GROUP_START 

Depricated in protobuf 3.

GROUP_END 

Depricated in protobuf 3.

THIRTY_TWO_BIT 

Little endian 32-bit number, integer or floating point types.

Member Function Documentation

◆ get_type_and_field()

static uint8_t JASS::protobuf::get_type_and_field ( wire_type type,
const uint8_t *&  stream 
)
inlinestatic

Extract the field number and its type from the stream.

The spec (https://developers.google.com/protocol-buffers/docs/encoding) states: "Each key in the streamed message is a varint with the value (field_number << 3) | wire_type" ... "in other words, the last three bits of the number store the wire type.".

Parameters
type[out] The type of the field
stream[in, out] A reference to a pointer to the start of the value, points to the next byte on return.
Returns
The number of the field

◆ un_zigzag()

static int64_t JASS::protobuf::un_zigzag ( uint64_t  bits)
inlinestaticprivate

Turn unsigned ZigZaged integer into a signed integer.

The spec (https://developers.google.com/protocol-buffers/docs/encoding) states: "ZigZag encoding maps signed integers to unsigned integers so that numbers with a small absolute value (for instance, -1) have a small varint encoded value too. It does this in a way that "zig-zags" back and forth through the positive and negative integers, so that -1 is encoded as 1, 1 is encodedas 2, -2 is encoded as 3, and so on". This method undoes the encoding.

Parameters
bits[in] The ZigZag encoding to convert
Returns
The signed integer

The documentation for this class was generated from the following file: