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_bzip2__
00026 #define __ZStream_bzip2__ 1
00027 #include "zconfig.h"
00028 #include "ZCONFIG_API.h"
00029 #include "ZCONFIG_SPI.h"
00030
00031 #ifndef ZCONFIG_API_Avail__Stream_bzip2
00032 # define ZCONFIG_API_Avail__Stream_bzip2 ZCONFIG_SPI_Enabled(bzip2)
00033 #endif
00034
00035 #ifndef ZCONFIG_API_Desired__Stream_bzip2
00036 # define ZCONFIG_API_Desired__Stream_bzip2 1
00037 #endif
00038
00039 #include "ZStreamer.h"
00040
00041 #if ZCONFIG_API_Enabled(Stream_bzip2)
00042
00043 #include <bzlib.h>
00044
00045
00046 #pragma mark -
00047 #pragma mark * ZStreamR_bzip2Decode
00048
00050
00051 class ZStreamR_bzip2Decode : public ZStreamR
00052 {
00053 public:
00054 ZStreamR_bzip2Decode(const ZStreamR& iStreamSource);
00055 ZStreamR_bzip2Decode(size_t iBufferSize, const ZStreamR& iStreamSource);
00056 ~ZStreamR_bzip2Decode();
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 bz_stream fState;
00067 char* fBuffer;
00068 size_t fBufferSize;
00069 };
00070
00071 typedef ZStreamerR_FT<ZStreamR_bzip2Decode> ZStreamerR_bzip2Decode;
00072
00073
00074 #pragma mark -
00075 #pragma mark * ZStreamW_bzip2Encode
00076
00078
00079 class ZStreamW_bzip2Encode : public ZStreamW
00080 {
00081 public:
00082 ZStreamW_bzip2Encode(int iBlockSize100K, const ZStreamW& iStreamSink);
00083 ZStreamW_bzip2Encode(int iBlockSize100K, size_t iBufferSize, const ZStreamW& iStreamSink);
00084 ~ZStreamW_bzip2Encode();
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 iBlockSize100K, size_t iBufferSize);
00092 void Internal_Flush();
00093
00094 const ZStreamW& fStreamSink;
00095 bz_stream fState;
00096 char* fBuffer;
00097 size_t fBufferSize;
00098 };
00099
00100
00101 #pragma mark -
00102 #pragma mark * ZStreamerW_bzip2Encode
00103
00105
00106 class ZStreamerW_bzip2Encode : public ZStreamerW
00107 {
00108 public:
00109 ZStreamerW_bzip2Encode(int iBlockSize100K, ZRef<ZStreamerW> iStreamer);
00110 ZStreamerW_bzip2Encode(int iBlockSize100K, size_t iBufferSize, ZRef<ZStreamerW> iStreamer);
00111
00112 virtual ~ZStreamerW_bzip2Encode();
00113
00114
00115 virtual const ZStreamW& GetStreamW();
00116
00117 protected:
00118 ZRef<ZStreamerW> fStreamer;
00119 ZStreamW_bzip2Encode fStream;
00120 };
00121
00122
00123 #pragma mark -
00124 #pragma mark * ZStream_bzip2
00125
00126 namespace ZStream_bzip2 {
00127
00128 void sAnalyze(const ZStreamR& iStreamR, vector<pair<uint64, uint32> >& oOffsets);
00129
00130 }
00131
00132
00133 #endif // ZCONFIG_API_Enabled(Stream_bzip2)
00134
00135 #endif // __ZStream_bzip2__