00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __ZStream_ZLib__
00026 #define __ZStream_ZLib__ 1
00027 #include "zconfig.h"
00028 #include "ZCONFIG_API.h"
00029 #include "ZCONFIG_SPI.h"
00030
00031 #ifndef ZCONFIG_API_Avail__Stream_ZLib
00032 # define ZCONFIG_API_Avail__Stream_ZLib ZCONFIG_SPI_Enabled(zlib)
00033 #endif
00034
00035 #ifndef ZCONFIG_API_Desired__Stream_ZLib
00036 # define ZCONFIG_API_Desired__Stream_ZLib 1
00037 #endif
00038
00039 #include "ZStreamer.h"
00040
00041 #if ZCONFIG_API_Enabled(Stream_ZLib)
00042
00043 #include <zlib.h>
00044
00045
00046 #pragma mark -
00047 #pragma mark * ZStreamR_ZLibDecode
00048
00050
00051 class ZStreamR_ZLibDecode : public ZStreamR
00052 {
00053 public:
00054 ZStreamR_ZLibDecode(const ZStreamR& iStreamSource);
00055 ZStreamR_ZLibDecode(size_t iBufferSize, const ZStreamR& iStreamSource);
00056 ~ZStreamR_ZLibDecode();
00057
00058
00059 virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00060 virtual size_t Imp_CountReadable();
00061
00062 protected:
00063 void Internal_Init(size_t iBufferSize);
00064
00065 const ZStreamR& fStreamSource;
00066 z_stream fState;
00067 Bytef* fBuffer;
00068 size_t fBufferSize;
00069 };
00070
00071 typedef ZStreamerR_FT<ZStreamR_ZLibDecode> ZStreamerR_ZLibDecode;
00072
00073
00074 #pragma mark -
00075 #pragma mark * ZStreamW_ZLibEncode
00076
00078
00079 class ZStreamW_ZLibEncode : public ZStreamW
00080 {
00081 public:
00082 ZStreamW_ZLibEncode(int iCompressionLevel, const ZStreamW& iStreamSink);
00083 ZStreamW_ZLibEncode(int iCompressionLevel, size_t iBufferSize, const ZStreamW& iStreamSink);
00084 ~ZStreamW_ZLibEncode();
00085
00086
00087 virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00088 virtual void Imp_Flush();
00089
00090 protected:
00091 void Internal_Init(int iCompressionLevel, size_t iBufferSize);
00092 void Internal_Flush();
00093
00094 const ZStreamW& fStreamSink;
00095 z_stream fState;
00096 Bytef* fBuffer;
00097 size_t fBufferSize;
00098 };
00099
00100
00101 #pragma mark -
00102 #pragma mark * ZStreamerW_ZLibEncode
00103
00105
00106 class ZStreamerW_ZLibEncode : public ZStreamerW
00107 {
00108 public:
00109 ZStreamerW_ZLibEncode(int iCompressionLevel, ZRef<ZStreamerW> iStreamer);
00110 ZStreamerW_ZLibEncode(int iCompressionLevel, size_t iBufferSize, ZRef<ZStreamerW> iStreamer);
00111
00112 virtual ~ZStreamerW_ZLibEncode();
00113
00114
00115 virtual const ZStreamW& GetStreamW();
00116
00117 protected:
00118 ZRef<ZStreamerW> fStreamer;
00119 ZStreamW_ZLibEncode fStream;
00120 };
00121
00122
00123
00124 #endif // ZCONFIG_API_Enabled(Stream_ZLib)
00125
00126 #endif // __ZStream_ZLib__