#include //for cout and cin #include //using string variable #include //working with input and output file #include #define VEC_SIZE 256 //using namespace std; static const char * magicWord="HUFF"; struct huff_node { unsigned long int count; //cout the probibility of each character signed short int ch; //store the character int left; // these are 3 integer representing index in vector to structure for making huffman tree int right; int parent; bool ignore; //true-> if we already handled this node unsigned short int len; //length of the huffman code... unsigned long int codeWord; //for storing binary code word...e.g. 00111010101 }; class huffman { public: huffman (char const *,char const *); // cunstructor of the class...get file name as input void getLastError(void); // print out errorMessage void encode(void); //main method to encode file ... void decode(void); //main method to decode file... bool print_detail; private: void generateHuffmanCode(unsigned char *,unsigned char *,int); void writeHuffman(void); //write generated huffman code to output file... void cop(void); double bitRate(void); //calculating bitrate... void printProbility(void); //print out character and it's corresponding probibility... void readInputFile(void); //read each char from input file and count probility and store in array void encodeHuffman(void); int checkVectorSize(void); int smallestProbility(void); //return the two smallest probility in array.. bool error_occured; //true -> means some error ocurred !!! std::string errorMessage; //store error message const char * inputFileName; //store input file name const char * outputFileName; //store output file name std::ofstream myFileOut; //handle to input file std::ifstream myFileIn; //handle to output file std::vector vec; //array of our huffman structure unsigned long int ui; unsigned char vector_size; };