ReXGlue SDK
Loading...
Searching...
No Matches
rex::memory::BitStream Class Reference

#include <rex/memory/stream.h>

Public Member Functions

 BitStream (u8 *buffer, size_t size_in_bits)
const u8 * GetBuffer () const
u8 * GetBuffer ()
size_t GetOffsetBits () const
size_t GetSizeBits () const
void Advance (size_t num_bits)
void SetOffset (size_t offset_bits)
size_t GetBitsRemaining () const
u64 Peek (size_t num_bits)
u64 Read (size_t num_bits)
bool Write (u64 val, size_t num_bits)
size_t Copy (u8 *dest_buffer, size_t num_bits)

Detailed Description

Bit cursor over a buffer the caller owns. Bits are read most significant bit first.

Constructor & Destructor Documentation

◆ BitStream()

rex::memory::BitStream::BitStream ( u8 * buffer,
size_t size_in_bits )

Wraps a buffer.

Parameters
size_in_bitsSize of buffer in bits.

Member Function Documentation

◆ Copy()

size_t rex::memory::BitStream::Copy ( u8 * dest_buffer,
size_t num_bits )

Copies bits from the cursor into a byte buffer and moves past them.

Returns
Bit offset of the cursor within its byte before the copy.

◆ Peek()

u64 rex::memory::BitStream::Peek ( size_t num_bits)

Reads bits at the cursor without moving it.

Parameters
num_bitsBit count, 0 to 57.
Returns
The bits, right aligned.

◆ Read()

u64 rex::memory::BitStream::Read ( size_t num_bits)

Reads bits at the cursor and moves past them.

Parameters
num_bitsBit count, 0 to 57.
Returns
The bits, right aligned.

◆ SetOffset()

void rex::memory::BitStream::SetOffset ( size_t offset_bits)

Moves the cursor, clamped to the buffer size.

◆ Write()

bool rex::memory::BitStream::Write ( u64 val,
size_t num_bits )

Writes bits at the cursor and moves past them.

Parameters
valBits to write, right aligned.
num_bitsBit count, 0 to 57.

The documentation for this class was generated from the following file: