JASSv2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JASS::bitstream Class Reference

Long bitstreams (push and pull from a long bitstring). More...

#include <bitstream.h>

Public Member Functions

 bitstream ()
 Constructor.
 
void push_zero (void)
 push a 0 into the stream
 
void push_zeros (size_t length)
 push length number of 0s into the stream More...
 
void push_one (void)
 push a 1 into the stream
 
void push_bits (uint64_t bits, size_t length)
 push up-to 64 bits into the steam More...
 
void rewind (void *destination=0, size_t destination_length=0)
 Rewind the bistream over the given memory. More...
 
uint64_t eof (void)
 Flush unflushed data to the stram and retun the stream length (or 0 on failure) in bytes. More...
 
int get_bit (void)
 return the next bit in the stream More...
 
uint64_t get_bits (size_t bits)
 get up-to 64 bits from the stream. More...
 

Static Public Member Functions

static void unittest (void)
 Unit test this class.
 

Protected Member Functions

void push_buffer (void)
 push the current word onto the end of the stream
 

Protected Attributes

uint64_t total_bits
 the length of the bitstring (in bits)
 
uint32_t * stream
 the bitstream
 
size_t stream_length
 the length of the bitstream (in 32-bit words)
 
size_t stream_pos
 current word (in stream) of the most recently written word
 
size_t bit_pos
 the current bit position (in buffer) of the head of the stream
 
uint32_t buffer
 the current head of the buffer
 
bool failed
 The bitstream is invalid because it has overflown its allocated length.
 

Detailed Description

Long bitstreams (push and pull from a long bitstring).

Member Function Documentation

◆ eof()

uint64_t JASS::bitstream::eof ( void  )
inline

Flush unflushed data to the stram and retun the stream length (or 0 on failure) in bytes.

Returns
The length of the stream (in bytes).

◆ get_bit()

int JASS::bitstream::get_bit ( void  )
inline

return the next bit in the stream

Returns
true or false

◆ get_bits()

uint64_t JASS::bitstream::get_bits ( size_t  bits)
inline

get up-to 64 bits from the stream.

Returns
The next bits in the bitstream.

◆ push_bits()

void JASS::bitstream::push_bits ( uint64_t  bits,
size_t  length 
)
inline

push up-to 64 bits into the steam

Parameters
bits[in] the bits to push (stored from high to low, so 1011 pushes 1, then 0, then 1, then 1).
length[in] the number of bits to push

◆ push_zeros()

void JASS::bitstream::push_zeros ( size_t  length)
inline

push length number of 0s into the stream

Parameters
length[in] the number of 0s to push

◆ rewind()

void JASS::bitstream::rewind ( void *  destination = 0,
size_t  destination_length = 0 
)
inline

Rewind the bistream over the given memory.

Parameters
destination[in] The buffer in which the bitstring is constructed
destination_length[in] The length of destination (in bytes)

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