1#ifndef BYTEME_GZIP_FILE_READER_HPP
2#define BYTEME_GZIP_FILE_READER_HPP
11#include "check_buffer_size.hpp"
12#include "SelfClosingGzFile.hpp"
53 my_gzfile(path,
"rb"),
55 check_buffer_size<int>(
56 check_buffer_size<unsigned>(
57 check_buffer_size(options.buffer_size)
74 const std::size_t bufsize = my_buffer.size();
75 auto ret = gzread(my_gzfile.handle, my_buffer.data(), bufsize);
82 my_finished = (my_read < bufsize);
86 const unsigned char*
buffer()
const {
87 return my_buffer.data();
95 SelfClosingGzFile my_gzfile;
96 std::vector<unsigned char> my_buffer;
97 std::size_t my_read = 0;
98 bool my_finished =
false;
100 void check_status() {
102 auto msg = gzerror(my_gzfile.handle, &status);
103 if (status != Z_OK) {
104 throw std::runtime_error(msg);
Read uncompressed bytes from a Gzip-compressed file.
Definition GzipFileReader.hpp:46
std::size_t available() const
Definition GzipFileReader.hpp:90
const unsigned char * buffer() const
Definition GzipFileReader.hpp:86
bool load()
Definition GzipFileReader.hpp:66
GzipFileReader(const char *path, const GzipFileReaderOptions &options)
Definition GzipFileReader.hpp:52
Virtual class for reading bytes from a source.
Definition Reader.hpp:17
Simple byte readers and writers.
Options for GzipFileReader construction.
Definition GzipFileReader.hpp:26
std::size_t buffer_size
Definition GzipFileReader.hpp:31
std::optional< unsigned > gzbuffer_size
Definition GzipFileReader.hpp:38