BitBuffer
in package
FinalYes
Holds the raw binary data
Table of Contents
Properties
- $bitsRead : int
- Read count (bits)
- $buffer : array<string|int, int>
- The buffer content
- $bytesRead : int
- Read count (bytes)
- $length : int
- Length of the content (bits)
Methods
- __construct() : mixed
- BitBuffer constructor.
- available() : int
- Returns the number of bits that can be read successfully
- clear() : self
- Clears the buffer and resets the stats
- getBuffer() : array<string|int, int>
- returns the buffer content
- getLength() : int
- returns the current buffer length
- put() : self
- appends a sequence of bits
- putBit() : self
- appends a single bit
- read() : int
- rewind() : self
- Resets the read-counters
Properties
$bitsRead
Read count (bits)
private
int
$bitsRead
= 0
$buffer
The buffer content
private
array<string|int, int>
$buffer
$bytesRead
Read count (bytes)
private
int
$bytesRead
= 0
$length
Length of the content (bits)
private
int
$length
Methods
__construct()
BitBuffer constructor.
public
__construct([array<string|int, int> $bytes = [] ]) : mixed
Parameters
- $bytes : array<string|int, int> = []
available()
Returns the number of bits that can be read successfully
public
available() : int
Return values
intclear()
Clears the buffer and resets the stats
public
clear() : self
Return values
selfgetBuffer()
returns the buffer content
public
getBuffer() : array<string|int, int>
to debug: array_map(fn($v) => sprintf('%08b', $v), $bitBuffer->getBuffer())
Return values
array<string|int, int>getLength()
returns the current buffer length
public
getLength() : int
Return values
intput()
appends a sequence of bits
public
put(int $bits, int $length) : self
Parameters
- $bits : int
- $length : int
Return values
selfputBit()
appends a single bit
public
putBit(bool $bit) : self
Parameters
- $bit : bool
Return values
selfread()
public
read(int $numBits) : int
Parameters
- $numBits : int
-
number of bits to read
Tags
Return values
int —representing the bits read. The bits will appear as the least-significant bits of the int
rewind()
Resets the read-counters
public
rewind() : self