class Binary

This class implements the (de)serialization of TagContext using the binary wire format.

Traits

Varint encoding and decoding methods inspired by Go encoding/binary package.

Constants

TAGS_VERSION_ID

Binary Encoding Version number

KEYTYPE_STRING

KeyTypes (currently only string is supported)

KEYTYPE_INT64

KEYTYPE_TRUE

KEYTYPE_FALSE

Methods

static int
encodeUnsigned(string $buf, int $x)

Varint encode as unsigned integer.

static int
encodeSigned(string $buf, int $x)

Varint encode as signed integer.

static int
decodeUnsigned(string $buf, int $x)

Varint decode an unsigned integer.

static int
decodeSigned(string $buf, int $x)

Varint decode a signed integer.

static string
encode(TagContext $tagContext)

Encode the provided TagContext to our binary wire format.

static TagContext
decode(string $str, Exception $err = null)

Decode the provided TagContext from the binary wire format.

Details

in VarintTrait at line 33
static int encodeUnsigned(string $buf, int $x)

Varint encode as unsigned integer.

Parameters

string $buf bytestring to hold varint encoding of $x.
int $x the unsigned integer to varint encode.

Return Value

int number of bytes written to buf.

in VarintTrait at line 51
static int encodeSigned(string $buf, int $x)

Varint encode as signed integer.

Parameters

string $buf bytestring to hold varint encoding of $x.
int $x the signed integer to varint encode.

Return Value

int number of bytes written to buf.

in VarintTrait at line 67
static int decodeUnsigned(string $buf, int $x)

Varint decode an unsigned integer.

Parameters

string $buf bytestring holding varint encoding.
int $x integer to receive the decoded value.

Return Value

int number of bytes read from buf.

in VarintTrait at line 96
static int decodeSigned(string $buf, int $x)

Varint decode a signed integer.

Parameters

string $buf bytestring holding varint encoding.
int $x integer to receive the decoded value.

Return Value

int number of bytes read from buf.

at line 48
static string encode(TagContext $tagContext)

Encode the provided TagContext to our binary wire format.

Parameters

TagContext $tagContext the object holding the Tag's to encode.

Return Value

string the bytestring holding our binary encoded Tag's.

at line 73
static TagContext decode(string $str, Exception $err = null)

Decode the provided TagContext from the binary wire format.

Parameters

string $str The bytestring holding our encoded TagContext.
Exception $err Set on deserialization errors and size constraints.

Return Value

TagContext