Inflater.h 913 Bytes
Newer Older
daFischer's avatar
first  
daFischer committed
1 2
/* 
 * File:   Inflater.h
3
 * Author: Johannes Fischer
daFischer's avatar
first  
daFischer committed
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * Created on May 8, 2014, 12:46 PM
 */

#ifndef INFLATER_H
#define	INFLATER_H

#include <stdio.h>
#include <string>
#include <fstream>
#include <zlib.h>
#include <assert.h>
#include "SizedArray.h"
17
#include "Constants.h"
daFischer's avatar
first  
daFischer committed
18 19 20

using namespace std;

21
#define CHUNK 32768
daFischer's avatar
first  
daFischer committed
22 23 24

class Inflater {
public:
daFischer's avatar
daFischer committed
25
    Inflater(FILE* f);
daFischer's avatar
first  
daFischer committed
26 27 28
    ~Inflater();
    bool readByte(char* Byte);
    bool readSizedArray(SizedArray* sArray);
daFischer's avatar
daFischer committed
29
    char* readCharArray(int length, bool end);
daFischer's avatar
first  
daFischer committed
30 31
    bool readShort(short* s);
    bool readInt(int* s);
32
    //bool readLong(long* s);
daFischer's avatar
daFischer committed
33
    bool skipBytes(int number);
daFischer's avatar
first  
daFischer committed
34
    bool endOfFile();
daFischer's avatar
daFischer committed
35 36 37
    long int getProgress();
    
    void addChar(char c);
daFischer's avatar
first  
daFischer committed
38 39
    
private:
daFischer's avatar
daFischer committed
40
    FILE* source;
daFischer's avatar
first  
daFischer committed
41 42 43 44 45 46
    unsigned char in[CHUNK];
    unsigned char out[CHUNK];
    int outOffset;
    int ret;
    z_stream strm;
    
daFischer's avatar
daFischer committed
47 48
    string addedChars;
    
daFischer's avatar
first  
daFischer committed
49 50 51 52
};

#endif	/* INFLATER_H */