c2ephp
|
Class to read from strings in the same way as files. More...
Public Member Functions | |
StringReader ($string) | |
Creates a new StringReader for the given string. | |
Read ($characters) | |
Reads a string. | |
ReadCString () | |
Reads a c-style string at the current position. | |
Seek ($position) | |
Changes the current position in the reader's stream. | |
Skip ($count) | |
Advances the position of the reader by $count. | |
ReadInt ($characters) | |
Reads an integer. | |
GetPosition () | |
Gets the position of the cursor. | |
GetSubString ($start, $length=FALSE) | |
Gets a substring. |
Class to read from strings in the same way as files.
This is a convenience class to allow strings to be treated in the same way as files. You won't generally have to create these yourself, but if you want to, go ahead.
Definition at line 9 of file StringReader.php.
StringReader::GetPosition | ( | ) |
Gets the position of the cursor.
This is analagous to ftell in C or PHP.
Implements IReader.
Definition at line 56 of file StringReader.php.
StringReader::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.
Implements IReader.
Definition at line 59 of file StringReader.php.
StringReader::Read | ( | $ | length | ) |
Reads a string.
$length | Length of the string to read in bytes |
Implements IReader.
Definition at line 25 of file StringReader.php.
StringReader::ReadCString | ( | ) |
Reads a c-style string at the current position.
C-style means that the string is terminated by a NUL (0) character.
Implements IReader.
Definition at line 37 of file StringReader.php.
StringReader::ReadInt | ( | $ | length | ) |
Reads an integer.
$length | Length of the integer in bytes. |
Implements IReader.
Definition at line 53 of file StringReader.php.
StringReader::Seek | ( | $ | position | ) |
Changes the current position in the reader's stream.
This is analagous to fseek in C or PHP.
Implements IReader.
Definition at line 47 of file StringReader.php.
StringReader::Skip | ( | $ | count | ) |
Advances the position of the reader by $count.
Implements IReader.
Definition at line 50 of file StringReader.php.
StringReader::StringReader | ( | $ | string | ) |
Creates a new StringReader for the given string.
Initialises the position to 0.
Definition at line 21 of file StringReader.php.