FixIO Documentation

Back to summary

import "io/stream";

ArrayStream class

Stream backed by arrays.

For performance reasons it is recommended to use the type directly instead of casting it to the generic Stream class as this class statically replaces the primitive reading/writing functions.

Inherits from Stream.

Functions

static function create(): ArrayStream
static function create(in_buf: Byte[]): ArrayStream
static function create(in_buf: Byte[], out_buf: Byte[]): ArrayStream
Creates a new array stream. You can provide input and output buffers. The output buffer is created automatically on first write if not provided.
function reset()
Resets the stream, the reading position is set back to beginning and the output buffer is cleared.
function reset(in_buf: Byte[])
function reset(in_buf: Byte[], out_buf: Byte[])
Resets the stream using the provided input and output buffers.
function get_position(): Integer
Returns the current reading position.
function set_position(pos: Integer)
Sets the current reading position.
function get_output(): Byte[]
Returns the output buffer.

Utility functions

function read_line(buf: Byte[]): Byte[]
function read_line(buf: Byte[], max_bytes: Integer): Byte[]
Reads a line delimited by LF or CRLF. The provided buffer is cleared before reading and the newline characters are not included. You can optionally limit the maximum length of the line (pass negative value to remove the limit). Returns the buffer or null when the end of the stream is reached.
function read_null_string(): Byte[]
function read_null_string(str: Byte[]): Byte[]
function read_null_string(str: Byte[], max_bytes: Integer): Byte[]
Reads null terminated byte string. Optionally it can append it into the provided string. You can also optionally limit the maximum length of the string (pass negative value to remove the limit).