Slim numerical data compression 1.0
bitstream Class Referenceabstract

Bit stream base class. More...

Inheritance diagram for bitstream:
ibitstream obitstream

Public Types

enum  { DEFAULT_IOBUFFER_SIZE =1024*1024 }
 Make *Dptr always point to same place as Bptr. More...
 
enum  { MAX_BITSTREAM_BUFSIZE =16*1024*1024 }
 

Public Member Functions

 bitstream ()
 Dummy default constructor.
 
 bitstream (const char *filename, int buffersize=DEFAULT_IOBUFFER_SIZE)
 Start bitstream by filename.
 
virtual ~bitstream ()
 Destructor deletes output buffer, closes file.
 
virtual void close ()=0
 
virtual bool is_open () const =0
 
virtual void setupstream ()
 Allocate a buffer and set up all pointers.
 
virtual void windup ()=0
 
virtual int get_bytes_used ()
 Return the number of bytes used so far in this stream.
 
int get_bitptr ()
 Get the position of the bitptr.
 
virtual void print () const =0
 Print properties of stream (pure virt)
 

Protected Attributes

size_t bufsize
 Size of I/O buffer (bytes)
 
size_t buf_used
 
Byte_t * buffer_base
 Pointer to the buffer.
 
Byte_t * beyondbuffer
 Pointer just beyond buffer (convenience).
 
union { 
 
   Byte_t *   Bptr 
 Pointer to the current word (as Byte_t *).
 
   Word_t *   Dptr 
 Pointer to the current word (as Word_t *).
 
buffptr 
 Pointer to the current word.
 
int bitptr
 Pointer to the current bits.
 

Static Protected Attributes

static const int Bits_per_word = 8*sizeof(Word_t)
 Bits per buffer word.
 

Detailed Description

Bit stream base class.

Allows you to R/W data one bit at a time with buffered reading/writing.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Make *Dptr always point to same place as Bptr.

But where Bptr is a (Byte_t *), *Dptr is a (Word_t *)

Member Function Documentation

◆ close()

virtual void bitstream::close ( )
pure virtual

Implemented in ibitstream, and obitstream.

◆ get_bytes_used()

int bitstream::get_bytes_used ( )
virtual

Return the number of bytes used so far in this stream.

Reimplemented in ibitstream.

References bitptr, buf_used, buffer_base, and buffptr.

◆ is_open()

virtual bool bitstream::is_open ( ) const
pure virtual

Implemented in ibitstream, and obitstream.

◆ print()

virtual void bitstream::print ( ) const
pure virtual

Print properties of stream (pure virt)

Implemented in ibitstream, and obitstream.

◆ setupstream()

void bitstream::setupstream ( )
virtual

Allocate a buffer and set up all pointers.

Reimplemented in ibitstream.

References beyondbuffer, bitptr, buf_used, buffer_base, buffptr, and bufsize.

Referenced by obitstream::obitstream(), obitstream::obitstream(), and ibitstream::setupstream().

◆ windup()

virtual void bitstream::windup ( )
pure virtual

Implemented in ibitstream, and obitstream.

Member Data Documentation

◆ buf_used

size_t bitstream::buf_used
protected

words ever I/O between buffer and disk.

Referenced by ibitstream::fill(), obitstream::flush(), get_bytes_used(), ibitstream::get_bytes_used(), and setupstream().


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