Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
zserio::BasicBitBuffer< ALLOC > Class Template Reference

#include <BitBuffer.h>

Public Types

using allocator_type = ALLOC
 

Public Member Functions

ALLOC get_allocator () const
 
 BasicBitBuffer ()
 
 BasicBitBuffer (const ALLOC &allocator)
 
 BasicBitBuffer (size_t bitSize, const ALLOC &allocator={})
 
 BasicBitBuffer (Span< const uint8_t > buffer, const ALLOC &allocator={})
 
 BasicBitBuffer (Span< const uint8_t > buffer, size_t bitSize, const ALLOC &allocator={})
 
 BasicBitBuffer (std::vector< uint8_t, ALLOC > &&buffer)
 
 BasicBitBuffer (std::vector< uint8_t, ALLOC > &&buffer, size_t bitSize)
 
 BasicBitBuffer (const BasicBitBuffer &other, const ALLOC &allocator)
 
 BasicBitBuffer (BasicBitBuffer &&other, const ALLOC &allocator)
 
bool operator== (const BasicBitBuffer &other) const
 
bool operator!= (const BasicBitBuffer &other) const
 
bool operator< (const BasicBitBuffer &other) const
 
bool operator> (const BasicBitBuffer &other) const
 
bool operator<= (const BasicBitBuffer &other) const
 
bool operator>= (const BasicBitBuffer &other) const
 
uint32_t hashCode () const
 
const uint8_t * getBuffer () const
 
uint8_t * getBuffer ()
 
size_t getBitSize () const
 
size_t getByteSize () const
 
const std::vector< uint8_t, ALLOC > & getBytes () const
 
Span< const uint8_t > getData () const
 
Span< uint8_t > getData ()
 
 BasicBitBuffer (const BasicBitBuffer &)=default
 
BasicBitBuffer & operator= (const BasicBitBuffer &)=default
 
 BasicBitBuffer (BasicBitBuffer &&)=default
 
BasicBitBuffer & operator= (BasicBitBuffer &&)=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 35 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 41 of file BitBuffer.h.

Constructor & Destructor Documentation

◆ BasicBitBuffer() [1/11]

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

Empty constructor.

Parameters
allocatorAllocator to use for internal vector allocation.

Definition at line 269 of file BitBuffer.h.

◆ BasicBitBuffer() [2/11]

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 275 of file BitBuffer.h.

◆ BasicBitBuffer() [3/11]

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

Constructor from bit size.

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

Definition at line 281 of file BitBuffer.h.

◆ BasicBitBuffer() [4/11]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( Span< const uint8_t >  buffer,
const ALLOC &  allocator = {} 
)
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 287 of file BitBuffer.h.

◆ BasicBitBuffer() [5/11]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( Span< const uint8_t >  buffer,
size_t  bitSize,
const ALLOC &  allocator = {} 
)
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 293 of file BitBuffer.h.

◆ BasicBitBuffer() [6/11]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( std::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 306 of file BitBuffer.h.

◆ BasicBitBuffer() [7/11]

template<typename ALLOC >
zserio::BasicBitBuffer< ALLOC >::BasicBitBuffer ( std::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 312 of file BitBuffer.h.

◆ BasicBitBuffer() [8/11]

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

Allocator aware copy constructor.

Definition at line 325 of file BitBuffer.h.

◆ BasicBitBuffer() [9/11]

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

Allocator aware move constructor.

Definition at line 331 of file BitBuffer.h.

◆ ~BasicBitBuffer()

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

Method generated by default.

◆ BasicBitBuffer() [10/11]

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

Method generated by default.

◆ BasicBitBuffer() [11/11]

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

Method generated by default.

Member Function Documentation

◆ get_allocator()

template<typename ALLOC = std::allocator<uint8_t>>
ALLOC 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 48 of file BitBuffer.h.

◆ getBitSize()

template<typename ALLOC >
size_t zserio::BasicBitBuffer< ALLOC >::getBitSize ( ) const

Gets the number of bits stored in the bit buffer.

Returns
Bit buffer size in bits.

Definition at line 448 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 442 of file BitBuffer.h.

◆ getBuffer() [2/2]

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

Gets the underlying buffer.

Returns
Pointer to the constant underlying buffer.

Definition at line 436 of file BitBuffer.h.

◆ getBytes()

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

Convenience getter for the underlying buffer.

Returns
Reference to the underlying vector of bytes.

Definition at line 460 of file BitBuffer.h.

◆ getByteSize()

template<typename ALLOC >
size_t zserio::BasicBitBuffer< ALLOC >::getByteSize ( ) const

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 454 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 472 of file BitBuffer.h.

◆ getData() [2/2]

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

Convenience getter for the underlying buffer.

Returns
The span to the underlying vector of bytes.

Definition at line 466 of file BitBuffer.h.

◆ hashCode()

template<typename ALLOC >
uint32_t zserio::BasicBitBuffer< ALLOC >::hashCode ( ) const

Calculates hash code of the bit buffer.

Returns
Calculated hash code.

Definition at line 415 of file BitBuffer.h.

◆ operator!=()

template<typename ALLOC = std::allocator<uint8_t>>
bool zserio::BasicBitBuffer< ALLOC >::operator!= ( const BasicBitBuffer< ALLOC > &  other) const
inline

Non-equal operator.

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

Definition at line 152 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), bit buffers with equal contents are ordered by their bit size.

Definition at line 368 of file BitBuffer.h.

◆ operator<=()

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

Operator less than or equal.

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

Definition at line 186 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 337 of file BitBuffer.h.

◆ operator>()

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

Operator greater than.

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

Definition at line 174 of file BitBuffer.h.

◆ operator>=()

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

Operator greater than or equal.

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

Definition at line 198 of file BitBuffer.h.


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