The Conley-Morse Graphs Software
Classes | Macros
bytecompr.h File Reference

Writing and reading binary data (int, double) with bzip2 compression. More...

#include <iostream>
#include <bzlib.h>

Go to the source code of this file.

Classes

class  ByteCompressor
 A simple wrapper for the bzip2 data compression to an output stream. More...
 
class  ByteDecompressor
 A simple wrapper for the bzip2 data decompression from an input stream. More...
 

Macros

#define DEFBYTEWRITE(var_type)
 Writes a variable to a byte compressor stream. More...
 
#define DEFBYTEREAD(var_type)
 Reads a variable from a byte decompressor stream. More...
 

Detailed Description

Writing and reading binary data (int, double) with bzip2 compression.

This file contains the definition of two classes "ByteCompressor" and "ByteDecompressor" which serve as simple wrappers for putting binary data into a previously opened binary stream, with compression, and getting the data back from a previously compressed stream. This may be useful e.g. for saving a memory dump to a bz2 file, or for saving and then retrieving temporary binary data structures to a bz2 compressed file. Note that the data is not portable, the sizes of types as well as byte order may depend on a particular architecture. These data structures are designed for storing temporary data and re-using it from the same (binary) program. Use with caution.

Author
Pawel Pilarczyk

Definition in file bytecompr.h.

Macro Definition Documentation

◆ DEFBYTEREAD

#define DEFBYTEREAD (   var_type)
Value:
{ \
c. read (reinterpret_cast<char *> (&n), sizeof (var_type)); \
return c; \
} /* operator >> */
ByteDecompressor & operator>>(ByteDecompressor &c, std::string &v)
Definition: byteutil.h:74
A simple wrapper for the bzip2 data decompression from an input stream.
Definition: bytecompr.h:295

Reads a variable from a byte decompressor stream.

Definition at line 558 of file bytecompr.h.

◆ DEFBYTEWRITE

#define DEFBYTEWRITE (   var_type)
Value:
inline ByteCompressor &operator << (ByteCompressor &c, const var_type &n) \
{ \
c. write (reinterpret_cast<const char *> (&n), sizeof (var_type)); \
return c; \
} /* operator << */
ByteCompressor & operator<<(ByteCompressor &c, const std::string &v)
Definition: byteutil.h:64
A simple wrapper for the bzip2 data compression to an output stream.
Definition: bytecompr.h:59

Writes a variable to a byte compressor stream.

Definition at line 268 of file bytecompr.h.