2018-05-03 11:28:17 +00:00
|
|
|
/**
|
2018-05-25 11:28:37 +00:00
|
|
|
* \file io.hh
|
2018-05-03 11:28:17 +00:00
|
|
|
* \brief Header for file reading and writing
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LZW_SRC_IO_H_
|
|
|
|
#define LZW_SRC_IO_H_
|
|
|
|
|
|
|
|
#include <cstdint>
|
2018-06-21 15:38:51 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <fstream>
|
2018-05-25 10:00:58 +00:00
|
|
|
#include <iostream>
|
2018-05-03 11:28:17 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Un fichier compressé se compose ainsi :
|
|
|
|
* char_size : taille d'un caractère en bits (1B)
|
|
|
|
* nb_chunk : nombre de chunks (4B)
|
|
|
|
* chunks* : chunks
|
|
|
|
*
|
|
|
|
* Un chunk se compose ainsi :
|
|
|
|
* nb_char_chunk : nombre de caractères du chunk (2B)
|
2018-06-21 15:38:51 +00:00
|
|
|
* text* : caractères de taille char_size (ceil((char_size * nb_char_chunk) /
|
|
|
|
* 8))
|
2018-05-03 11:28:17 +00:00
|
|
|
*
|
|
|
|
* Si le dernier caractère ne termine pas le dernier octet du chunk, les
|
|
|
|
* derniers bits sont mit à zéro
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// \brief Écrit dans le fichier le texte compressé
|
2018-06-21 15:38:51 +00:00
|
|
|
void write_file(std::ofstream &,
|
|
|
|
const std::vector<std::vector<std::uint16_t>> &);
|
2018-05-25 10:00:58 +00:00
|
|
|
|
|
|
|
/// \brief Écrit un chunk dans le fichier de sortie
|
2018-06-21 15:38:51 +00:00
|
|
|
void write_chunk(std::ofstream &, const std::vector<std::uint16_t> &);
|
2018-05-03 11:28:17 +00:00
|
|
|
|
|
|
|
#endif /* LZW_SRC_IO_H_ */
|