Zserio C++17 runtime library  0.5.0
Built for Zserio 2.17.0
zserio::BitStreamWriter Class Reference

#include <BitStreamWriter.h>

Classes

class  InsufficientCapacityException
 

Public Types

using BitPosType = size_t
 

Public Member Functions

 BitStreamWriter (uint8_t *buffer, size_t bufferBitSize, BitsTag)
 
 BitStreamWriter (uint8_t *buffer, size_t bufferByteSize)
 
 BitStreamWriter (Span< uint8_t > buffer)
 
 BitStreamWriter (Span< uint8_t > buffer, size_t bufferBitSize)
 
template<typename ALLOC >
 BitStreamWriter (BasicBitBuffer< ALLOC > &bitBuffer)
 
 ~BitStreamWriter ()=default
 
void writeUnsignedBits32 (uint32_t data, uint8_t numBits=32)
 
void writeUnsignedBits64 (uint64_t data, uint8_t numBits=64)
 
void writeSignedBits32 (int32_t data, uint8_t numBits=32)
 
void writeSignedBits64 (int64_t data, uint8_t numBits=64)
 
void writeBool (Bool data)
 
void writeVarInt16 (VarInt16 data)
 
void writeVarInt32 (VarInt32 data)
 
void writeVarInt64 (VarInt64 data)
 
void writeVarInt (VarInt data)
 
void writeVarUInt16 (VarUInt16 data)
 
void writeVarUInt32 (VarUInt32 data)
 
void writeVarUInt64 (VarUInt64 data)
 
void writeVarUInt (VarUInt data)
 
void writeVarSize (VarSize data)
 
void writeFloat16 (Float16 data)
 
void writeFloat32 (Float32 data)
 
void writeFloat64 (Float64 data)
 
void writeBytes (BytesView data)
 
void writeString (std::string_view data)
 
template<typename ALLOC >
void writeBitBuffer (const BasicBitBuffer< ALLOC > &bitBuffer)
 
BitPosType getBitPosition () const
 
void setBitPosition (BitPosType position)
 
void alignTo (size_t alignment)
 
bool hasWriteBuffer () const
 
const uint8_t * getWriteBuffer () const
 
Span< const uint8_t > getBuffer () const
 
size_t getBufferBitSize () const
 
 BitStreamWriter (const BitStreamWriter &)=delete
 
BitStreamWriteroperator= (const BitStreamWriter &)=delete
 
 BitStreamWriter (const BitStreamWriter &&)=delete
 
BitStreamWriteroperator= (BitStreamWriter &&)=delete
 

Detailed Description

Writer class which allows to write various data to the bit stream.

Definition at line 22 of file BitStreamWriter.h.

Member Typedef Documentation

◆ BitPosType

Type for bit position.

Definition at line 33 of file BitStreamWriter.h.

Constructor & Destructor Documentation

◆ BitStreamWriter() [1/7]

zserio::BitStreamWriter::BitStreamWriter ( uint8_t *  buffer,
size_t  bufferBitSize,
BitsTag   
)
explicit

Constructor from externally allocated byte buffer.

Parameters
bufferExternal byte buffer to create from.
bufferBitSizeSize of the buffer in bits.

Definition at line 319 of file BitStreamWriter.cpp.

◆ BitStreamWriter() [2/7]

zserio::BitStreamWriter::BitStreamWriter ( uint8_t *  buffer,
size_t  bufferByteSize 
)
explicit

Constructor from externally allocated byte buffer.

Parameters
bufferExternal byte buffer to create from.
bufferByteSizeSize of the buffer in bytes.

Definition at line 325 of file BitStreamWriter.cpp.

◆ BitStreamWriter() [3/7]

zserio::BitStreamWriter::BitStreamWriter ( Span< uint8_t >  buffer)
explicit

Constructor from externally allocated byte buffer.

Parameters
bufferExternal buffer to create from as a Span.

Definition at line 329 of file BitStreamWriter.cpp.

◆ BitStreamWriter() [4/7]

zserio::BitStreamWriter::BitStreamWriter ( Span< uint8_t >  buffer,
size_t  bufferBitSize 
)
explicit

Constructor from externally allocated byte buffer with exact bit size.

Parameters
bufferExternal buffer to create from as a Span.
bufferBitSizeSize of the buffer in bits.

Definition at line 335 of file BitStreamWriter.cpp.

◆ BitStreamWriter() [5/7]

template<typename ALLOC >
zserio::BitStreamWriter::BitStreamWriter ( BasicBitBuffer< ALLOC > &  bitBuffer)
inlineexplicit

Constructor from externally allocated bit buffer.

Parameters
bitBufferExternal bit buffer to create from.

Definition at line 72 of file BitStreamWriter.h.

◆ ~BitStreamWriter()

zserio::BitStreamWriter::~BitStreamWriter ( )
default

Destructor.

◆ BitStreamWriter() [6/7]

zserio::BitStreamWriter::BitStreamWriter ( const BitStreamWriter )
delete

Copying and moving is disallowed!

◆ BitStreamWriter() [7/7]

zserio::BitStreamWriter::BitStreamWriter ( const BitStreamWriter &&  )
delete

Copying and moving is disallowed!

Member Function Documentation

◆ alignTo()

void zserio::BitStreamWriter::alignTo ( size_t  alignment)

Moves current bit position to perform the requested bit alignment.

Parameters
alignmentSize of the alignment in bits.

Definition at line 529 of file BitStreamWriter.cpp.

◆ getBitPosition()

BitPosType zserio::BitStreamWriter::getBitPosition ( ) const
inline

Gets current bit position.

Returns
Current bit position.

Definition at line 277 of file BitStreamWriter.h.

◆ getBuffer()

Span< const uint8_t > zserio::BitStreamWriter::getBuffer ( ) const

Gets the write buffer as span.

Returns
Span which represents the write buffer.

Definition at line 544 of file BitStreamWriter.cpp.

◆ getBufferBitSize()

size_t zserio::BitStreamWriter::getBufferBitSize ( ) const
inline

Gets size of the underlying buffer in bits.

Returns
Buffer bit size.

Definition at line 325 of file BitStreamWriter.h.

◆ getWriteBuffer()

const uint8_t * zserio::BitStreamWriter::getWriteBuffer ( ) const

Gets the write buffer.

Returns
Pointer to the beginning of write buffer.

Definition at line 539 of file BitStreamWriter.cpp.

◆ hasWriteBuffer()

bool zserio::BitStreamWriter::hasWriteBuffer ( ) const
inline

Gets whether the writer has assigned a write buffer.

Returns
True when a buffer is assigned. False otherwise.

Definition at line 301 of file BitStreamWriter.h.

◆ operator=() [1/2]

BitStreamWriter& zserio::BitStreamWriter::operator= ( BitStreamWriter &&  )
delete

Copying and moving is disallowed!

◆ operator=() [2/2]

BitStreamWriter& zserio::BitStreamWriter::operator= ( const BitStreamWriter )
delete

Copying and moving is disallowed!

◆ setBitPosition()

void zserio::BitStreamWriter::setBitPosition ( BitPosType  position)

Sets current bit position. Use with caution!

Parameters
positionNew bit position.

Definition at line 519 of file BitStreamWriter.cpp.

◆ writeBitBuffer()

template<typename ALLOC >
void zserio::BitStreamWriter::writeBitBuffer ( const BasicBitBuffer< ALLOC > &  bitBuffer)
inline

Writes bit buffer.

Parameters
bitBufferBit buffer to write.

Definition at line 237 of file BitStreamWriter.h.

◆ writeBool()

void zserio::BitStreamWriter::writeBool ( Bool  data)

Writes bool as a single bit.

Parameters
dataBool to write.

Definition at line 393 of file BitStreamWriter.cpp.

◆ writeBytes()

void zserio::BitStreamWriter::writeBytes ( BytesView  data)

Writes bytes.

Parameters
dataBytes to write.

Definition at line 468 of file BitStreamWriter.cpp.

◆ writeFloat16()

void zserio::BitStreamWriter::writeFloat16 ( Float16  data)

Writes 16-bit float.

Parameters
dataFloat16 to write.

Definition at line 450 of file BitStreamWriter.cpp.

◆ writeFloat32()

void zserio::BitStreamWriter::writeFloat32 ( Float32  data)

Writes 32-bit float.

Parameters
dataFloat32 to write.

Definition at line 456 of file BitStreamWriter.cpp.

◆ writeFloat64()

void zserio::BitStreamWriter::writeFloat64 ( Float64  data)

Writes 64-bit float.

Parameters
dataFloat64 to write.

Definition at line 462 of file BitStreamWriter.cpp.

◆ writeSignedBits32()

void zserio::BitStreamWriter::writeSignedBits32 ( int32_t  data,
uint8_t  numBits = 32 
)

Writes signed bits up to 32 bits.

Parameters
dataData to write.
numBitsNumber of bits to write.

Definition at line 369 of file BitStreamWriter.cpp.

◆ writeSignedBits64()

void zserio::BitStreamWriter::writeSignedBits64 ( int64_t  data,
uint8_t  numBits = 64 
)

Writes signed bits up to 64 bits.

Parameters
dataData to write.
numBitsNumber of bits to write.

Definition at line 381 of file BitStreamWriter.cpp.

◆ writeString()

void zserio::BitStreamWriter::writeString ( std::string_view  data)

Writes UTF-8 string.

Parameters
dataString view to write.

Definition at line 493 of file BitStreamWriter.cpp.

◆ writeUnsignedBits32()

void zserio::BitStreamWriter::writeUnsignedBits32 ( uint32_t  data,
uint8_t  numBits = 32 
)

Writes unsigned bits up to 32 bits.

Parameters
dataData to write.
numBitsNumber of bits to write.

Definition at line 347 of file BitStreamWriter.cpp.

◆ writeUnsignedBits64()

void zserio::BitStreamWriter::writeUnsignedBits64 ( uint64_t  data,
uint8_t  numBits = 64 
)

Writes unsigned bits up to 64 bits.

Parameters
dataData to write.
numBitsNumber of bits to write.

Definition at line 358 of file BitStreamWriter.cpp.

◆ writeVarInt()

void zserio::BitStreamWriter::writeVarInt ( VarInt  data)

Writes signed variable integer up to 72 bits.

Parameters
dataVaruint64 to write.

Definition at line 413 of file BitStreamWriter.cpp.

◆ writeVarInt16()

void zserio::BitStreamWriter::writeVarInt16 ( VarInt16  data)

Writes signed variable integer up to 16 bits.

Parameters
dataVarint16 to write.

Definition at line 398 of file BitStreamWriter.cpp.

◆ writeVarInt32()

void zserio::BitStreamWriter::writeVarInt32 ( VarInt32  data)

Writes signed variable integer up to 32 bits.

Parameters
dataVarint32 to write.

Definition at line 403 of file BitStreamWriter.cpp.

◆ writeVarInt64()

void zserio::BitStreamWriter::writeVarInt64 ( VarInt64  data)

Writes signed variable integer up to 64 bits.

Parameters
dataVarint64 to write.

Definition at line 408 of file BitStreamWriter.cpp.

◆ writeVarSize()

void zserio::BitStreamWriter::writeVarSize ( VarSize  data)

Writes variable size integer up to 40 bits.

Parameters
dataVarsize to write.

Definition at line 445 of file BitStreamWriter.cpp.

◆ writeVarUInt()

void zserio::BitStreamWriter::writeVarUInt ( VarUInt  data)

Writes signed variable integer up to 72 bits.

Parameters
dataVaruint64 to write.

Definition at line 440 of file BitStreamWriter.cpp.

◆ writeVarUInt16()

void zserio::BitStreamWriter::writeVarUInt16 ( VarUInt16  data)

Writes unsigned variable integer up to 16 bits.

Parameters
dataVaruint16 to write.

Definition at line 425 of file BitStreamWriter.cpp.

◆ writeVarUInt32()

void zserio::BitStreamWriter::writeVarUInt32 ( VarUInt32  data)

Writes unsigned variable integer up to 32 bits.

Parameters
dataVaruint32 to write.

Definition at line 430 of file BitStreamWriter.cpp.

◆ writeVarUInt64()

void zserio::BitStreamWriter::writeVarUInt64 ( VarUInt64  data)

Writes unsigned variable integer up to 64 bits.

Parameters
dataVaruint64 to write.

Definition at line 435 of file BitStreamWriter.cpp.


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