31namespace data_compression
38template <
typename CodeType, std::
size_t Length = 8 * sizeof(CodeType)>
43 static_assert(Length <= 8 *
sizeof(
code_type),
"CodeType must allow specified bit length");
49 template <
typename ValueType,
typename WriterType>
64template <
typename TargetType,
class Codec = CodecIdentity<TargetType>>
76 assert(mFilledBits == 0);
96 template <
typename WriterT>
100 if (mFilledBits > 0) {
117 template <
typename ValueType,
typename WriterT>
120 auto bitsToWrite = bitlength;
121 if (bitlength > 8 *
sizeof(ValueType)) {
123 throw std::runtime_error(
"bit length exceeds width of the data type");
125 while (bitsToWrite > 0) {
132 auto writeNow = bitsToWrite;
139 if (writeNow > capacity) {
142 auto mask = (((ValueType)1 << writeNow) - 1) << (bitsToWrite - writeNow);
143 auto activebits = (
value &
mask) >> (bitsToWrite - writeNow);
144 mCurrent |= activebits << (capacity - writeNow);
145 mFilledBits += writeNow;
146 bitsToWrite -= writeNow;
149 return bitlength - bitsToWrite;
152 template <
typename T,
typename WriterT>
155 using RegType =
typename Codec::code_type;
157 value, [&,
this](RegType code, uint16_t codelength) ->
int {
return this->
writeRaw(code, codelength, writer); });
181 unsigned mFilledBits;
int write(ValueType v, WriterType writer)
static const std::size_t sMaxLength
int close(WriterT &writer)
int write(T value, WriterT writer)
int writeRaw(ValueType value, uint16_t bitlength, WriterT writer)
std::function< bool(const target_type &)> Writer
static const std::size_t TargetBitWidth
GLsizei const GLfloat * value
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...