1 #ifndef ZSERIO_BIT_STREAM_WRITER_H_INC
2 #define ZSERIO_BIT_STREAM_WRITER_H_INC
70 template <
typename ALLOC>
235 template <
typename ALLOC>
238 const size_t bitSize = bitBuffer.
getBitSize();
242 size_t numBytesToWrite = bitSize / 8;
243 const uint8_t numRestBits =
static_cast<uint8_t
>(bitSize - numBytesToWrite * 8);
246 if ((beginBitPosition & 0x07U) != 0)
251 writeUnsignedBits(*it, 8);
260 (void)std::copy(buffer.
begin(), buffer.
begin() + numBytesToWrite,
261 m_buffer.
data() + beginBitPosition / 8);
267 writeUnsignedBits(
static_cast<uint32_t
>(*itEnd) >> (8U - numRestBits), numRestBits);
293 void alignTo(
size_t alignment);
302 return m_buffer.
data() !=
nullptr;
326 return m_bufferBitSize;
330 void writeUnsignedBits(uint32_t data, uint8_t
numBits);
331 void writeUnsignedBits64(uint64_t data, uint8_t
numBits);
332 void writeSignedVarNum(int64_t value,
size_t maxVarBytes,
size_t numVarBytes);
333 void writeUnsignedVarNum(uint64_t value,
size_t maxVarBytes,
size_t numVarBytes);
334 void writeVarNum(uint64_t value,
bool hasSign,
bool isNegative,
size_t maxVarBytes,
size_t numVarBytes);
336 void checkCapacity(
size_t bitSize)
const;
337 void throwInsufficientCapacityException()
const;
341 size_t m_bufferBitSize;
Span< const uint8_t > getData() const
size_t getBitSize() const
void writeFloat64(double data)
void writeVarInt64(int64_t data)
void writeVarInt16(int16_t data)
Span< const uint8_t > getBuffer() const
void writeString(StringView data)
void writeSignedBits(int32_t data, uint8_t numBits=32)
void writeFloat32(float data)
~BitStreamWriter()=default
size_t getBufferBitSize() const
BitPosType getBitPosition() const
void writeVarUInt64(uint64_t data)
void writeVarUInt16(uint16_t data)
const uint8_t * getWriteBuffer() const
void writeVarInt32(int32_t data)
void writeSignedBits64(int64_t data, uint8_t numBits=64)
void writeVarSize(uint32_t data)
void writeVarUInt32(uint32_t data)
void writeVarUInt(uint64_t data)
BitStreamWriter(const BitStreamWriter &&)=delete
void writeVarInt(int64_t data)
void writeFloat16(float data)
BitStreamWriter(const BitStreamWriter &)=delete
BitStreamWriter & operator=(const BitStreamWriter &)=delete
void writeBits64(uint64_t data, uint8_t numBits=64)
void writeBytes(Span< const uint8_t > data)
void writeBool(bool data)
void writeBitBuffer(const BasicBitBuffer< ALLOC > &bitBuffer)
BitStreamWriter(BasicBitBuffer< ALLOC > &bitBuffer)
BitStreamWriter(uint8_t *buffer, size_t bufferBitSize, BitsTag)
BitStreamWriter & operator=(BitStreamWriter &&)=delete
void writeBits(uint32_t data, uint8_t numBits=32)
bool hasWriteBuffer() const
void setBitPosition(BitPosType position)
void alignTo(size_t alignment)
CppRuntimeException(const char *message="")
constexpr pointer data() const noexcept
constexpr iterator begin() const noexcept
uint8_t numBits(uint64_t numValues)
uint32_t convertSizeToUInt32(size_t value)