2008-04-29 12:55:25 +00:00
|
|
|
// Write bits into a bit stream. See BitStream for reading.
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#ifndef BITWRITER_HH
|
|
|
|
#define BITWRITER_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2023-05-20 11:22:32 +00:00
|
|
|
#include <cstddef>
|
2009-09-26 15:19:12 +00:00
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
class Pipeline;
|
|
|
|
|
2009-10-21 00:27:24 +00:00
|
|
|
class BitWriter
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Write bits to the pipeline. It is the caller's responsibility to eventually call finish on
|
|
|
|
// the pipeline.
|
|
|
|
BitWriter(Pipeline* pl);
|
2019-06-21 03:35:23 +00:00
|
|
|
void writeBits(unsigned long long val, size_t bits);
|
|
|
|
void writeBitsSigned(long long val, size_t bits);
|
|
|
|
void writeBitsInt(int val, size_t bits);
|
2008-04-29 12:55:25 +00:00
|
|
|
// Force any partial byte to be written to the pipeline.
|
|
|
|
void flush();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Pipeline* pl;
|
|
|
|
unsigned char ch;
|
2019-06-21 03:35:23 +00:00
|
|
|
size_t bit_offset;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // BITWRITER_HH
|