mortified_penguin

huff_code.hpp

Dec 29th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #ifndef CODE_HPP
  2. #define CODE_HPP
  3.  
  4. #include <map>
  5. #include <queue>
  6. #include <fstream>
  7. #include <cstdint>
  8.  
  9. #include "node.hpp"
  10. #include "tree.hpp"
  11.  
  12.  
  13. enum struct opentype: bool
  14. {
  15.    BINARY,
  16.    PLAIN
  17. };
  18.  
  19.  
  20. class compr
  21. {
  22.    public:
  23.       compr(std::string &infile_, const opentype opentype_);
  24.       virtual ~compr() = 0;
  25.  
  26.    protected:
  27.       std::ifstream infile;
  28.       std::map<char, int> histog;
  29. };
  30.  
  31.  
  32. class compress: public compr
  33. {
  34.    public:
  35.       compress(std::string infile_);
  36.       void write(const std::string outfile_);
  37. };
  38.  
  39. class decompress: public compr
  40. {
  41.    public:
  42.       decompress(std::string infile_);
  43.       std::string plaintext() const;
  44.  
  45.    private:
  46.       uint16_t stream_offset;
  47.       std::string ptext;
  48.  
  49.       void getplain(const tree &hc);
  50. };
  51.  
  52.  
  53.  
  54. #endif // CODE_HPP
Advertisement
Add Comment
Please, Sign In to add comment