-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMiniz.h
51 lines (45 loc) · 1.21 KB
/
SMiniz.h
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
#pragma once
#include "miniz.h"
#include <functional>
#include <iostream>
#define SMINIZ_BUF_SIZE (1048576)
typedef std::function<bool(const unsigned char* data, size_t length)> WriteFunc;
namespace util
{
class SMiniz
{
protected:
#pragma warning(push)
#pragma warning(disable:4251)
int _compressionLevel = Z_BEST_COMPRESSION;
z_stream _stream;
unsigned char _outBuf[SMINIZ_BUF_SIZE];
WriteFunc _writeFunc = nullptr;
bool _isInitialized = false;
#pragma warning(pop)
public:
SMiniz(WriteFunc writeFunc);
virtual ~SMiniz() = default;
void printStat(int bufLength, size_t index, size_t length, int flush);
};
class SMinizCompress : public SMiniz
{
public:
SMinizCompress(WriteFunc funcWrite) :SMiniz(funcWrite) {}
~SMinizCompress();
void initialize(int compressionLevel = Z_BEST_COMPRESSION);
void end();
int writeDeflate(int flush);
void compressData(const unsigned char* srcData, size_t length, int flush = Z_NO_FLUSH);
};
class SMinizDecompress : public SMiniz
{
public:
SMinizDecompress(WriteFunc funcWrite) :SMiniz(funcWrite) {}
~SMinizDecompress();
void initialize();
void end();
int writeInflate(int flush);
void decompressData(const unsigned char* srcData, size_t length);
};
}