Documentation

Swift_ByteStream_ArrayByteStream
in package
implements Swift_InputByteStream, Swift_OutputByteStream

Allows reading and writing of bytes to and from an array.

Tags
author

Chris Corbyn

Interfaces, Classes and Traits

Swift_InputByteStream
An abstract means of writing data.
Swift_OutputByteStream
An abstract means of reading data.

Table of Contents

$array  : array<string|int, string>
The internal stack of bytes.
$arraySize  : int
The size of the stack.
$mirrors  : array<string|int, Swift_InputByteStream>
Bound streams.
$offset  : int
The internal pointer offset.
__construct()  : mixed
Create a new ArrayByteStream.
bind()  : mixed
Attach $is to this stream.
commit()  : mixed
Not used.
flushBuffers()  : mixed
Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
read()  : string
Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
setReadPointer()  : bool
Move the internal read pointer to $byteOffset in the stream.
unbind()  : mixed
Remove an already bound stream.
write()  : int
Writes $bytes to the end of the stream.

Properties

$array

The internal stack of bytes.

private array<string|int, string> $array = []

Methods

__construct()

Create a new ArrayByteStream.

public __construct([mixed $stack = null ]) : mixed

If $stack is given the stream will be populated with the bytes it contains.

Parameters
$stack : mixed = null

of bytes in string or array form, optional

Return values
mixed —

flushBuffers()

Flush the contents of the stream (empty it) and set the internal pointer to the beginning.

public flushBuffers() : mixed
Return values
mixed —

read()

Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.

public read(int $length) : string

If less bytes exist than are requested the remaining bytes are given instead. If no bytes are remaining at all, boolean false is returned.

Parameters
$length : int
Return values
string —

setReadPointer()

Move the internal read pointer to $byteOffset in the stream.

public setReadPointer(int $byteOffset) : bool
Parameters
$byteOffset : int
Return values
bool —

unbind()

Remove an already bound stream.

public unbind(Swift_InputByteStream $is) : mixed

If $is is not bound, no errors will be raised. If the stream currently has any buffered data it will be written to $is before unbinding occurs.

Parameters
$is : Swift_InputByteStream
Return values
mixed —

write()

Writes $bytes to the end of the stream.

public write(string $bytes) : int
Parameters
$bytes : string
Return values
int —

Search results