00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTI_ZIP_DEFLATER_H_
00019 #define _DECAF_UTI_ZIP_DEFLATER_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 #include <decaf/lang/exceptions/NullPointerException.h>
00024 #include <decaf/lang/exceptions/IllegalArgumentException.h>
00025 #include <decaf/lang/exceptions/IllegalStateException.h>
00026 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
00027
00028 #include <vector>
00029
00030 namespace decaf {
00031 namespace util {
00032 namespace zip {
00033
00034 class DeflaterData;
00035
00052 class DECAF_API Deflater {
00053 public:
00054
00058 static const int BEST_SPEED;
00059
00063 static const int BEST_COMPRESSION;
00064
00068 static const int DEFAULT_COMPRESSION;
00069
00073 static const int DEFLATED;
00074
00078 static const int NO_COMPRESSION;
00079
00085 static const int FILTERED;
00086
00090 static const int HUFFMAN_ONLY;
00091
00095 static const int DEFAULT_STRATEGY;
00096
00097 private:
00098
00099
00100 DeflaterData* data;
00101
00102 private:
00103
00104 Deflater( const Deflater& );
00105 Deflater operator= ( const Deflater& );
00106
00107 public:
00108
00119 Deflater( int level, bool nowrap = false );
00120
00125 Deflater();
00126
00127 virtual ~Deflater();
00128
00146 void setInput( const unsigned char* buffer, int size, int offset, int length );
00147
00162 void setInput( const std::vector<unsigned char>& buffer, int offset, int length );
00163
00173 void setInput( const std::vector<unsigned char>& buffer );
00174
00194 void setDictionary( const unsigned char* buffer, int size, int offset, int length );
00195
00212 void setDictionary( const std::vector<unsigned char>& buffer, int offset, int length );
00213
00225 void setDictionary( const std::vector<unsigned char>& buffer );
00226
00236 void setStrategy( int strategy );
00237
00247 void setLevel( int level );
00248
00253 bool needsInput() const;
00254
00259 void finish();
00260
00264 bool finished() const;
00265
00286 int deflate( unsigned char* buffer, int size, int offset, int length );
00287
00305 int deflate( std::vector<unsigned char>& buffer, int offset, int length );
00306
00319 int deflate( std::vector<unsigned char>& buffer );
00320
00326 long long getAdler() const;
00327
00333 long long getBytesRead() const;
00334
00340 long long getBytesWritten() const;
00341
00348 void reset();
00349
00355 void end();
00356
00357 };
00358
00359 }}}
00360
00361 #endif