CCSDS 124.0-B-1 C++ 1.0.0
CCSDS 124.0-B-1 Lossless Compression
Loading...
Searching...
No Matches
ccsds124::BitBuffer< MaxBytes > Class Template Reference

Variable-length bit buffer with static allocation. More...

#include <bitbuffer.hpp>

Public Member Functions

constexpr BitBuffer () noexcept
 Default constructor - initializes to empty state.
 
void clear () noexcept
 Clear buffer to empty state.
 
std::size_t size () const noexcept
 Get number of bits in buffer.
 
Error append_bit (int bit) noexcept
 Append a single bit.
 
Error append_bits (const std::uint8_t *bytes, std::size_t num_bits) noexcept
 Append multiple bits from byte array.
 
Error append_value (std::uint32_t value, std::size_t num_bits) noexcept
 Append multiple bits from a value.
 
template<std::size_t N>
Error append_bitvector (const BitVector< N > &bv, std::size_t num_bits) noexcept
 Append bits from a BitVector.
 
template<std::size_t N>
Error append_bitvector (const BitVector< N > &bv) noexcept
 Append all bits from a BitVector.
 
std::size_t to_bytes (std::uint8_t *bytes, std::size_t max_bytes) const noexcept
 Convert bit buffer to byte array.
 

Detailed Description

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
class ccsds124::BitBuffer< MaxBytes >

Variable-length bit buffer with static allocation.

Template Parameters
MaxBytesMaximum output size in bytes

Uses static allocation only - no heap allocation. Suitable for embedded systems with -fno-exceptions -fno-rtti.

Definition at line 51 of file bitbuffer.hpp.

Constructor & Destructor Documentation

◆ BitBuffer()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
constexpr ccsds124::BitBuffer< MaxBytes >::BitBuffer ( )
inlineconstexprnoexcept

Default constructor - initializes to empty state.

Definition at line 56 of file bitbuffer.hpp.

Member Function Documentation

◆ append_bit()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
Error ccsds124::BitBuffer< MaxBytes >::append_bit ( int  bit)
inlinenoexcept

Append a single bit.

Parameters
bitBit value (0 or 1)
Returns
Error::Ok on success, Error::Overflow if buffer is full

Definition at line 82 of file bitbuffer.hpp.

References ccsds124::Ok, and ccsds124::Overflow.

Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().

◆ append_bits()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
Error ccsds124::BitBuffer< MaxBytes >::append_bits ( const std::uint8_t *  bytes,
std::size_t  num_bits 
)
inlinenoexcept

Append multiple bits from byte array.

Parameters
bytesSource bytes (MSB first within each byte)
num_bitsNumber of bits to append
Returns
Error::Ok on success

Definition at line 108 of file bitbuffer.hpp.

References ccsds124::BitBuffer< MaxBytes >::append_value(), ccsds124::Ok, and ccsds124::Overflow.

◆ append_bitvector() [1/2]

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
template<std::size_t N>
Error ccsds124::BitBuffer< MaxBytes >::append_bitvector ( const BitVector< N > &  bv)
inlinenoexcept

Append all bits from a BitVector.

Template Parameters
NBitVector length
Parameters
bvSource bit vector
Returns
Error::Ok on success

Definition at line 238 of file bitbuffer.hpp.

References ccsds124::BitBuffer< MaxBytes >::append_bitvector().

◆ append_bitvector() [2/2]

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
template<std::size_t N>
Error ccsds124::BitBuffer< MaxBytes >::append_bitvector ( const BitVector< N > &  bv,
std::size_t  num_bits 
)
inlinenoexcept

Append bits from a BitVector.

Template Parameters
NBitVector length
Parameters
bvSource bit vector
num_bitsNumber of bits to append
Returns
Error::Ok on success

Definition at line 177 of file bitbuffer.hpp.

References ccsds124::BitBuffer< MaxBytes >::append_value(), ccsds124::Ok, and ccsds124::Overflow.

Referenced by ccsds124::BitBuffer< MaxBytes >::append_bitvector(), and ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().

◆ append_value()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
Error ccsds124::BitBuffer< MaxBytes >::append_value ( std::uint32_t  value,
std::size_t  num_bits 
)
inlinenoexcept

Append multiple bits from a value.

Parameters
valueValue containing bits (right-justified)
num_bitsNumber of bits to append (1-24)
Returns
Error::Ok on success

Definition at line 144 of file bitbuffer.hpp.

References ccsds124::InvalidArg, ccsds124::Ok, and ccsds124::Overflow.

Referenced by ccsds124::BitBuffer< MaxBytes >::append_bits(), ccsds124::BitBuffer< MaxBytes >::append_bitvector(), and ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().

◆ clear()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
void ccsds124::BitBuffer< MaxBytes >::clear ( )
inlinenoexcept

Clear buffer to empty state.

Definition at line 61 of file bitbuffer.hpp.

Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().

◆ size()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
std::size_t ccsds124::BitBuffer< MaxBytes >::size ( ) const
inlinenoexcept

Get number of bits in buffer.

Returns
Number of bits currently stored

Definition at line 72 of file bitbuffer.hpp.

◆ to_bytes()

template<std::size_t MaxBytes = MAX_OUTPUT_BYTES>
std::size_t ccsds124::BitBuffer< MaxBytes >::to_bytes ( std::uint8_t *  bytes,
std::size_t  max_bytes 
) const
inlinenoexcept

Convert bit buffer to byte array.

Pads final byte with zeros if not byte-aligned.

Parameters
bytesDestination byte array
max_bytesMaximum bytes to write
Returns
Number of bytes written

Definition at line 251 of file bitbuffer.hpp.

Referenced by ccsds124::compress().


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