@@ -12,13 +12,14 @@ discard block |
||
| 12 | 12 | interface IReader { |
| 13 | 13 | /// @brief Reads an integer |
| 14 | 14 | /** |
| 15 | - * @param $length Length of the integer in bytes. |
|
| 15 | + * @param integer $length Length of the integer in bytes. |
|
| 16 | 16 | */ |
| 17 | 17 | public function ReadInt($length); |
| 18 | 18 | |
| 19 | 19 | /// @brief Reads a string |
| 20 | 20 | /** |
| 21 | 21 | * @param $length Length of the string to read in bytes |
| 22 | + * @return string|false |
|
| 22 | 23 | */ |
| 23 | 24 | public function Read($length); |
| 24 | 25 | |
@@ -30,24 +31,32 @@ discard block |
||
| 30 | 31 | * memory-wise, but it simplifies the code and c2e files don't |
| 31 | 32 | * tend to get big enough to make this inefficiency a concern on |
| 32 | 33 | * any reasonably modern hardware. |
| 34 | + * @return string |
|
| 33 | 35 | */ |
| 34 | 36 | public function GetSubString($start,$length=FALSE); |
| 35 | 37 | /// @brief Gets the position of the cursor |
| 36 | 38 | /** |
| 37 | 39 | * This is analagous to ftell in C or PHP. |
| 40 | + * @return integer |
|
| 38 | 41 | */ |
| 39 | 42 | public function GetPosition(); |
| 40 | 43 | /// @brief Changes the current position in the reader's stream |
| 41 | 44 | /** |
| 42 | 45 | * This is analagous to fseek in C or PHP. |
| 46 | + * @return void |
|
| 43 | 47 | */ |
| 44 | 48 | public function Seek($position); |
| 45 | 49 | /// @brief Advances the position of the reader by $count. |
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @return void |
|
| 53 | + */ |
|
| 46 | 54 | public function Skip($count); |
| 47 | 55 | /// @brief Reads a c-style string at the current position. |
| 48 | 56 | /** |
| 49 | 57 | * C-style means that the string is terminated by a NUL (0) |
| 50 | 58 | * character. |
| 59 | + * @return string |
|
| 51 | 60 | */ |
| 52 | 61 | public function ReadCString(); //read a string of unknown length until the first NUL |
| 53 | 62 | } |
@@ -50,12 +50,20 @@ discard block |
||
| 50 | 50 | public function Skip($count) { |
| 51 | 51 | $this->position += $count; |
| 52 | 52 | } |
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param integer $characters |
|
| 56 | + */ |
|
| 53 | 57 | public function ReadInt($characters) { |
| 54 | 58 | return BytesToIntLilEnd($this->Read($characters)); |
| 55 | 59 | } |
| 56 | 60 | public function GetPosition() { |
| 57 | 61 | return $this->position; |
| 58 | 62 | } |
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @param integer $start |
|
| 66 | + */ |
|
| 59 | 67 | public function GetSubString($start,$length = FALSE) { |
| 60 | 68 | if($length == FALSE) { |
| 61 | 69 | $length = strlen($this->string)-$start; |
@@ -65,6 +73,9 @@ discard block |
||
| 65 | 73 | } |
| 66 | 74 | } |
| 67 | 75 | |
| 76 | +/** |
|
| 77 | + * @param false|string $string |
|
| 78 | + */ |
|
| 68 | 79 | function BytesToIntLilEnd($string) { //little endian |
| 69 | 80 | if($string == "") { |
| 70 | 81 | return false; |