Zserio C++ runtime library  1.1.0
Built for Zserio 2.15.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 writeBits (uint32_t data, uint8_t numBits=32)
 
void writeBits64 (uint64_t data, uint8_t numBits=64)
 
void writeSignedBits (int32_t data, uint8_t numBits=32)
 
void writeSignedBits64 (int64_t data, uint8_t numBits=64)
 
void writeVarInt64 (int64_t data)
 
void writeVarInt32 (int32_t data)
 
void writeVarInt16 (int16_t data)
 
void writeVarUInt64 (uint64_t data)
 
void writeVarUInt32 (uint32_t data)
 
void writeVarUInt16 (uint16_t data)
 
void writeVarInt (int64_t data)
 
void writeVarUInt (uint64_t data)
 
void writeVarSize (uint32_t data)
 
void writeFloat16 (float data)
 
void writeFloat32 (float data)
 
void writeFloat64 (double data)
 
void writeBytes (Span< const uint8_t > data)
 
void writeString (StringView data)
 
void writeBool (bool 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 21 of file BitStreamWriter.h.

Member Typedef Documentation

◆ BitPosType

Type for bit position.

Definition at line 32 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 327 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 333 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 337 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 343 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 71 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 536 of file BitStreamWriter.cpp.

◆ getBitPosition()

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

Gets current bit position.

Returns
Current bit position.

Definition at line 276 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 551 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 324 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 546 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 300 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 526 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 236 of file BitStreamWriter.h.

◆ writeBits()

void zserio::BitStreamWriter::writeBits ( 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 355 of file BitStreamWriter.cpp.

◆ writeBits64()

void zserio::BitStreamWriter::writeBits64 ( 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 366 of file BitStreamWriter.cpp.

◆ writeBool()

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

Writes bool as a single bit.

Parameters
dataBool to write.

Definition at line 521 of file BitStreamWriter.cpp.

◆ writeBytes()

void zserio::BitStreamWriter::writeBytes ( Span< const uint8_t >  data)

Writes bytes.

Parameters
dataBytes to write.

Definition at line 471 of file BitStreamWriter.cpp.

◆ writeFloat16()

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

Writes 16-bit float.

Parameters
dataFloat16 to write.

Definition at line 453 of file BitStreamWriter.cpp.

◆ writeFloat32()

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

Writes 32-bit float.

Parameters
dataFloat32 to write.

Definition at line 459 of file BitStreamWriter.cpp.

◆ writeFloat64()

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

Writes 64-bit float.

Parameters
dataFloat64 to write.

Definition at line 465 of file BitStreamWriter.cpp.

◆ writeSignedBits()

void zserio::BitStreamWriter::writeSignedBits ( 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 377 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 389 of file BitStreamWriter.cpp.

◆ writeString()

void zserio::BitStreamWriter::writeString ( StringView  data)

Writes UTF-8 string.

Parameters
dataString view to write.

Definition at line 496 of file BitStreamWriter.cpp.

◆ writeVarInt()

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

Writes signed variable integer up to 72 bits.

Parameters
dataVaruint64 to write.

Definition at line 431 of file BitStreamWriter.cpp.

◆ writeVarInt16()

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

Writes signed variable integer up to 16 bits.

Parameters
dataVarint16 to write.

Definition at line 411 of file BitStreamWriter.cpp.

◆ writeVarInt32()

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

Writes signed variable integer up to 32 bits.

Parameters
dataVarint32 to write.

Definition at line 406 of file BitStreamWriter.cpp.

◆ writeVarInt64()

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

Writes signed variable integer up to 64 bits.

Parameters
dataVarint64 to write.

Definition at line 401 of file BitStreamWriter.cpp.

◆ writeVarSize()

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

Writes variable size integer up to 40 bits.

Parameters
dataVarsize to write.

Definition at line 448 of file BitStreamWriter.cpp.

◆ writeVarUInt()

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

Writes signed variable integer up to 72 bits.

Parameters
dataVaruint64 to write.

Definition at line 443 of file BitStreamWriter.cpp.

◆ writeVarUInt16()

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

Writes unsigned variable integer up to 16 bits.

Parameters
dataVaruint16 to write.

Definition at line 426 of file BitStreamWriter.cpp.

◆ writeVarUInt32()

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

Writes unsigned variable integer up to 32 bits.

Parameters
dataVaruint32 to write.

Definition at line 421 of file BitStreamWriter.cpp.

◆ writeVarUInt64()

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

Writes unsigned variable integer up to 64 bits.

Parameters
dataVaruint64 to write.

Definition at line 416 of file BitStreamWriter.cpp.


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