Pack a set of values bitwise into a stream. More...
#include <BitPacker.h>
Public Member Functions | |
BitPacker (uint8_t nbits, STREAM &stream) | |
Constructor. | |
~BitPacker () | |
Destructor. | |
void | pack (uint32_t x) |
Pack one value to the stream. |
Pack a set of values bitwise into a stream.
This helper can be used to pack a set of values into 32-bit words and write them to a stream. The number of bits taken by each value is configurable.
STREAM
should support output (operator<<) with uint32_t
(satisfied by a ROOT TBuffer).
CxxUtils::BitPacker< STREAM >::BitPacker | ( | uint8_t | nbits, | |
STREAM & | stream | |||
) | [inline] |
Constructor.
nbits | Number of bits per item to use in the packed representation. | |
stream | Output stream object. |
CxxUtils::BitPacker< STREAM >::~BitPacker | ( | ) | [inline] |
Destructor.
This may flush buffered data to the output stream.
void CxxUtils::BitPacker< STREAM >::pack | ( | uint32_t | dat | ) | [inline] |
Pack one value to the stream.
x | The value to pack. The upper bits should all be clear. |