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

package Swift
subpackage ByteStream
author Chris Corbyn

 Methods

Create a new ArrayByteStream.

__construct(mixed $stack) 

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

Parameters

$stack

mixed

of bytes in string or array form, optional

Attach $is to this stream.

bind(\Swift_InputByteStream $is) 

The stream acts as an observer, receiving all data that is written. All write() and flushBuffers() operations will be mirrored.

Parameters

Not used.

commit() 

Exceptions

\Swift_IoException

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

flushBuffers() 

Exceptions

\Swift_IoException

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

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

Exceptions

\Swift_IoException

Returns

string

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

setReadPointer(int $byteOffset) : boolean

Parameters

$byteOffset

int

Exceptions

\Swift_IoException

Returns

boolean

Remove an already bound stream.

unbind(\Swift_InputByteStream $is) 

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

Writes $bytes to the end of the stream.

write(string $bytes) : int

Writing may not happen immediately if the stream chooses to buffer. If you want to write these bytes with immediate effect, call commit() after calling write().

This method returns the sequence ID of the write (i.e. 1 for first, 2 for second, etc etc).

Parameters

$bytes

string

Exceptions

\Swift_IoException

Returns

int

 Properties

 

$_array : string[]
access private
 

$_arraySize : int
access private
 

$_mirrors 
 

$_offset : int
access private