ByteReader provides a byte reader that can read different integer and floating point types from a memory
buffer.
It provides functions for reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading
little/big endian floating points numbers of 32 and 64 bits. It also provides functions to read NUL-terminated strings in various
character encodings.
- public bool dup_data (uint size, out uint8[] val)
Free-function: g_free
- public bool dup_string_utf16 (out uint16[] str)
Free-function: g_free
- public bool dup_string_utf32 (out uint32[] str)
Free-function: g_free
- public bool dup_string_utf8 (out string[] str)
Free-function: g_free
- public void free ()
Frees a ByteReader instance, which was
previously allocated by ByteReader.
- public bool get_data (uint size, out unowned uint8[] val)
Returns a constant pointer to the current data position if at least
size
bytes are left and updates the current position.
- public bool get_float32_be (out float val)
Read a 32 bit big endian floating point value into val
and update the current position.
- public bool get_float32_le (out float val)
Read a 32 bit little endian floating point value into val
and update the current position.
- public bool get_float64_be (out double val)
Read a 64 bit big endian floating point value into val
and update the current position.
- public bool get_float64_le (out double val)
Read a 64 bit little endian floating point value into val
and update the current position.
- public bool get_int16_be (out int16 val)
Read a signed 16 bit big endian integer into val
and
update the current position.
- public bool get_int16_le (out int16 val)
Read a signed 16 bit little endian integer into val
and
update the current position.
- public bool get_int24_be (out int32 val)
Read a signed 24 bit big endian integer into val
and
update the current position.
- public bool get_int24_le (out int32 val)
Read a signed 24 bit little endian integer into val
and
update the current position.
- public bool get_int32_be (out int32 val)
Read a signed 32 bit big endian integer into val
and
update the current position.
- public bool get_int32_le (out int32 val)
Read a signed 32 bit little endian integer into val
and
update the current position.
- public bool get_int64_be (out int64 val)
Read a signed 64 bit big endian integer into val
and
update the current position.
- public bool get_int64_le (out int64 val)
Read a signed 64 bit little endian integer into val
and
update the current position.
- public bool get_int8 (out int8 val)
Read a signed 8 bit integer into val
and update the
current position.
- public uint get_pos ()
Returns the current position of a ByteReader
instance in bytes.
- public uint get_remaining ()
Returns the remaining number of bytes of a
ByteReader instance.
- public uint get_size ()
Returns the total number of bytes of a ByteReader
instance.
- public bool get_string_utf8 (out unowned string[] str)
Returns a constant pointer to the current data position if there is a
NUL-terminated string in the data (this could be just a NUL terminator), advancing the current position to the byte after the string.
- public bool get_uint16_be (out uint16 val)
Read an unsigned 16 bit big endian integer into val
and
update the current position.
- public bool get_uint16_le (out uint16 val)
Read an unsigned 16 bit little endian integer into val
and update the current position.
- public bool get_uint24_be (out uint32 val)
Read an unsigned 24 bit big endian integer into val
and
update the current position.
- public bool get_uint24_le (out uint32 val)
Read an unsigned 24 bit little endian integer into val
and update the current position.
- public bool get_uint32_be (out uint32 val)
Read an unsigned 32 bit big endian integer into val
and
update the current position.
- public bool get_uint32_le (out uint32 val)
Read an unsigned 32 bit little endian integer into val
and update the current position.
- public bool get_uint64_be (out uint64 val)
Read an unsigned 64 bit big endian integer into val
and
update the current position.
- public bool get_uint64_le (out uint64 val)
Read an unsigned 64 bit little endian integer into val
and update the current position.
- public bool get_uint8 (out uint8 val)
Read an unsigned 8 bit integer into val
and update the
current position.
- public void init (uint8[] data)
Initializes a ByteReader instance to read
from data
.
- public uint masked_scan_uint32 (uint32 mask, uint32 pattern, uint offset, uint size)
Scan for pattern pattern
with applied mask mask
in the byte reader data, starting from offset offset
relative to the current position.
- public uint masked_scan_uint32_peek (uint32 mask, uint32 pattern, uint offset, uint size, out uint32 value)
Scan for pattern pattern
with applied mask mask
in the byte reader data, starting from offset offset
relative to the current position.
- public bool peek_data (uint size, out unowned uint8[] val)
Returns a constant pointer to the current data position if at least
size
bytes are left and keeps the current position.
- public bool peek_float32_be (out float val)
Read a 32 bit big endian floating point value into val
but keep the current position.
- public bool peek_float32_le (out float val)
Read a 32 bit little endian floating point value into val
but keep the current position.
- public bool peek_float64_be (out double val)
Read a 64 bit big endian floating point value into val
but keep the current position.
- public bool peek_float64_le (out double val)
Read a 64 bit little endian floating point value into val
but keep the current position.
- public bool peek_int16_be (out int16 val)
Read a signed 16 bit big endian integer into val
but keep
the current position.
- public bool peek_int16_le (out int16 val)
Read a signed 16 bit little endian integer into val
but
keep the current position.
- public bool peek_int24_be (out int32 val)
Read a signed 24 bit big endian integer into val
but keep
the current position.
- public bool peek_int24_le (out int32 val)
Read a signed 24 bit little endian integer into val
but
keep the current position.
- public bool peek_int32_be (out int32 val)
Read a signed 32 bit big endian integer into val
but keep
the current position.
- public bool peek_int32_le (out int32 val)
Read a signed 32 bit little endian integer into val
but
keep the current position.
- public bool peek_int64_be (out int64 val)
Read a signed 64 bit big endian integer into val
but keep
the current position.
- public bool peek_int64_le (out int64 val)
Read a signed 64 bit little endian integer into val
but
keep the current position.
- public bool peek_int8 (out int8 val)
Read a signed 8 bit integer into val
but keep the current
position.
- public bool peek_string_utf8 (out unowned string[] str)
Returns a constant pointer to the current data position if there is a
NUL-terminated string in the data (this could be just a NUL terminator).
- public bool peek_uint16_be (out uint16 val)
Read an unsigned 16 bit big endian integer into val
but
keep the current position.
- public bool peek_uint16_le (out uint16 val)
Read an unsigned 16 bit little endian integer into val
but keep the current position.
- public bool peek_uint24_be (out uint32 val)
Read an unsigned 24 bit big endian integer into val
but
keep the current position.
- public bool peek_uint24_le (out uint32 val)
Read an unsigned 24 bit little endian integer into val
but keep the current position.
- public bool peek_uint32_be (out uint32 val)
Read an unsigned 32 bit big endian integer into val
but
keep the current position.
- public bool peek_uint32_le (out uint32 val)
Read an unsigned 32 bit little endian integer into val
but keep the current position.
- public bool peek_uint64_be (out uint64 val)
Read an unsigned 64 bit big endian integer into val
but
keep the current position.
- public bool peek_uint64_le (out uint64 val)
Read an unsigned 64 bit little endian integer into val
but keep the current position.
- public bool peek_uint8 (out uint8 val)
Read an unsigned 8 bit integer into val
but keep the
current position.
- public bool set_pos (uint pos)
Sets the new position of a ByteReader
instance to pos
in bytes.
- public bool skip (uint nbytes)
Skips nbytes
bytes of the ByteReader
instance.
- public bool skip_string_utf16 ()
Skips a NUL-terminated UTF-16 string in the
ByteReader instance, advancing the current position to the byte after the string.
- public bool skip_string_utf32 ()
Skips a NUL-terminated UTF-32 string in the
ByteReader instance, advancing the current position to the byte after the string.
- public bool skip_string_utf8 ()
Skips a NUL-terminated string in the ByteReader
instance, advancing the current position to the byte after the string.