My Project
 
Loading...
Searching...
No Matches
HuffmanDecoder.hpp
Go to the documentation of this file.
1
5
6#ifndef HUFFMANDECODER_HPP
7#define HUFFMANDECODER_HPP
8
10#include <bitset>
11#include <iostream>
12#include <stdint.h>
13#include <vector>
14#include <fstream>
15
16using namespace std;
17
23{
27 ifstream inFile;
28
32 unordered_map<uint32_t, uint8_t> code;
33
38
43
47 void readCodes();
48
53 vector<uint8_t> readMessage();
54
60 vector<uint8_t> decodeVec(const vector<uint8_t> &buffer);
61
62public:
69 vector<uint8_t> decodeFile(const string &filenameIn, const string &filenameOut);
70
76 vector<uint8_t> decodeFile(const string &filenameIn);
77
83 vector<uint8_t> decodeVector(const vector<uint8_t> &vector);
84};
85
86#endif // HUFFMANDECODER_HPP
Handles reading a binary-encoded file, reconstructing the Huffman codes, and decoding the data.
Definition HuffmanDecoder.hpp:23
vector< uint8_t > decodeVector(const vector< uint8_t > &vector)
Decodes a Huffman-encoded byte vector in memory.
Definition HuffmanDecoder.cpp:144
vector< uint8_t > decodeVec(const vector< uint8_t > &buffer)
Decodes a buffer of raw Huffman-encoded bytes into original data.
Definition HuffmanDecoder.cpp:81
vector< uint8_t > decodeFile(const string &filenameIn, const string &filenameOut)
Decodes a file and writes the decoded output to another file.
Definition HuffmanDecoder.cpp:126
uint64_t current_position
Tracks the current byte position in the input file for reading code maps and data.
Definition HuffmanDecoder.hpp:37
uint8_t last_bit_to_read
Specifies how many bits in the last byte are valid and should be read.
Definition HuffmanDecoder.hpp:42
void readCodes()
Reads the Huffman header and code mappings from the encoded file.
Definition HuffmanDecoder.cpp:3
vector< uint8_t > readMessage()
Reads and decodes the Huffman-encoded message from the input file.
Definition HuffmanDecoder.cpp:66
ifstream inFile
Input file stream from which the encoded data is read.
Definition HuffmanDecoder.hpp:27
unordered_map< uint32_t, uint8_t > code
Maps Huffman codes (represented as integers) to original byte values.
Definition HuffmanDecoder.hpp:32