00001 #ifndef LZW_HPP 00002 #define LZW_HPP 00003 00004 #include <iostream> 00005 #include <stdlib.h> 00006 using namespace std; 00007 00008 #include "BitIO.hpp" 00009 #include "Dictionnaire.hpp" 00010 #include "SequenceMessages.hpp" 00011 #include <fstream> 00012 00013 typedef unsigned long Code; //Définition du type Code. 00014 00023 class Lzw { 00024 00025 public : 00026 enum InOutStatus{CODAGE, DECODAGE}; 00027 private : 00028 00029 InOutStatus iostatus; 00030 TBitStream *bitStream; 00031 ifstream* ifs; 00032 ofstream* ofs; 00034 Dictionnaire dico; 00035 Code SP; 00038 int tailleCode; 00040 int valMaxCode; 00041 int coutCodage; 00047 bool endOfInputFlux(); 00048 00049 00050 /********************************/ 00051 /* METHODE POUR LA COMPRESSION * / 00052 /********************************/ 00053 00060 Message litMessage(); 00061 00070 void ecritCode(Code code); 00071 00072 /**********************************/ 00073 /* METHODE POUR LA DECOMPRESSION * / 00074 /**********************************/ 00075 00084 Code litCode(); 00085 00093 void ecritMessages(SequenceMessages seq); 00094 00095 public: 00096 00100 Lzw(); 00101 00105 Lzw(ifstream* ifs, ofstream* ofs, InOutStatus iostatus); 00106 00112 void initDictionnaire(); 00113 00114 00119 void codage(); 00120 00125 void decodage(unsigned long nbBitTotal); 00126 }; 00127 #endif //LZW_HPP