nalchi
Loading...
Searching...
No Matches
nalchi::bit_stream_measurer Class Referencefinal

Measures the bytes bit_stream_writer will use. More...

#include <nalchi/bit_stream.hpp>

Public Types

using size_type = bit_stream_writer::size_type
 Size type representing number of bits and bytes.
 

Public Member Functions

 bit_stream_measurer (const bit_stream_measurer &)=delete
 Deleted copy constructor.
 
auto operator= (const bit_stream_measurer &) -> bit_stream_measurer &=delete
 Deleted copy assignment operator.
 
 bit_stream_measurer ()=default
 Constructs a bit_stream_measurer instance.
 
auto used_bytes () const -> size_type
 Gets the number of used (measured) bytes.
 
auto used_bits () const -> size_type
 Gets the number of used (measured) bits.
 
void restart ()
 Restarts the measure from zero.
 
auto write (const void *data, size_type size) -> bit_stream_measurer &
 Fake-writes some arbitrary data to the bit stream.
 
template<std::integral Int>
auto write (Int data, Int min=std::numeric_limits< Int >::min(), Int max=std::numeric_limits< Int >::max()) -> bit_stream_measurer &
 Fake-writes an integral value to the bit stream.
 
auto write (float data) -> bit_stream_measurer &
 Fake-writes a float value to the bit stream.
 
auto write (double data) -> bit_stream_measurer &
 Fake-writes a double value to the bit stream.
 
template<character CharT, typename CharTraits >
auto write (std::basic_string_view< CharT, CharTraits > str) -> bit_stream_measurer &
 Fake-writes a string view to the bit stream.
 
template<character CharT, typename CharTraits , typename Allocator >
auto write (const std::basic_string< CharT, CharTraits, Allocator > &str) -> bit_stream_measurer &
 Fake-writes a string to the bit stream.
 
template<character CharT>
auto write (const CharT *str) -> bit_stream_measurer &
 Fake-writes a null-terminated string to the bit stream.
 

Detailed Description

Measures the bytes bit_stream_writer will use.

This never actually writes any data.
Instead, it only measures how many bytes bit_stream_writer would use.
You can use this to measure the required space for the bit_stream_writer.

Member Function Documentation

◆ used_bits()

auto nalchi::bit_stream_measurer::used_bits ( ) const -> size_type
inline

Gets the number of used (measured) bits.

Returns
Number of used (measured) bits.

◆ used_bytes()

auto nalchi::bit_stream_measurer::used_bytes ( ) const -> size_type

Gets the number of used (measured) bytes.

Returns
Number of used (measured) bytes.

◆ write() [1/7]

template<character CharT>
auto nalchi::bit_stream_measurer::write ( const CharT * str) -> bit_stream_measurer&
inline

Fake-writes a null-terminated string to the bit stream.

Template Parameters
CharTCharacter type of the null-terminated string.
Parameters
strString to fake-write.
Returns
The stream itself.

◆ write() [2/7]

template<character CharT, typename CharTraits , typename Allocator >
auto nalchi::bit_stream_measurer::write ( const std::basic_string< CharT, CharTraits, Allocator > & str) -> bit_stream_measurer&
inline

Fake-writes a string to the bit stream.

Template Parameters
CharTUnderlying character type of std::basic_string.
CharTraitsChar traits for CharT.
AllocatorUnderlying allocator for std::basic_string.
Parameters
strString to fake-write.
Returns
The stream itself.

◆ write() [3/7]

auto nalchi::bit_stream_measurer::write ( const void * data,
size_type size ) -> bit_stream_measurer&
inline

Fake-writes some arbitrary data to the bit stream.

Parameters
dataPointer to the arbitrary data.
sizeSize in bytes of the data.
Returns
The stream itself.

◆ write() [4/7]

auto nalchi::bit_stream_measurer::write ( double data) -> bit_stream_measurer&
inline

Fake-writes a double value to the bit stream.

Parameters
dataData to fake-write.
Returns
The stream itself.

◆ write() [5/7]

auto nalchi::bit_stream_measurer::write ( float data) -> bit_stream_measurer&
inline

Fake-writes a float value to the bit stream.

Parameters
dataData to fake-write.
Returns
The stream itself.

◆ write() [6/7]

template<std::integral Int>
auto nalchi::bit_stream_measurer::write ( Int data,
Int min = std::numeric_limits<Int>::min(),
Int max = std::numeric_limits<Int>::max() ) -> bit_stream_measurer&
inline

Fake-writes an integral value to the bit stream.

Template Parameters
IntInteger type.
Parameters
dataData to fake-write.
minMinimum value allowed for data.
maxMaximum value allowed for data.
Returns
The stream itself.

◆ write() [7/7]

template<character CharT, typename CharTraits >
auto nalchi::bit_stream_measurer::write ( std::basic_string_view< CharT, CharTraits > str) -> bit_stream_measurer&
inline

Fake-writes a string view to the bit stream.

Template Parameters
CharTUnderlying character type of std::basic_string_view.
CharTraitsChar traits for CharT.
Parameters
strString to fake-write.
Returns
The stream itself.

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