A stream reader class.
More...
|
| __construct ($stream, $closeStream=false) |
| StreamReader constructor.
|
|
| __destruct () |
| The destructor.
|
|
| addOffset ($offset) |
| Add an offset to the current offset.
|
|
| cleanUp () |
| Closes the file handle.
|
|
| ensure ($pos, $length) |
| Ensures bytes in the buffer with a specific length and location in the file.
|
|
| ensureContent () |
| Make sure that there is at least one character beyond the current offset in the buffer.
|
|
| getBuffer ($atOffset=true) |
| Returns the current buffer.
|
|
| getBufferLength ($atOffset=false) |
| Returns the byte length of the buffer.
|
|
| getByte ($position=null) |
| Gets a byte at a specific position in the buffer.
|
|
| getOffset () |
| Returns the current offset in the current buffer.
|
|
| getPosition () |
| Get the current position in the stream.
|
|
| getStream () |
| Returns the stream.
|
|
| getTotalLength () |
| Gets the total available length.
|
|
| increaseLength ($minLength=100) |
| Forcefully read more data into the buffer.
|
|
| readByte ($position=null) |
| Returns a byte at a specific position, and set the offset to the next byte position.
|
|
| readBytes ($length, $position=null) |
| Read bytes from the current or a specific offset position and set the internal pointer to the next byte.
|
|
| readLine ($length=1024) |
| Read a line from the current position.
|
|
| reset ($pos=0, $length=200) |
| Resets the buffer to a position and re-read the buffer with the given length.
|
|
| setOffset ($offset) |
| Set the offset position in the current buffer.
|
|
|
static | createByFile ($filename) |
| Creates a stream reader instance by a filename.
|
|
static | createByString ($content, $maxMemory=2097152) |
| Creates a stream reader instance by a string value.
|
|
|
string | $buffer |
| The buffer.
|
|
int | $bufferLength |
| The buffer length.
|
|
bool | $closeStream |
| Defines whether the stream should be closed when the stream reader instance is deconstructed or not.
|
|
int | $offset |
| The byte-offset position in the buffer.
|
|
int | $position |
| The byte-offset position in the stream.
|
|
resource | $stream |
| The stream resource.
|
|
int | $totalLength |
| The total length of the stream.
|
|
◆ __construct()
StreamReader::__construct |
( |
| $stream, |
|
|
| $closeStream = false ) |
StreamReader constructor.
- Parameters
-
resource | $stream | |
bool | $closeStream | Defines whether to close the stream resource if the instance is destructed or not. |
◆ addOffset()
StreamReader::addOffset |
( |
| $offset | ) |
|
Add an offset to the current offset.
- Parameters
-
◆ createByFile()
static StreamReader::createByFile |
( |
| $filename | ) |
|
|
static |
Creates a stream reader instance by a filename.
- Parameters
-
- Return values
-
◆ createByString()
static StreamReader::createByString |
( |
| $content, |
|
|
| $maxMemory = 2097152 ) |
|
static |
Creates a stream reader instance by a string value.
- Parameters
-
string | $content | |
int | $maxMemory | |
- Return values
-
◆ ensure()
StreamReader::ensure |
( |
| $pos, |
|
|
| $length ) |
Ensures bytes in the buffer with a specific length and location in the file.
- Parameters
-
- See also
- reset()
◆ ensureContent()
StreamReader::ensureContent |
( |
| ) |
|
Make sure that there is at least one character beyond the current offset in the buffer.
- Return values
-
◆ getBuffer()
StreamReader::getBuffer |
( |
| $atOffset = true | ) |
|
Returns the current buffer.
- Parameters
-
- Return values
-
◆ getBufferLength()
StreamReader::getBufferLength |
( |
| $atOffset = false | ) |
|
Returns the byte length of the buffer.
- Parameters
-
- Return values
-
◆ getByte()
StreamReader::getByte |
( |
| $position = null | ) |
|
Gets a byte at a specific position in the buffer.
If the position is invalid the method will return false.
If the $position parameter is set to null the value of $this->offset will be used.
- Parameters
-
- Return values
-
◆ getOffset()
StreamReader::getOffset |
( |
| ) |
|
Returns the current offset in the current buffer.
- Return values
-
◆ getPosition()
StreamReader::getPosition |
( |
| ) |
|
Get the current position in the stream.
- Return values
-
◆ getStream()
StreamReader::getStream |
( |
| ) |
|
Returns the stream.
- Return values
-
◆ getTotalLength()
StreamReader::getTotalLength |
( |
| ) |
|
Gets the total available length.
- Return values
-
◆ increaseLength()
StreamReader::increaseLength |
( |
| $minLength = 100 | ) |
|
Forcefully read more data into the buffer.
- Parameters
-
- Return values
-
bool | Returns false if the stream reaches the end |
◆ readByte()
StreamReader::readByte |
( |
| $position = null | ) |
|
Returns a byte at a specific position, and set the offset to the next byte position.
If the position is invalid the method will return false.
If the $position parameter is set to null the value of $this->offset will be used.
- Parameters
-
- Return values
-
◆ readBytes()
StreamReader::readBytes |
( |
| $length, |
|
|
| $position = null ) |
Read bytes from the current or a specific offset position and set the internal pointer to the next byte.
If the position is invalid the method will return false.
If the $position parameter is set to null the value of $this->offset will be used.
- Parameters
-
int | $length | |
int | null | $position | |
- Return values
-
◆ readLine()
StreamReader::readLine |
( |
| $length = 1024 | ) |
|
Read a line from the current position.
- Parameters
-
- Return values
-
◆ reset()
StreamReader::reset |
( |
| $pos = 0, |
|
|
| $length = 200 ) |
Resets the buffer to a position and re-read the buffer with the given length.
If the $pos parameter is negative the start buffer position will be the $pos'th position from the end of the file.
If the $pos parameter is negative and the absolute value is bigger then the totalLength of the file $pos will set to zero.
- Parameters
-
int | null | $pos | Start position of the new buffer |
int | $length | Length of the new buffer. Mustn't be negative |
◆ setOffset()
StreamReader::setOffset |
( |
| $offset | ) |
|
Set the offset position in the current buffer.
- Parameters
-
The documentation for this class was generated from the following file:
- mod/assign/feedback/editpdf/fpdi/PdfParser/StreamReader.php