-
Notifications
You must be signed in to change notification settings - Fork 0
/
lempel_zivW.h
54 lines (49 loc) · 1.51 KB
/
lempel_zivW.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
52
53
54
/**
* @file
* Defines the structure of the Lempel-Ziv W Encoder subclass.
*/
#ifndef _LEMPEL_ZIV_W_H_
#define _LEMPEL_ZIV_W_H_
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#include "lempel_ziv.h"
#include "binarizer.h"
/**
* The "LempelZivWEncoder" is a subclass of the "LempelZivEncoder"
* class for encoding a file using the LZW algorithm.
*
* Because of inheritance, this encoder has a method "encode" which
* is virtual for the parent's class and allows us to use it in the
* main function as if it was any class of encoder.
*/
class LempelZivWEncoder : public LempelZivEncoder
{
/**
* The "dictionary" attribute is a map object which contains
* the pairs of index and the corresponding entries.
*/
std::map < unsigned int, std::string > dictionary;
/**
* The "instant_codes" is another map object for storing the
* symbols in the file and their corresponding instant code.
*/
std::map < char , std::string > instant_codes;
/**
* The "outputs" vector is used for storing the outputs
* and read them from it later, so we can codify these outputs
* in a comfortable way.
*
* It is a vector that stores pairs of indexes and symbols.
*/
std::vector < unsigned int > outputs;
public:
void addFirstIndex(char* inputFileName);
void doEncoding(char* inputFileName);
void encode(char* inputFileName);
void decode(char *inputFileName, char *outputFileName);
bool stringExistsInDict(std::string);
unsigned int getIndexOfString(std::string);
};
#endif