vfbLib.parsers.base.StreamReader

class vfbLib.parsers.base.StreamReader

Bases: object

Base class that reads values from the input stream.

This is the parent class for the general BaseParser, from which all other parsers inherit, but it may be subclassed directly if more flexibility is needed.

__init__()

Methods

__init__()

read_double()

Return a double-precision float from the stream.

read_doubles(num)

Return a tuple of num double-precision floats from the stream.

read_float()

Return a float from the stream.

read_floats(num)

Return a tuple of num floats from the stream.

read_int16()

Return a signed 16-bit integer from the stream.

read_int32()

Return a signed 32-bit integer from the stream.

read_int8()

Return a signed 8-bit integer from the stream.

read_str(size)

Return a string of the specified size from the current stream with the current encoding

read_str_all()

Return the remaining bytes of the current stream as a string with the current encoding.

read_uint16()

Return an unsigned 16-bit integer from the stream.

read_uint32()

Return an unsigned 32-bit integer from the stream.

read_uint8()

Return an unsigned 8-bit integer from the stream.

read_value([signed])

Return an encoded integer value from the stream.

Attributes

encoding

stream

read_double() float

Return a double-precision float from the stream.

Returns:

The float

Return type:

float

read_doubles(num) tuple[float]

Return a tuple of num double-precision floats from the stream.

Parameters:

num (int) – The number of double-precision floats to read from the stream

Returns:

The tuple of floats

Return type:

tuple[float]

read_float() float

Return a float from the stream.

Returns:

The float

Return type:

float

read_floats(num: int) tuple[float]

Return a tuple of num floats from the stream.

Parameters:

num (int) – The number of floats to read from the stream

Returns:

The tuple of floats

Return type:

tuple[float]

read_int16() int

Return a signed 16-bit integer from the stream.

Returns:

The integer

Return type:

int

read_int32() int

Return a signed 32-bit integer from the stream.

Returns:

The integer

Return type:

int

read_int8() int

Return a signed 8-bit integer from the stream.

Returns:

The integer

Return type:

int

read_str(size: int) str

Return a string of the specified size from the current stream with the current encoding

Parameters:

size (int) – The size in bytes to be converted to a string

Returns:

The string

Return type:

str

read_str_all() str

Return the remaining bytes of the current stream as a string with the current encoding. Null bytes and whitespace are stripped from the string.

Returns:

The string

Return type:

str

read_uint16() int

Return an unsigned 16-bit integer from the stream.

Returns:

The integer

Return type:

int

read_uint32() int

Return an unsigned 32-bit integer from the stream.

Returns:

The integer

Return type:

int

read_uint8() int

Return an unsigned 8-bit integer from the stream.

Returns:

The integer

Return type:

int

read_value(signed: bool = True) int

Return an encoded integer value from the stream.

Parameters:
  • signed (bool, optional) – Whether the value is interpreted as a signed value.

  • True. (Defaults to)

Returns:

The integer

Return type:

int