The Conley-Morse Graphs Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ByteDecompressor Class Reference

A simple wrapper for the bzip2 data decompression from an input stream. More...

#include <bytecompr.h>

Public Member Functions

 ByteDecompressor (std::istream &in)
 The constructor of an input stream for retrieving binary data. More...
 
 ~ByteDecompressor ()
 The destructor that ends the decompression procedure and releases the internal memory buffers. More...
 
void close ()
 Ends the decompression and deletes the bzip2 structure. More...
 
void read (char *buf, size_t n)
 Reads the given number of bytes from the decompressed stream. More...
 

Private Member Functions

void decompress ()
 Decompresses data from the input buffer (and the input stream) to provide more data for reading if possible. More...
 
 ByteDecompressor (const ByteDecompressor &)
 
ByteDecompressoroperator= (const ByteDecompressor &)
 

Private Attributes

bz_stream * bzStream
 The bzip2 data stream information. More...
 
std::istream & inStream
 A reference to the input stream from which the compressed data should be read. More...
 
char * inBuffer
 An internal buffer for caching data read from the input stream. More...
 
char * outBuffer
 An internal buffer for caching decompressed data. More...
 
size_t bufSize
 The size of each of the internal buffers. More...
 
bool finished
 Is the decompression procedure completed? More...
 
size_t inPos
 The current position in the internal buffer with compressed data. More...
 
size_t inPosEnd
 The end of the compressed data in the internal buffer. More...
 
size_t outPos
 The current position in the internal buffer with decompressed data. More...
 
size_t outPosEnd
 The position of the end of the decompressed data in the internal buffer. More...
 

Detailed Description

A simple wrapper for the bzip2 data decompression from an input stream.

Definition at line 294 of file bytecompr.h.

Constructor & Destructor Documentation

◆ ByteDecompressor() [1/2]

ByteDecompressor::ByteDecompressor ( std::istream &  in)
inline

The constructor of an input stream for retrieving binary data.

It also initializes the bzip2 decompression structure.

Definition at line 362 of file bytecompr.h.

References bufSize, bzStream, finished, inBuffer, inPos, inPosEnd, outBuffer, outPos, and outPosEnd.

◆ ~ByteDecompressor()

ByteDecompressor::~ByteDecompressor ( )
inline

The destructor that ends the decompression procedure and releases the internal memory buffers.

Definition at line 542 of file bytecompr.h.

References bzStream, close(), inBuffer, and outBuffer.

◆ ByteDecompressor() [2/2]

ByteDecompressor::ByteDecompressor ( const ByteDecompressor )
private

Member Function Documentation

◆ close()

void ByteDecompressor::close ( )
inline

Ends the decompression and deletes the bzip2 structure.

Definition at line 517 of file bytecompr.h.

References bzStream.

Referenced by ~ByteDecompressor().

◆ decompress()

void ByteDecompressor::decompress ( )
inlineprivate

Decompresses data from the input buffer (and the input stream) to provide more data for reading if possible.

Definition at line 403 of file bytecompr.h.

References bufSize, bzStream, finished, inBuffer, inPos, inPosEnd, inStream, outBuffer, outPos, outPosEnd, and read().

Referenced by read().

◆ operator=()

ByteDecompressor & ByteDecompressor::operator= ( const ByteDecompressor )
private

◆ read()

void ByteDecompressor::read ( char *  buf,
size_t  n 
)

Reads the given number of bytes from the decompressed stream.

Uses an internal buffer to avoid the inefficiency that comes from taking small portions of data from the bzip2 procedures. Throws an exception if there is not enough data.

Definition at line 503 of file bytecompr.h.

References bufSize, decompress(), outBuffer, outPos, and outPosEnd.

Referenced by decompress().

Member Data Documentation

◆ bufSize

size_t ByteDecompressor::bufSize
private

The size of each of the internal buffers.

Definition at line 329 of file bytecompr.h.

Referenced by ByteDecompressor(), decompress(), and read().

◆ bzStream

bz_stream* ByteDecompressor::bzStream
private

The bzip2 data stream information.

Definition at line 316 of file bytecompr.h.

Referenced by ByteDecompressor(), close(), decompress(), and ~ByteDecompressor().

◆ finished

bool ByteDecompressor::finished
private

Is the decompression procedure completed?

Definition at line 332 of file bytecompr.h.

Referenced by ByteDecompressor(), and decompress().

◆ inBuffer

char* ByteDecompressor::inBuffer
private

An internal buffer for caching data read from the input stream.

Definition at line 323 of file bytecompr.h.

Referenced by ByteDecompressor(), decompress(), and ~ByteDecompressor().

◆ inPos

size_t ByteDecompressor::inPos
private

The current position in the internal buffer with compressed data.

Definition at line 335 of file bytecompr.h.

Referenced by ByteDecompressor(), and decompress().

◆ inPosEnd

size_t ByteDecompressor::inPosEnd
private

The end of the compressed data in the internal buffer.

Definition at line 338 of file bytecompr.h.

Referenced by ByteDecompressor(), and decompress().

◆ inStream

std::istream& ByteDecompressor::inStream
private

A reference to the input stream from which the compressed data should be read.

Definition at line 320 of file bytecompr.h.

Referenced by decompress().

◆ outBuffer

char* ByteDecompressor::outBuffer
private

An internal buffer for caching decompressed data.

Definition at line 326 of file bytecompr.h.

Referenced by ByteDecompressor(), decompress(), read(), and ~ByteDecompressor().

◆ outPos

size_t ByteDecompressor::outPos
private

The current position in the internal buffer with decompressed data.

Definition at line 342 of file bytecompr.h.

Referenced by ByteDecompressor(), decompress(), and read().

◆ outPosEnd

size_t ByteDecompressor::outPosEnd
private

The position of the end of the decompressed data in the internal buffer.

Definition at line 346 of file bytecompr.h.

Referenced by ByteDecompressor(), decompress(), and read().


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