1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// --------------------------------------------------------------------------
//
// File
// Name: CompressStream.h
// Purpose: Compressing stream
// Created: 27/5/04
//
// --------------------------------------------------------------------------
#ifndef COMPRESSSTREAM__H
#define COMPRESSSTREAM__H
#include "IOStream.h"
// --------------------------------------------------------------------------
//
// Class
// Name: CompressStream
// Purpose: Compressing stream
// Created: 27/5/04
//
// --------------------------------------------------------------------------
class CompressStream : public IOStream
{
public:
CompressStream(IOStream *pStream, bool TakeOwnership,
bool DecompressRead, bool CompressWrite, bool PassThroughWhenNotCompressed = false);
~CompressStream();
private:
// No copying (have implementations which exception)
CompressStream(const CompressStream &);
CompressStream &operator=(const CompressStream &);
public:
virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
virtual void Write(const void *pBuffer, int NBytes,
int Timeout = IOStream::TimeOutInfinite);
virtual void WriteAllBuffered(int Timeout = IOStream::TimeOutInfinite);
virtual void Close();
virtual bool StreamDataLeft();
virtual bool StreamClosed();
protected:
void CheckRead();
void CheckWrite();
void CheckBuffer();
void WriteCompressedData(bool SyncFlush = false,
int Timeout = IOStream::TimeOutInfinite);
private:
IOStream *mpStream;
bool mHaveOwnership;
bool mDecompressRead;
bool mCompressWrite;
bool mPassThroughWhenNotCompressed;
// Avoid having to include Compress.h
void *mpReadCompressor;
void *mpWriteCompressor;
void *mpBuffer;
bool mIsClosed;
};
#endif // COMPRESSSTREAM__H
|