|
1 |
| -# `php-buffer` -> Read And Write Binary Data |
| 1 | +# `nelexa/buffer` -> Read And Write Binary Data |
| 2 | + |
| 3 | +[](https://packagist.org/packages/nelexa/buffer) |
| 4 | +[](https://packagist.org/packages/nelexa/buffer) |
| 5 | +[](https://travis-ci.org/Ne-Lexa/php-buffer) |
| 6 | +[](https://packagist.org/packages/nelexa/buffer) |
2 | 7 |
|
3 | 8 | This is classes defines methods for **reading and writing** values of all primitive types. Primitive values are translated to (or from) sequences of bytes according to the buffer's current byte order, which may be retrieved and modified via the order methods. The initial order of a byte buffer is always Buffer::BIG_ENDIAN.
|
4 | 9 |
|
@@ -50,7 +55,7 @@ Checking the possibility of recording in the buffer
|
50 | 55 | $boolValue = $buffer->isReadOnly();
|
51 | 56 | ```
|
52 | 57 |
|
53 |
| -Modifies this buffer's byte order, either Buffer::BIG_ENDIAN or Buffer::LITTLE_ENDIAN |
| 58 | +Modifies this buffer's byte order, either `Buffer::BIG_ENDIAN` or `Buffer::LITTLE_ENDIAN` |
54 | 59 | ```php
|
55 | 60 | $buffer->setOrder(\Nelexa\Buffer::LITTLE_ENDIAN);
|
56 | 61 | ```
|
@@ -94,6 +99,8 @@ $buffer->skipByte(); // skip 1 byte
|
94 | 99 | $buffer->skipShort(); // skip 2 bytes
|
95 | 100 | $buffer->skipInt(); // skip 4 bytes
|
96 | 101 | $buffer->skipLong(); // skip 8 bytes
|
| 102 | +$buffer->skipFloat(); // skip 4 bytes |
| 103 | +$buffer->skipDouble(); // skip 8 bytes |
97 | 104 | ```
|
98 | 105 |
|
99 | 106 | Rewinds this buffer. The position is set to zero.
|
@@ -187,6 +194,8 @@ Method | Type | Values
|
187 | 194 | `$buffer->getInt()` | int (4 bytes) | -2147483648 ... 2147483647
|
188 | 195 | `$buffer->getUnsignedInt()` | unsigned int (uint) | 0 ... 4294967296
|
189 | 196 | `$buffer->getLong()` | long (8 bytes) | -9223372036854775808 ... 9223372036854775807
|
| 197 | +`$buffer->getFloat()` | float (4 bytes) | single-precision 32-bit IEEE 754 floating point number |
| 198 | +`$buffer->getDouble()` | double (5 bytes) | double-precision 64-bit IEEE 754 floating point number |
190 | 199 | `$buffer->getArrayBytes($length)` | byte[] | `array`
|
191 | 200 | `$buffer->getString($length)` | string (length bytes) | `string`
|
192 | 201 | `$buffer->getUTF()` | string | `string`
|
@@ -235,6 +244,14 @@ Insert long value (-9223372036854775808 >= long <= 9223372036854775807). Change
|
235 | 244 | ```php
|
236 | 245 | $buffer->insertLong($longValue);
|
237 | 246 | ```
|
| 247 | +Insert float value (single-precision 32-bit IEEE 754 floating point number). Change position +4. |
| 248 | +```php |
| 249 | +$buffer->insertFloat($floatValue); |
| 250 | +``` |
| 251 | +Insert double value (double-precision 64-bit IEEE 754 floating point number). Change position +8. |
| 252 | +```php |
| 253 | +$buffer->insertDouble($doubleValue); |
| 254 | +``` |
238 | 255 | Insert array bytes. Change size and position by +(size array).
|
239 | 256 | ```php
|
240 | 257 | $buffer->insertArrayBytes($bytes);
|
@@ -293,6 +310,14 @@ Put long value (-9223372036854775808 >= long <= 9223372036854775807). Change pos
|
293 | 310 | ```php
|
294 | 311 | $buffer->putLong($longValue);
|
295 | 312 | ```
|
| 313 | +Put float value (single-precision 32-bit IEEE 754 floating point number). Change position +4. |
| 314 | +```php |
| 315 | +$buffer->putFloat($floatValue); |
| 316 | +``` |
| 317 | +Put double value (double-precision 64-bit IEEE 754 floating point number). Change position +8. |
| 318 | +```php |
| 319 | +$buffer->putDouble($doubleValue); |
| 320 | +``` |
296 | 321 | Put array bytes. Change position by +(size array).
|
297 | 322 | ```php
|
298 | 323 | $buffer->putArrayBytes($bytes);
|
@@ -351,6 +376,14 @@ Replace by long value (-9223372036854775808 >= long <= 9223372036854775807). Cha
|
351 | 376 | ```php
|
352 | 377 | $buffer->replaceLong($longValue, $length);
|
353 | 378 | ```
|
| 379 | +Replace by float value (single-precision 32-bit IEEE 754 floating point number). Change size by (-$length + 4) and position +4. |
| 380 | +```php |
| 381 | +$buffer->replaceFloat($floatValue, $length); |
| 382 | +``` |
| 383 | +Replace by double value (double-precision 64-bit IEEE 754 floating point number). Change size by (-$length + 8) and position +8. |
| 384 | +```php |
| 385 | +$buffer->replaceDouble($doubleValue, $length); |
| 386 | +``` |
354 | 387 | Replace by array bytes. Change size by (-$length + size array) and position +(size array).
|
355 | 388 | ```php
|
356 | 389 | $buffer->replaceArrayBytes($bytes, $length);
|
|
0 commit comments