Handles reading a binary-encoded file, reconstructing the Huffman codes, and decoding the data.
More...
#include <HuffmanDecoder.hpp>
|
vector< uint8_t > | decodeFile (const string &filenameIn, const string &filenameOut) |
| Decodes a file and writes the decoded output to another file.
|
|
vector< uint8_t > | decodeFile (const string &filenameIn) |
| Decodes an input file and returns the decoded contents.
|
|
vector< uint8_t > | decodeVector (const vector< uint8_t > &vector) |
| Decodes a Huffman-encoded byte vector in memory.
|
|
|
void | readCodes () |
| Reads the Huffman header and code mappings from the encoded file.
|
|
vector< uint8_t > | readMessage () |
| Reads and decodes the Huffman-encoded message from the input file.
|
|
vector< uint8_t > | decodeVec (const vector< uint8_t > &buffer) |
| Decodes a buffer of raw Huffman-encoded bytes into original data.
|
|
|
ifstream | inFile |
| Input file stream from which the encoded data is read.
|
|
unordered_map< uint32_t, uint8_t > | code |
| Maps Huffman codes (represented as integers) to original byte values.
|
|
uint64_t | current_position |
| Tracks the current byte position in the input file for reading code maps and data.
|
|
uint8_t | last_bit_to_read |
| Specifies how many bits in the last byte are valid and should be read.
|
|
Handles reading a binary-encoded file, reconstructing the Huffman codes, and decoding the data.
◆ decodeFile() [1/2]
vector< uint8_t > HuffmanDecoder::decodeFile |
( |
const string & | filenameIn | ) |
|
Decodes an input file and returns the decoded contents.
- Parameters
-
filenameIn | The name of the input file to decode. |
- Returns
- The decoded data as a byte vector.
◆ decodeFile() [2/2]
vector< uint8_t > HuffmanDecoder::decodeFile |
( |
const string & | filenameIn, |
|
|
const string & | filenameOut ) |
Decodes a file and writes the decoded output to another file.
- Parameters
-
filenameIn | The name of the encoded input file. |
filenameOut | The name of the output file to write the decoded data. |
- Returns
- The decoded data as a byte vector.
◆ decodeVec()
vector< uint8_t > HuffmanDecoder::decodeVec |
( |
const vector< uint8_t > & | buffer | ) |
|
|
private |
Decodes a buffer of raw Huffman-encoded bytes into original data.
- Parameters
-
buffer | The encoded data buffer. |
- Returns
- A vector of decoded bytes.
◆ decodeVector()
vector< uint8_t > HuffmanDecoder::decodeVector |
( |
const vector< uint8_t > & | vector | ) |
|
Decodes a Huffman-encoded byte vector in memory.
- Parameters
-
vector | The encoded byte vector. |
- Returns
- The decoded byte vector.
◆ readCodes()
void HuffmanDecoder::readCodes |
( |
| ) |
|
|
private |
Reads the Huffman header and code mappings from the encoded file.
◆ readMessage()
vector< uint8_t > HuffmanDecoder::readMessage |
( |
| ) |
|
|
private |
Reads and decodes the Huffman-encoded message from the input file.
- Returns
- A vector of decoded bytes.
◆ code
unordered_map<uint32_t, uint8_t> HuffmanDecoder::code |
|
private |
Maps Huffman codes (represented as integers) to original byte values.
◆ current_position
uint64_t HuffmanDecoder::current_position |
|
private |
Tracks the current byte position in the input file for reading code maps and data.
◆ inFile
ifstream HuffmanDecoder::inFile |
|
private |
Input file stream from which the encoded data is read.
◆ last_bit_to_read
uint8_t HuffmanDecoder::last_bit_to_read |
|
private |
Specifies how many bits in the last byte are valid and should be read.
The documentation for this class was generated from the following files: