| @@ 52-67 (lines=16) @@ | ||
| 49 | * |
|
| 50 | * @return int |
|
| 51 | */ |
|
| 52 | public function readUnsignedInteger16() |
|
| 53 | { |
|
| 54 | switch ($this->getByteOrder()) { |
|
| 55 | case ByteOrder::BIG_ENDIAN: |
|
| 56 | $format = 'n'; |
|
| 57 | break; |
|
| 58 | case ByteOrder::LITTLE_ENDIAN: |
|
| 59 | $format = 'v'; |
|
| 60 | break; |
|
| 61 | default: |
|
| 62 | $format = 'S'; |
|
| 63 | } |
|
| 64 | ||
| 65 | list(, $value) = unpack($format, $this->read(2)); |
|
| 66 | return $value; |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Read signed 16-bit integer (short) data from the stream |
|
| @@ 154-169 (lines=16) @@ | ||
| 151 | * |
|
| 152 | * @return int |
|
| 153 | */ |
|
| 154 | public function readUnsignedInteger32() |
|
| 155 | { |
|
| 156 | switch ($this->getByteOrder()) { |
|
| 157 | case ByteOrder::BIG_ENDIAN: |
|
| 158 | $format = 'N'; |
|
| 159 | break; |
|
| 160 | case ByteOrder::LITTLE_ENDIAN: |
|
| 161 | $format = 'V'; |
|
| 162 | break; |
|
| 163 | default: |
|
| 164 | $format = 'L'; |
|
| 165 | } |
|
| 166 | ||
| 167 | list(, $value) = unpack($format, $this->read(4)); |
|
| 168 | return $value; |
|
| 169 | } |
|
| 170 | ||
| 171 | /** |
|
| 172 | * Read signed 32-bit integer (long) data from the stream |
|
| @@ 195-210 (lines=16) @@ | ||
| 192 | * |
|
| 193 | * @return int |
|
| 194 | */ |
|
| 195 | public function readUnsignedInteger64() |
|
| 196 | { |
|
| 197 | switch ($this->getByteOrder()) { |
|
| 198 | case ByteOrder::BIG_ENDIAN: |
|
| 199 | $format = 'J'; |
|
| 200 | break; |
|
| 201 | case ByteOrder::LITTLE_ENDIAN: |
|
| 202 | $format = 'P'; |
|
| 203 | break; |
|
| 204 | default: |
|
| 205 | $format = 'Q'; |
|
| 206 | } |
|
| 207 | ||
| 208 | list(, $value) = unpack($format, $this->read(8)); |
|
| 209 | return $value; |
|
| 210 | } |
|
| 211 | ||
| 212 | /** |
|
| 213 | * Read signed 64-bit integer (long long) data from the stream |
|
| @@ 56-70 (lines=15) @@ | ||
| 53 | * |
|
| 54 | * @return int |
|
| 55 | */ |
|
| 56 | public function writeUnsignedInteger16($data) |
|
| 57 | { |
|
| 58 | switch ($this->getByteOrder()) { |
|
| 59 | case ByteOrder::BIG_ENDIAN: |
|
| 60 | $format = 'n'; |
|
| 61 | break; |
|
| 62 | case ByteOrder::LITTLE_ENDIAN: |
|
| 63 | $format = 'v'; |
|
| 64 | break; |
|
| 65 | default: |
|
| 66 | $format = 'S'; |
|
| 67 | } |
|
| 68 | ||
| 69 | return $this->write(pack($format, $data)); |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Write signed 16-bit integer (short) data to the stream |
|
| @@ 97-111 (lines=15) @@ | ||
| 94 | * |
|
| 95 | * @return int |
|
| 96 | */ |
|
| 97 | public function writeUnsignedInteger32($data) |
|
| 98 | { |
|
| 99 | switch ($this->getByteOrder()) { |
|
| 100 | case ByteOrder::BIG_ENDIAN: |
|
| 101 | $format = 'N'; |
|
| 102 | break; |
|
| 103 | case ByteOrder::LITTLE_ENDIAN: |
|
| 104 | $format = 'V'; |
|
| 105 | break; |
|
| 106 | default: |
|
| 107 | $format = 'L'; |
|
| 108 | } |
|
| 109 | ||
| 110 | return $this->write(pack($format, $data)); |
|
| 111 | } |
|
| 112 | ||
| 113 | /** |
|
| 114 | * Write signed 32-bit integer (long) data to the stream |
|
| @@ 138-152 (lines=15) @@ | ||
| 135 | * |
|
| 136 | * @return int |
|
| 137 | */ |
|
| 138 | public function writeUnsignedInteger64($data) |
|
| 139 | { |
|
| 140 | switch ($this->getByteOrder()) { |
|
| 141 | case ByteOrder::BIG_ENDIAN: |
|
| 142 | $format = 'J'; |
|
| 143 | break; |
|
| 144 | case ByteOrder::LITTLE_ENDIAN: |
|
| 145 | $format = 'P'; |
|
| 146 | break; |
|
| 147 | default: |
|
| 148 | $format = 'Q'; |
|
| 149 | } |
|
| 150 | ||
| 151 | return $this->write(pack($format, $data)); |
|
| 152 | } |
|
| 153 | ||
| 154 | /** |
|
| 155 | * Write signed 64-bit integer (long long) data to the stream |
|