Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

BSByteStream Class Reference

#include <BSByteStream.h>

Inheritance diagram for BSByteStream:

ByteStream GPEnabled

List of all members.

Detailed Description

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. {verbatim} GP<ByteStream> in=ByteStreamcreate(infile,"rb"); GP<ByteStream> out=ByteStreamcreate(outfile,"wb"); if (encoding) { BSByteStream bsb(out, blocksize); bsb.copy(*in); } else { BSByteStream bsb(in); out->copy(bsb); } {verbatim} 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.

You should never directly access a ByteStream object connected to a valid BSByteStream object. The ByteStream object can be accessed again after the destruction of the BSByteStream object. Note that the encoder always flushes its internal buffers and writes a few final code bytes when the BSByteStream object is destroyed. Note also that the decoder often reads a few bytes beyond the last code byte written by the encoder. This lag means that you must reposition the ByteStream after the destruction of the BSByteStream object and before re-using the ByteStream object (see {IFFByteStream}.)

Definition at line 201 of file BSByteStream.h.

Public Types

enum  { MINBLOCK = 10, MAXBLOCK = 4096 }
enum  { FREQMAX = 4, CTXIDS = 3 }
enum  codepage_type { RAW, AUTO, NATIVE, UTF8 }

Public Member Functions

virtual void flush (void)=0
int get_count (void) const
GNativeString getAsNative (void)
GUTF8String getAsUTF8 (void)
ByteStreamoperator & ()
ByteStreamoperator & () const
virtual size_t read (void *buffer, size_t size)
virtual int seek (long offset, int whence=SEEK_SET, bool nothrow=false)
virtual long tell (void) const
virtual size_t write (const void *buffer, size_t size)
Utility Functions.
Class ByteStream# implements these functions using the virtual interface functions only. All subclasses of ByteStream# inherit these functions.

size_t copy (ByteStream &bsfrom, size_t size=0)
size_t format (const char *fmt,...)
 Allows printf() type operations to a bytestream.
void formatmessage (const char *fmt,...)
TArray< char > get_data (void)
 Use at your own risk, only guarenteed to work for ByteStream::Memorys.
unsigned int read16 ()
unsigned int read24 ()
unsigned int read32 ()
unsigned int read8 ()
size_t readall (void *buffer, size_t size)
virtual size_t readat (void *buffer, size_t sz, int pos)
int scanf (const char *fmt,...)
 Allows scanf() type operations on a bytestream.
virtual int size (void) const
size_t writall (const void *buffer, size_t size)
void write16 (unsigned int card16)
void write24 (unsigned int card24)
void write32 (unsigned int card32)
void write8 (unsigned int card8)
void writemessage (const char *message)
size_t writestring (const GNativeString &s)
size_t writestring (const GUTF8String &s)
Virtual Functions.
These functions are usually implemented by each subclass of ByteStream#.

virtual size_t read (void *buffer, size_t size)
virtual int seek (long offset, int whence=SEEK_SET, bool nothrow=false)
virtual size_t write (const void *buffer, size_t size)

Static Public Member Functions

static GP< ByteStreamcreate (FILE *const f, char const *const mode, const bool closeme)
static GP< ByteStreamcreate (const int fd, char const *const mode, const bool closeme)
static GP< ByteStreamcreate (char const *const mode)
static GP< ByteStreamcreate (const GURL &url, char const *const mode)
static GP< ByteStreamcreate (void const *const buffer, const size_t size)
static GP< ByteStreamcreate (void)
static GP< ByteStreamcreate (GP< ByteStream > bs, const int blocksize)
static GP< ByteStreamcreate (GP< ByteStream > bs)
static GP< ByteStreamcreate_static (void const *buffer, size_t size)
static GP< ByteStreamget_stderr (char const *mode=0)
static GP< ByteStreamget_stdin (char const *mode=0)
static GP< ByteStreamget_stdout (char const *mode=0)

Public Attributes

enum ByteStream::codepage_type cp

Static Public Attributes

static const char * EndOfFile = ERR_MSG("EOF")

Protected Member Functions

 BSByteStream (GP< ByteStream > bs)
 Wrapper (const GP< ByteStream > &xbs)
 Wrapper (void)

Protected Attributes

unsigned int blocksize
int bptr
volatile int count
 The reference counter.
BitContext ctx [300]
unsigned char * data
GP< ByteStreamgbs
GPBuffer< unsigned char > gdata
GP< ZPCodecgzp
long offset
int size

Private Member Functions

 BSByteStream (ByteStream *, int)
 BSByteStream (ByteStream *)
 BSByteStream (const BSByteStream &)
BSByteStreamoperator= (const BSByteStream &)


class  Decode
class  Encode

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

Generated by  Doxygen 1.6.0   Back to index