Skip to content

Commit

Permalink
- add write/read Int64BE Int64LE
Browse files Browse the repository at this point in the history
  • Loading branch information
t3ran13 committed Oct 20, 2020
1 parent 2d9ab76 commit 1cbc758
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/t3ran13/ByteBuffer/ByteBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ public function writeInt32LE($value, $offset = null) {
$this->insert($format, $value, $offset, $this->lengthMap->getLengthFor($format));
}

public function writeInt64BE($value, $offset = null) {
$format = 'J';
$this->checkForOverSize(0xffffffffffffffff, $value);
$this->insert($format, $value, $offset, $this->lengthMap->getLengthFor($format));
}

public function writeInt64LE($value, $offset = null) {
$format = 'P';
$this->checkForOverSize(0xffffffffffffffff, $value);
$this->insert($format, $value, $offset, $this->lengthMap->getLengthFor($format));
}

public function read($offset, $length) {
$format = 'a' . $length;
return $this->extract($format, $offset, $length);
Expand Down Expand Up @@ -233,4 +245,14 @@ public function readInt32LE($offset) {
return $this->extract($format, $offset, $this->lengthMap->getLengthFor($format));
}

public function readInt64BE($offset) {
$format = 'J';
return $this->extract($format, $offset, $this->lengthMap->getLengthFor($format));
}

public function readInt64LE($offset) {
$format = 'P';
return $this->extract($format, $offset, $this->lengthMap->getLengthFor($format));
}

}

0 comments on commit 1cbc758

Please sign in to comment.