Bitcoin Core  27.99.0
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
BitStreamWriter< OStream > Class Template Reference

#include <streams.h>

Public Member Functions

 BitStreamWriter (OStream &ostream)
 
 ~BitStreamWriter ()
 
void Write (uint64_t data, int nbits)
 Write the nbits least significant bits of a 64-bit int to the output stream. More...
 
void Flush ()
 Flush any unwritten bits to the output stream, padding with 0's to the next byte boundary. More...
 

Private Attributes

OStream & m_ostream
 
uint8_t m_buffer {0}
 Buffered byte waiting to be written to the output stream. More...
 
int m_offset {0}
 Number of high order bits in m_buffer already written by previous Write() calls and not yet flushed to the stream. More...
 

Detailed Description

template<typename OStream>
class BitStreamWriter< OStream >

Definition at line 326 of file streams.h.

Constructor & Destructor Documentation

◆ BitStreamWriter()

template<typename OStream >
BitStreamWriter< OStream >::BitStreamWriter ( OStream &  ostream)
inlineexplicit

Definition at line 341 of file streams.h.

◆ ~BitStreamWriter()

template<typename OStream >
BitStreamWriter< OStream >::~BitStreamWriter ( )
inline

Definition at line 343 of file streams.h.

Here is the call graph for this function:

Member Function Documentation

◆ Flush()

template<typename OStream >
void BitStreamWriter< OStream >::Flush ( )
inline

Flush any unwritten bits to the output stream, padding with 0's to the next byte boundary.

Definition at line 371 of file streams.h.

Here is the caller graph for this function:

◆ Write()

template<typename OStream >
void BitStreamWriter< OStream >::Write ( uint64_t  data,
int  nbits 
)
inline

Write the nbits least significant bits of a 64-bit int to the output stream.

Data is buffered until it completes an octet.

Definition at line 351 of file streams.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_buffer

template<typename OStream >
uint8_t BitStreamWriter< OStream >::m_buffer {0}
private

Buffered byte waiting to be written to the output stream.

The byte is written buffer when m_offset reaches 8 or Flush() is called.

Definition at line 333 of file streams.h.

◆ m_offset

template<typename OStream >
int BitStreamWriter< OStream >::m_offset {0}
private

Number of high order bits in m_buffer already written by previous Write() calls and not yet flushed to the stream.

The next bit to be written to is at this offset from the most significant bit position.

Definition at line 338 of file streams.h.

◆ m_ostream

template<typename OStream >
OStream& BitStreamWriter< OStream >::m_ostream
private

Definition at line 329 of file streams.h.


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