huffman.h
Go to the documentation of this file.
00001 #ifndef HUFFMAN_HEADER
00002 #define HUFFMAN_HEADER
00003 
00004 #include <iostream>
00005 #include <sstream>
00006 #include <fstream>
00007 #include <vector>
00008 #include <list>
00009 #include <algorithm>
00010 #include <ctime>
00011 #include "huffmanElement.h"
00012 #include "letter.h"
00013 
00014 using namespace std;
00015 
00022 class Huffman {
00023         private:
00027                 static const int ENCODING_MAX;
00031                 vector<HuffmanElement*> tree;
00035                 HuffmanElement* root;
00039                 int* lookup_positions;
00043                 int print_status_counter;
00044 
00045         public:
00046                 Huffman();
00047                 Huffman(const Huffman& original);
00048                 virtual ~Huffman();
00049                 virtual Huffman& operator=(const Huffman& original);
00050                 virtual void build_tree(string text, bool file);
00051                 virtual bool* compress(bool* compr_bits_ar, int* count, string text, bool file);
00052                 virtual bool* compress_table(bool* compr_bits_ar, int* count, string text, bool file);
00053                 virtual bool* compress_lookup(bool* compr_bits_ar, int* count, string text, bool file);
00054                 virtual void decompress(string filename, string out_filename);
00055                 virtual string decompress(vector<bool> compr_bits);
00056                 virtual void save_tree(string filename) const;
00057 
00058         private:
00059                 void copy_huffman(const Huffman& original);
00060                 void delete_huffman();
00061                 string decompress(bool* compr_bits, int count, string filename);
00062                 void save_element(fstream* f, HuffmanElement* element) const;
00063                 bool depth_search(char search_node, HuffmanElement* node, vector<bool>* compr_buffer);
00064                 void read_file(string filename, vector<Letter>* letters) const;
00065                 void read_file(string filename, vector<char>* letters) const;
00066                 string to_ascii(string text) const;
00067                 void print_and_write(string file_name, string text) const;
00068                 int insert_compr_bits(bool* compr_bits, unsigned int compr_bits_index, bool* compr_bits_rev, HuffmanElement* cur_element) const;
00069                 void print_status(int overall, int current);
00070 };
00071 
00072 #endif
 All Classes Files Functions