Kodi Documentation 23.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CBitReader Class Reference

Reads a byte buffer as a stream of bits, most significant bit first. More...

#include <BitReader.h>

Public Member Functions

 CBitReader (std::span< const uint8_t > data) noexcept
 
 CBitReader (std::span< const std::byte > data) noexcept
 
uint32_t ReadBits (unsigned int n) noexcept
 Reads n bits, up to 32.
 
void SkipBits (size_t n) noexcept
 
uint32_t ReadUE (uint32_t max=UINT32_MAX - 1) noexcept
 Reads an unsigned Exp-Golomb code. A value above max is an error.
 
int32_t ReadSE () noexcept
 Reads a signed Exp-Golomb code.
 
void SkipUE () noexcept
 
void SkipSE () noexcept
 
void ByteAlign () noexcept
 
size_t Position () const noexcept
 The number of bits read or skipped.
 
size_t BitsLeft () const noexcept
 
bool Error () const noexcept
 

Detailed Description

Reads a byte buffer as a stream of bits, most significant bit first.

A read or skip that does not fit sets Error() and leaves the position unchanged. The error is sticky: once set, every read returns 0 and every skip does nothing, so a caller can parse a whole structure and check Error() once at the end.

Constructor & Destructor Documentation

◆ CBitReader() [1/2]

CBitReader::CBitReader ( std::span< const uint8_t > data)
inlineexplicitnoexcept

◆ CBitReader() [2/2]

CBitReader::CBitReader ( std::span< const std::byte > data)
inlineexplicitnoexcept

Member Function Documentation

◆ BitsLeft()

size_t CBitReader::BitsLeft ( ) const
inlinenoexcept

◆ ByteAlign()

void CBitReader::ByteAlign ( )
inlinenoexcept

◆ Error()

bool CBitReader::Error ( ) const
inlinenoexcept

◆ Position()

size_t CBitReader::Position ( ) const
inlinenoexcept

The number of bits read or skipped.

◆ ReadBits()

uint32_t CBitReader::ReadBits ( unsigned int n)
inlinenoexcept

Reads n bits, up to 32.

◆ ReadSE()

int32_t CBitReader::ReadSE ( )
inlinenoexcept

Reads a signed Exp-Golomb code.

◆ ReadUE()

uint32_t CBitReader::ReadUE ( uint32_t max = UINT32_MAX - 1)
inlinenoexcept

Reads an unsigned Exp-Golomb code. A value above max is an error.

◆ SkipBits()

void CBitReader::SkipBits ( size_t n)
inlinenoexcept

◆ SkipSE()

void CBitReader::SkipSE ( )
inlinenoexcept

◆ SkipUE()

void CBitReader::SkipUE ( )
inlinenoexcept

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