c2ephp
|
Interface for reading data. More...
Public Member Functions | |
ReadInt ($length) | |
Reads an integer. | |
Read ($length) | |
Reads a string. | |
GetSubString ($start, $length=FALSE) | |
Gets a substring. | |
GetPosition () | |
Gets the position of the cursor. | |
Seek ($position) | |
Changes the current position in the reader's stream. | |
Skip ($count) | |
Advances the position of the reader by $count. | |
ReadCString () | |
Reads a c-style string at the current position. |
Interface for reading data.
This is implemented by StringReader and FileReader to allow the main c2ephp classes to read data from strings and files with a consistent and simple OO interface.
IReaders work a bit like file handles: they store a position and all their functions are based around that position.
Definition at line 12 of file IReader.php.
IReader::GetPosition | ( | ) |
Gets the position of the cursor.
This is analagous to ftell in C or PHP.
Implemented in FileReader, and StringReader.
IReader::GetSubString | ( | $ | start, |
$ | length = FALSE |
||
) |
Gets a substring.
This function is to allow things like PRAYFile to pull out a big chunk of data and then initialise a new StringReader to deal with it. It's not the most efficient way of doing things memory-wise, but it simplifies the code and c2e files don't tend to get big enough to make this inefficiency a concern on any reasonably modern hardware.
Implemented in FileReader, and StringReader.
IReader::Read | ( | $ | length | ) |
Reads a string.
$length | Length of the string to read in bytes |
Implemented in FileReader, and StringReader.
IReader::ReadCString | ( | ) |
Reads a c-style string at the current position.
C-style means that the string is terminated by a NUL (0) character.
Implemented in FileReader, and StringReader.
IReader::ReadInt | ( | $ | length | ) |
Reads an integer.
$length | Length of the integer in bytes. |
Implemented in FileReader, and StringReader.
IReader::Seek | ( | $ | position | ) |
Changes the current position in the reader's stream.
This is analagous to fseek in C or PHP.
Implemented in FileReader, and StringReader.
IReader::Skip | ( | $ | count | ) |
Advances the position of the reader by $count.
Implemented in FileReader, and StringReader.