Zserio C++ runtime library  1.0.2
Built for Zserio 2.14.1
zserio::BasicBitBuffer< ALLOC > Class Template Reference

#include <BitBuffer.h>

Public Types

using allocator_type = ALLOC
 

Public Member Functions

allocator_type get_allocator () const
 
 BasicBitBuffer ()
 
 BasicBitBuffer (const ALLOC &allocator)
 
 BasicBitBuffer (size_t bitSize, const ALLOC &allocator=ALLOC())
 
 BasicBitBuffer (Span< const uint8_t > buffer, const ALLOC &allocator=ALLOC())
 
 BasicBitBuffer (Span< const uint8_t > buffer, size_t bitSize, const ALLOC &allocator=ALLOC())
 
 BasicBitBuffer (vector< uint8_t, ALLOC > &&buffer)
 
 BasicBitBuffer (vector< uint8_t, ALLOC > &&buffer, size_t bitSize)
 
 BasicBitBuffer (const uint8_t *buffer, size_t bitSize, const ALLOC &allocator=ALLOC())
 
bool operator== (const BasicBitBuffer< ALLOC > &other) const
 
bool operator< (const BasicBitBuffer< ALLOC > &other) const
 
uint32_t hashCode () const
 
const uint8_t * getBuffer () const
 
uint8_t * getBuffer ()
 
size_t getBitSize () const
 
size_t getByteSize () const
 
const vector< uint8_t, ALLOC > & getBytes () const
 
Span< const uint8_t > getData () const
 
Span< uint8_t > getData ()
 
 ~BasicBitBuffer ()=default
 
 BasicBitBuffer (const BasicBitBuffer< ALLOC > &)=default
 
 BasicBitBuffer (const BasicBitBuffer< ALLOC > &other, const ALLOC &allocator)
 
BasicBitBufferoperator= (const BasicBitBuffer< ALLOC > &)=default
 
 BasicBitBuffer (BasicBitBuffer< ALLOC > &&)=default
 
 BasicBitBuffer (const BasicBitBuffer< ALLOC > &&other, const ALLOC &allocator)
 
BasicBitBufferoperator= (BasicBitBuffer< ALLOC > &&)=default
 

Detailed Description

template<typename ALLOC = std::allocator<uint8_t>>
class zserio::BasicBitBuffer< ALLOC >

Class which holds any bit sequence.

Because bit buffer size does not have to be byte aligned (divisible by 8), it's possible that not all bits of the last byte are used. In this case, only most significant bits of the corresponded size are used.

Definition at line 32 of file BitBuffer.h.

Member Typedef Documentation

◆ allocator_type

template<typename ALLOC = std::allocator<uint8_t>>
using zserio::BasicBitBuffer< ALLOC >::allocator_type = ALLOC

Definition at line 38 of file BitBuffer.h.

Constructor & Destructor Documentation

◆ BasicBitBuffer() [1/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer

Empty constructor.

Parameters
allocatorAllocator to use for internal vector allocation.

Definition at line 218 of file BitBuffer.h.

◆ BasicBitBuffer() [2/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( const ALLOC &  allocator)
explicit

Constructor from given allocator.

Parameters
allocatorAllocator to use for internal vector allocation.

Definition at line 224 of file BitBuffer.h.

◆ BasicBitBuffer() [3/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( size_t  bitSize,
const ALLOC &  allocator = ALLOC() 
)
explicit

Constructor from bit size.

Parameters
bitSizeSize in bits of created bit buffer.
allocatorAllocator to use for internal vector allocation.

Definition at line 230 of file BitBuffer.h.

◆ BasicBitBuffer() [4/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( Span< const uint8_t >  buffer,
const ALLOC &  allocator = ALLOC() 
)
explicit

Constructor from span.

Parameters
bufferSpan of bytes from which the bit buffer should be created.
allocatorAllocator to use for internal vector allocation.

Definition at line 236 of file BitBuffer.h.

◆ BasicBitBuffer() [5/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( Span< const uint8_t >  buffer,
size_t  bitSize,
const ALLOC &  allocator = ALLOC() 
)
explicit

Constructor from span and bit size.

Parameters
bufferSpan of bytes from which the bit buffer should be created.
bitSizeNumber of bits stored in buffer to use.
allocatorAllocator to use for internal vector allocation.
Exceptions
CppRuntimeExceptionIf given bit size is out of range for given Span.

Definition at line 242 of file BitBuffer.h.

◆ BasicBitBuffer() [6/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( vector< uint8_t, ALLOC > &&  buffer)
explicit

Constructor from moved STL vector.

Parameters
bufferSTL vector of bytes from which the bit buffer should be created.

Definition at line 255 of file BitBuffer.h.

◆ BasicBitBuffer() [7/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( vector< uint8_t, ALLOC > &&  buffer,
size_t  bitSize 
)
explicit

Constructor from moved STL vector and bit size.

Parameters
bufferSTL vector of bytes from which the bit buffer should be created.
bitSizeNumber of bits stored in buffer to use.
Exceptions
CppRuntimeExceptionIf given bit size is out of range for given vector.

Definition at line 261 of file BitBuffer.h.

◆ BasicBitBuffer() [8/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( const uint8_t *  buffer,
size_t  bitSize,
const ALLOC &  allocator = ALLOC() 
)
explicit

Constructor from raw pointer.

Parameters
bufferRaw pointer to all bytes from which the bit buffer should be created.
bitSizeNumber of bits stored in buffer to use.
allocatorAllocator to use for internal vector allocation.

Definition at line 274 of file BitBuffer.h.

◆ ~BasicBitBuffer()

template<typename ALLOC = std::allocator<uint8_t>>
zserio::BasicBitBuffer< ALLOC >::~BasicBitBuffer ( )
default

Method generated by default.

◆ BasicBitBuffer() [9/12]

template<typename ALLOC = std::allocator<uint8_t>>
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( const BasicBitBuffer< ALLOC > &  )
default

Method generated by default.

◆ BasicBitBuffer() [10/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( const BasicBitBuffer< ALLOC > &  other,
const ALLOC &  allocator 
)
inline

Method generated by default.

Definition at line 280 of file BitBuffer.h.

◆ BasicBitBuffer() [11/12]

template<typename ALLOC = std::allocator<uint8_t>>
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( BasicBitBuffer< ALLOC > &&  )
default

Method generated by default.

◆ BasicBitBuffer() [12/12]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( const BasicBitBuffer< ALLOC > &&  other,
const ALLOC &  allocator 
)
inline

Method generated by default.

Definition at line 286 of file BitBuffer.h.

Member Function Documentation

◆ get_allocator()

template<typename ALLOC = std::allocator<uint8_t>>
allocator_type zserio::BasicBitBuffer< ALLOC >::get_allocator ( ) const
inline

Get copy of the allocator used for dynamic memory allocations.

Returns
Allocator used for dynamic memory allocations.

Definition at line 45 of file BitBuffer.h.

◆ getBitSize()

template<typename ALLOC >
size_t zserio::BasicBitBuffer< ALLOC >::getBitSize

Gets the number of bits stored in the bit buffer.

Returns
Bit buffer size in bits.

Definition at line 403 of file BitBuffer.h.

◆ getBuffer() [1/2]

template<typename ALLOC >
uint8_t * zserio::BasicBitBuffer< ALLOC >::getBuffer

Gets the underlying buffer.

Returns
Pointer to the underlying buffer.

Definition at line 397 of file BitBuffer.h.

◆ getBuffer() [2/2]

template<typename ALLOC >
const uint8_t * zserio::BasicBitBuffer< ALLOC >::getBuffer

Gets the underlying buffer.

Returns
Pointer to the constant underlying buffer.

Definition at line 391 of file BitBuffer.h.

◆ getBytes()

template<typename ALLOC >
const vector< uint8_t, ALLOC > & zserio::BasicBitBuffer< ALLOC >::getBytes

Convenience getter for the underlying buffer.

Returns
Reference to the underlying vector of bytes.

Definition at line 415 of file BitBuffer.h.

◆ getByteSize()

template<typename ALLOC >
size_t zserio::BasicBitBuffer< ALLOC >::getByteSize

Gets the number of bytes stored in the bit buffer.

Not all bits of the last byte must be used. Unused bits of the last byte are set to zero.

Returns
Bit buffer size in bytes.

Definition at line 409 of file BitBuffer.h.

◆ getData() [1/2]

template<typename ALLOC >
Span< uint8_t > zserio::BasicBitBuffer< ALLOC >::getData

Convenience getter for the underlying buffer.

Returns
The span to the underlying vector of bytes.

Definition at line 427 of file BitBuffer.h.

◆ getData() [2/2]

template<typename ALLOC >
Span< const uint8_t > zserio::BasicBitBuffer< ALLOC >::getData

Convenience getter for the underlying buffer.

Returns
The span to the underlying vector of bytes.

Definition at line 421 of file BitBuffer.h.

◆ hashCode()

template<typename ALLOC >
uint32_t zserio::BasicBitBuffer< ALLOC >::hashCode

Calculates hash code of the bit buffer.

Returns
Calculated hash code.

Definition at line 370 of file BitBuffer.h.

◆ operator<()

template<typename ALLOC >
bool zserio::BasicBitBuffer< ALLOC >::operator< ( const BasicBitBuffer< ALLOC > &  other) const

Operator less than.

Parameters
otherThe another instance of bit buffer to which compare this bit buffer.
Returns
True when this bit buffer is less than the other (using lexicographical compare).

Definition at line 323 of file BitBuffer.h.

◆ operator=() [1/2]

template<typename ALLOC = std::allocator<uint8_t>>
BasicBitBuffer& zserio::BasicBitBuffer< ALLOC >::operator= ( BasicBitBuffer< ALLOC > &&  )
default

Method generated by default.

◆ operator=() [2/2]

template<typename ALLOC = std::allocator<uint8_t>>
BasicBitBuffer& zserio::BasicBitBuffer< ALLOC >::operator= ( const BasicBitBuffer< ALLOC > &  )
default

Method generated by default.

◆ operator==()

template<typename ALLOC >
bool zserio::BasicBitBuffer< ALLOC >::operator== ( const BasicBitBuffer< ALLOC > &  other) const

Equal operator.

Parameters
otherThe another instance of bit buffer to which compare this bit buffer.
Returns
True when the bit buffers have same contents, false otherwise.

Definition at line 292 of file BitBuffer.h.


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