Back to Aurora Vision Library Lite website

You are here: Start » All Functions » Binary Data » ReadIntegerArrayFromBuffer

ReadIntegerArrayFromBuffer


This is Filter Equivalent. This function may be present in generated code, but should not be used in hand-written code.

Header: STD.h
Namespace: avl

Reads an array of integer values in specified binary format from a byte buffer.

Syntax

void avl::ReadIntegerArrayFromBuffer
(
	const avl::ByteBuffer& inBuffer,
	int inOffset,
	int inArraySize,
	avl::IntegerBinaryFormat::Type inFormat,
	bool inCheckRange,
	atl::Array<int>& outArray,
	int& outOffset
)

Parameters

Name Type Range Default Description
Input value inBuffer const ByteBuffer& Source data
Input value inOffset int 0 - 0 Read start position
Input value inArraySize int 0 - 1 Number of elements to read into array
Input value inFormat IntegerBinaryFormat::Type Signed_32Bit_LittleEndian Binary serialization format of integer data
Input value inCheckRange bool True Verify if read data can be stored in resulting Integer type
Output value outArray Array<int>& Array of read values
Output value outOffset int& Resulting position behind read data

Description

This filter is intended for reading (deserializing) an array of integer values out of a raw binary data in a ByteBuffer.

Data is read starting at the position provided by the inOffset input (in bytes). This position is than advanced by the size of read data and returned on the outOffset output. This output can be connected to the inOffset input of other byte buffer reading filter when reading consecutive fields of data structures. When data read spans beyond the end of the input buffer an IOError is raised.

This filter reads multiple consecutive integer values in number specified by the inArraySize input and stores them in an array on the outArray output. Every array item integer value is converted from a binary representation according to the inFormat input value:

  • Signed_8Bit - signed two's complement 8-bit integer, 1 byte long.
  • Signed_16Bit_LittleEndian - signed two's complement 16-bit integer, 2 bytes long with little-endian byte order.
  • Signed_32Bit_LittleEndian - signed two's complement 32-bit integer, 4 bytes long with little-endian byte order.
  • Signed_64Bit_LittleEndian - signed two's complement 64-bit integer, 8 bytes long with little-endian byte order.
  • Unsigned_8Bit - unsigned 8-bit integer, 1 byte long.
  • Unsigned_16Bit_LittleEndian - unsigned 16-bit integer, 2 bytes long with little-endian byte order.
  • Unsigned_64Bit_LittleEndian - unsigned 64-bit integer, 8 bytes long with little-endian byte order.
  • Signed_16Bit_BigEndian - signed two's complement 16-bit integer, 2 bytes long with big-endian byte order.
  • Signed_32Bit_BigEndian - signed two's complement 32-bit integer, 4 bytes long with big-endian byte order.
  • Signed_64Bit_BigEndian - signed two's complement 64-bit integer, 8 bytes long with big-endian byte order.
  • Unsigned_16Bit_BigEndian - unsigned 16-bit integer, 2 bytes long with big-endian byte order.
  • Unsigned_32Bit_BigEndian - unsigned 32-bit integer, 4 bytes long with big-endian byte order.
  • Unsigned_64Bit_BigEndian - unsigned 64-bit integer, 8 bytes long with big-endian byte order.

Supported numeric range of stored value also depends on selected format:

  • Signed_8Bit: -128...127
  • Signed_16Bit_: -32768...32767
  • Signed_32Bit_: -2147483648...2147483647
  • Signed_64Bit_: -9223372036854775808...9223372036854775807 *
  • Unsigned_8Bit: 0...255
  • Unsigned_16Bit_: 0...65535
  • Unsigned_32Bit_: 0...4294967295 *
  • Unsigned_64Bit_: 0...18446744073709551615 *

 *) actual achievable range in the application is also limited by the Integer type

When a value read from the buffer cannot be stored in the data type of the output array item (which is a signed 32-bit integer) an IOError is raised. inCheckRange input can be set to False to ignore this error (in such situation value is truncated without saturation).

This filter can be used as a more convenient and faster alternative to the connection of ReadBufferArrayFromBuffer and ReadIntegerFromBuffer filters.

Errors

List of possible exceptions:

Error type Description
DomainError Not supported integer binary format.
IoError Empty byte buffer at input of ReadIntegerArrayFromBuffer.
IoError Reading beyond the end of the byte buffer.
Source data range specified by the inOffset input and the size of integers array spans beyond the end of the byte buffer.
IoError The read value is out of supported range.
Array item value read from the source data cannot be stored in Integer data type. This error can be silenced using the inCheckRange input.

See Also

  • WriteIntegerArrayToBuffer – Converts an array of integer values into specified binary representation and writes it to a byte buffer.