MemoryReader
in package
implements
Reader
A reader that holds an in-memory buffer.
Interfaces, Classes, Traits and Enums
- Reader
- An interface to read a byte string (which can be quite long) in separated multiple chunks.
Table of Contents
- __construct() : void
- Creates a {@see MemoryWriter} instance.
- read() : string
- Reads a chunk of bytes.
- seek() : void
- Fast-forwards or rewinds the offset.
- tell() : int
- Gets the current offset in the buffer.
Methods
__construct()
Creates a {@see MemoryWriter} instance.
public
__construct(string $buffer) : void
Parameters
- $buffer : string
-
The input bytes to be consumed later.
Tags
Return values
void —read()
Reads a chunk of bytes.
public
read(mixed $size) : string
Parameters
- $size : mixed
-
The size of bytes to request. Zero or negative integers reads nothing and an empty string is returned.
Tags
Return values
string —The read bytes. It may be shorter than the requested size if there is not enough bytes to read.
seek()
Fast-forwards or rewinds the offset.
public
seek(mixed $offset) : void
Parameters
- $offset : mixed
-
The number of bytes to move the offset pointer. Negative integers rewind and positive integers fast-forward. (Zero is no-op.) If the destination is less than zero or greater than the entire length, the offset is set to zero or the end of the entire buffer.
Tags
Return values
void —tell()
Gets the current offset in the buffer.
public
tell() : int
Tags
Return values
int —The current offset.