class BSByteStream: public ByteStream

Performs bzz compression/decompression.

Inheritance:


Public Methods

[more] BSByteStream(ByteStream &bs, int blocksize=0)
Constructs a BSByteStream.


Inherited from ByteStream:

Public

Virtual Functions.

[more]virtual ~ByteStream()
Virtual destructor.
[more]virtual size_t read(void *buffer, size_t size)
Reads data from a ByteStream.
[more]virtual size_t write(const void *buffer, size_t size)
Writes data to a ByteStream.
[more]virtual long tell(void)
Returns the offset of the current position in the ByteStream.
[more]virtual int is_seekable(void) const
Tests whether function seek can seek backwards.
[more]virtual void seek(long offset, int whence = SEEK_SET)
Sets the current position for reading or writing the ByteStream.
[more]virtual void flush()
Flushes all buffers in the ByteStream.

Utility Functions.

[more]size_t readall(void *buffer, size_t size)
Reads data and blocks until everything has been read.
[more]size_t writall(const void *buffer, size_t size)
Writes data and blocks until everything has been written.
[more]size_t copy(ByteStream &bsfrom, size_t size=0)
Copy data from another ByteStream.
[more]void write8(unsigned int card8)
Writes a one-byte integer to a ByteStream.
[more]void write16(unsigned int card16)
Writes a two-bytes integer to a ByteStream.
[more]void write32(unsigned int card32)
Writes a four-bytes integer to a ByteStream.
[more]unsigned int read8()
Reads a one-byte integer from a ByteStream.
[more]unsigned int read16()
Reads a two-bytes integer from a ByteStream.
[more]unsigned int read32()
Reads a four-bytes integer from a ByteStream.


Documentation

Performs bzz compression/decompression.

Class BSByteStream defines a ByteStream which transparently performs the BZZ compression/decompression. The constructor of class BSByteStream takes another ByteStream as argument. Any data written to the BSByteStream is compressed and written to this second ByteStream. Any data read from the BSByteStream is internally generated by decompressing data read from the second ByteStream.

Program bzz demonstrates how to use this class. All the hard work is achieved by a simple ByteStream to ByteStream copy, as shown below.

      StdioByteStream in(infile,"rb");
      StdioByteStream out(outfile,"wb");
      if (encoding) {
          BSByteStream bsb(&out, blocksize);
          bsb.copy(in);
      } else {
          BSByteStream bsb(&in);
          out.copy(bsb);
      }
    
Due to the block oriented nature of the Burrows-Wheeler transform, there is a very significant latency between the data input and the data output. You can use function flush to force data output at the expense of compression efficiency. Destroying the BSByteStream performs an implicit flush.
o BSByteStream(ByteStream &bs, int blocksize=0)
Constructs a BSByteStream. Argument blocksize determines whether the BSByteStream will be used for compressing or decompressing data.
Decompression
Setting blocksize to zero initializes the decompressor. Chunks of data will be read from ByteStream bs and decompressed into an internal buffer. Function read can be used to access the decompressed data.
Compression
Setting blocksize to a positive number between 100 and 4096 initializes the compressor. Data written to the BSByteStream will be accumulated into an internal buffer. The buffered data will be compressed and written to ByteStream bs whenever the buffer sizes reaches the maximum value specified by argument blocksize (in kilobytes). Using a larger block size usually increases the compression ratio at the expense of computation time. There is no need however to specify a block size larger than the total number of bytes to compress. Setting blocksize to 1024 is a good starting point.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java