summaryrefslogtreecommitdiff
path: root/lib/compress/CompressStream.h
diff options
context:
space:
mode:
authorBen Summers <ben@fluffy.co.uk>2005-10-14 08:50:54 +0000
committerBen Summers <ben@fluffy.co.uk>2005-10-14 08:50:54 +0000
commit99f8ce096bc5569adbfea1911dbcda24c28d8d8b (patch)
tree049c302161fea1f2f6223e1e8f3c40d9e8aadc8b /lib/compress/CompressStream.h
Box Backup 0.09 with a few tweeks
Diffstat (limited to 'lib/compress/CompressStream.h')
-rw-r--r--lib/compress/CompressStream.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/compress/CompressStream.h b/lib/compress/CompressStream.h
new file mode 100644
index 00000000..7959e3dc
--- /dev/null
+++ b/lib/compress/CompressStream.h
@@ -0,0 +1,62 @@
+// --------------------------------------------------------------------------
+//
+// 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);
+ virtual void WriteAllBuffered();
+ virtual void Close();
+ virtual bool StreamDataLeft();
+ virtual bool StreamClosed();
+
+protected:
+ void CheckRead();
+ void CheckWrite();
+ void CheckBuffer();
+ void WriteCompressedData(bool SyncFlush = false);
+
+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
+