SetaPDF_Core_Reader_AbstractReader An abstract reader class

File: /SetaPDF v2/Core/Reader/AbstractReader.php

Class hierarchy

Summary

Properties

$_buffer

The current buffer

$_length

The length of the buffer

$_offset

The offset to the current position

$_pos

The current file position

$_totalLength

The total length


Methods

addOffset()

public SetaPDF_Core_Reader_AbstractReader::addOffset (
int $offset
): void

Add an offset to the current offset.

Parameters
$offset : int
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

ensure()

public SetaPDF_Core_Reader_AbstractReader::ensure (
int $pos,
int $length
): void

Ensures bytes in the buffer with a specific length and location in the file.

Parameters
$pos : int
 
$length : int
 
See

ensureContent()

Make sure that there is at least one character beyond the current offset in the buffer.

getBuffer()

public SetaPDF_Core_Reader_AbstractReader::getBuffer (
bool $atOffset = true
): string

Returns the current buffer.

Parameters
$atOffset : bool
 

getByte()

public SetaPDF_Core_Reader_AbstractReader::getByte (
int $pos = null
): string|bool

Gets a byte at a specific position.

If the position is invalid the method will return false.

If non position is set $this->_offset will used.

Parameters
$pos : int
 

getLength()

public SetaPDF_Core_Reader_AbstractReader::getLength (
bool $atOffset = false
): int

Returns the byte length of the buffer.

Parameters
$atOffset : bool
 

getOffset()

Returns the current offset of the current position.

getPos()

Get the current position of the pointer.

increaseLength()

abstract public SetaPDF_Core_Reader_AbstractReader::increaseLength (
int $minLength = 100
): void

Forcefully read more data into the buffer.

Parameters
$minLength : int
 

readByte()

public SetaPDF_Core_Reader_AbstractReader::readByte (
int $pos = null
): string|bool

Returns a byte at a specific position, returns it and set the offset to the next byte position.

If the position is invalid the method will return false.

If non position is set $this->_offset will used.

Parameters
$pos : int
 

readBytes()

public SetaPDF_Core_Reader_AbstractReader::readBytes (
int $length,
int $pos = null
): string|bool

Get a specific byte count from the current or at a specific offset position and set the internal pointer to the next byte.

If the position is invalid the method will return false.

If non position is set $this->_offset will used.

Parameters
$length : int
 
$pos : int
 

readLine()

public SetaPDF_Core_Reader_AbstractReader::readLine (
int $length = 1024
): string|false

Read a line from the current position.

Parameters
$length : int
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

reset()

abstract public SetaPDF_Core_Reader_AbstractReader::reset (
?int $pos,
int $length = 200
): void

Resets the buffer to a specific position and reread the buffer with the given length.

If the $pos is negative the start buffer position will be the $pos'th position from the end of the file.

If the $pos is negative and the absolute value is bigger then the totalLength of the file $pos will set to zero.

Parameters
$pos : ?int

Start position of the new buffer

$length : int

Length of the new buffer. Mustn't be negative

setOffset()

public SetaPDF_Core_Reader_AbstractReader::setOffset (
int $offset
): void

Set the offset position.

Parameters
$offset : int
 
Exceptions

Throws SetaPDF_Core_Reader_Exception