Swift_ByteStream_ArrayByteStream
in package
implements
Swift_InputByteStream, Swift_OutputByteStream
Allows reading and writing of bytes to and from an array.
Tags
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
= []
$arraySize
The size of the stack.
private
int
$arraySize
= 0
$mirrors
Bound streams.
private
array<string|int, Swift_InputByteStream>
$mirrors
= []
$offset
The internal pointer offset.
private
int
$offset
= 0
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 —bind()
Attach $is to this stream.
public
bind(Swift_InputByteStream $is) : mixed
The stream acts as an observer, receiving all data that is written. All and operations will be mirrored.
Parameters
- $is : Swift_InputByteStream
Return values
mixed —commit()
Not used.
public
commit() : mixed
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