/
gzip.hpp
38 lines (30 loc) · 878 Bytes
/
gzip.hpp
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
#pragma once
/*
* FILE: gzip.hpp
* Created: Feb 22, 2018 Thu
*/
#include <vector>
#include "zlib.h"
#include "options.hpp"
#define OUT_SIZE 32768U /* out buffer size */
#define IN_SIZE 16384 /* file input buffer size */
#define RL_OK 0
#define RL_END 1
#define RL_ERR -1
class Gzip
{
public:
Gzip(bool gzipped);
//~Gzip();
int getline(std::ifstream & ifs, std::string & line);
private:
bool gzipped;
// zlib related
char* line_start; // pointer to the start of a line within the 'z_out' buffer
z_stream strm; // stream control structure. Holds stream in/out buffers (byte arrays), sizes, positions etc.
std::vector<unsigned char> z_in; // IN buffer for compressed data
std::vector<unsigned char> z_out; // OUT buffer for decompressed data
private:
void init();
int inflatez(std::ifstream & ifs); // 'z' in the name to distinguish from zlib.inflate
};