| @@ 433-448 (lines=16) @@ | ||
| 430 | * |
|
| 431 | * @return int |
|
| 432 | */ |
|
| 433 | public function readUInt16() |
|
| 434 | { |
|
| 435 | switch ($this->getByteOrder()) { |
|
| 436 | case ByteOrder::BIG_ENDIAN: |
|
| 437 | $format = 'n'; |
|
| 438 | break; |
|
| 439 | case ByteOrder::LITTLE_ENDIAN: |
|
| 440 | $format = 'v'; |
|
| 441 | break; |
|
| 442 | default: |
|
| 443 | $format = 'S'; |
|
| 444 | } |
|
| 445 | ||
| 446 | list(, $value) = unpack($format, $this->read(2)); |
|
| 447 | return $value; |
|
| 448 | } |
|
| 449 | ||
| 450 | /** |
|
| 451 | * Read signed 24-bit integer (short) data from the stream. |
|
| @@ 528-543 (lines=16) @@ | ||
| 525 | * |
|
| 526 | * @return int |
|
| 527 | */ |
|
| 528 | public function readUInt32() |
|
| 529 | { |
|
| 530 | switch ($this->getByteOrder()) { |
|
| 531 | case ByteOrder::BIG_ENDIAN: |
|
| 532 | $format = 'N'; |
|
| 533 | break; |
|
| 534 | case ByteOrder::LITTLE_ENDIAN: |
|
| 535 | $format = 'V'; |
|
| 536 | break; |
|
| 537 | default: |
|
| 538 | $format = 'L'; |
|
| 539 | } |
|
| 540 | ||
| 541 | list(, $value) = unpack($format, $this->read(4)); |
|
| 542 | return $value; |
|
| 543 | } |
|
| 544 | ||
| 545 | /** |
|
| 546 | * Read signed 64-bit integer (long long) data from the stream. |
|
| @@ 577-592 (lines=16) @@ | ||
| 574 | * |
|
| 575 | * @return int |
|
| 576 | */ |
|
| 577 | public function readUInt64() |
|
| 578 | { |
|
| 579 | switch ($this->getByteOrder()) { |
|
| 580 | case ByteOrder::BIG_ENDIAN: |
|
| 581 | $format = 'J'; |
|
| 582 | break; |
|
| 583 | case ByteOrder::LITTLE_ENDIAN: |
|
| 584 | $format = 'P'; |
|
| 585 | break; |
|
| 586 | default: |
|
| 587 | $format = 'Q'; |
|
| 588 | } |
|
| 589 | ||
| 590 | list(, $value) = unpack($format, $this->read(8)); |
|
| 591 | return $value; |
|
| 592 | } |
|
| 593 | ||
| 594 | /** |
|
| 595 | * Write data to the stream and return the number of bytes written. |
|