StreamReader

from acron.core import StreamReader
class StreamReader

Bases:

A class to read sequential binary data directly from an istream. Its interface is similar to DatagramIterator by design; see also StreamWriter.

Inheritance diagram

digraph inheritance40d8b6a74a { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "StreamReader" [URL="acron.core.StreamReader.html#acron.core.StreamReader",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "StreamReader" [arrowsize=0.75,style=""]; }
__init__()

If owns_stream is true, the stream pointer will be deleted when the StreamReader destructs.

The copy constructor does not copy ownership of the stream.

The move constructor steals ownership of the stream.

assign()
extract_bytes()

Extracts the indicated number of bytes in the stream into the given character buffer. Assumes that the buffer is big enough to hold the requested number of bytes. Returns the number of bytes that were successfully written.

Extracts the indicated number of bytes in the stream and returns them as a string. Returns empty string at end-of-file.

get_be_float32()

Extracts a 32-bit single-precision big-endian floating-point number. Since this kind of float is not necessarily portable across different architectures, special care is required.

get_be_float64()

Extracts a 64-bit big-endian floating-point number.

get_be_int16()

Extracts a signed big-endian 16-bit integer.

get_be_int32()

Extracts a signed big-endian 32-bit integer.

get_be_int64()

Extracts a signed big-endian 64-bit integer.

get_be_uint16()

Extracts an unsigned big-endian 16-bit integer.

get_be_uint32()

Extracts an unsigned big-endian 32-bit integer.

get_be_uint64()

Extracts an unsigned big-endian 64-bit integer.

get_bool()

Extracts a boolean value.

get_fixed_string()

Extracts a fixed-length string. However, if a zero byte occurs within the string, it marks the end of the string.

get_float32()

Extracts a 32-bit single-precision floating-point number. Since this kind of float is not necessarily portable across different architectures, special care is required.

get_float64()

Extracts a 64-bit floating-point number.

get_int16()

Extracts a signed 16-bit integer.

get_int32()

Extracts a signed 32-bit integer.

get_int64()

Extracts a signed 64-bit integer.

get_int8()

Extracts a signed 8-bit integer.

get_istream()

Returns the stream in use.

get_string()

Extracts a variable-length string.

get_string32()

Extracts a variable-length string with a 32-bit length field.

get_uint16()

Extracts an unsigned 16-bit integer.

get_uint32()

Extracts an unsigned 32-bit integer.

get_uint64()

Extracts an unsigned 64-bit integer.

get_uint8()

Extracts an unsigned 8-bit integer.

get_z_string()

Extracts a variable-length string, as a NULL-terminated string.

property istream → istream

Returns the stream in use.

readline()

Assumes the stream represents a text file, and extracts one line up to and including the trailing newline character. Returns empty string when the end of file is reached.

The interface here is intentionally designed to be similar to that for Python’s File.readline() function.

readlines()
skip_bytes()

Skips over the indicated number of bytes in the stream.