-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
55 lines (46 loc) · 1.07 KB
/
main.cpp
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
55
#include <iostream>
#include <fstream>
#include <string>
#include "param_parser.h"
#include "help.h"
#include "mainlib/huffman.h"
// #include "debughelpers/tree_printer.h"
// #include "debughelpers/bit_printer.h"
using namespace std;
int main(int argc, char *argv[])
{
input_param options = parse_options(argc, argv);
if (show_help_if_option_invalid(options))
{
// The options were stupid enough to warrant a full exit
return 1;
}
if (options.encode)
{
if (options.verbose)
cout << "Generating Huffman Tree" << endl;
tree *huffman_tree = make_huffman_tree(options);
if (options.verbose)
cout << "Generating Huffman Code" << endl;
huffman_code *huff_code = generate_code(huffman_tree);
if (options.verbose)
cout << "Encoding file" << endl;
if (encode_file(huff_code, options) == 0)
{
//job done
}
delete huffman_tree;
delete huff_code;
// if (options.generate_code)
// output_code(options);
// if (options.generate_table)
// output_table(options);
}
else
{
{
naive_decode_with_header(options);
}
}
return 0;
}