1#ifndef BYTEME_SOME_FILE_READER_HPP
2#define BYTEME_SOME_FILE_READER_HPP
11#include "magic_numbers.hpp"
45 unsigned char header[3];
48 SelfClosingFILE file(path,
"rb");
49 read = std::fread(header,
sizeof(
unsigned char), 3, file.handle);
52 if (is_gzip(header, read)) {
65 return my_source->load();
68 const unsigned char*
buffer()
const {
69 return my_source->buffer();
73 return my_source->available();
77 std::unique_ptr<Reader> my_source;
Read a Gzip-compressed file.
Read a file without any extra transformations.
Read uncompressed bytes from a Gzip-compressed file.
Definition GzipFileReader.hpp:46
Read bytes from a file, usually text.
Definition RawFileReader.hpp:46
Virtual class for reading bytes from a source.
Definition Reader.hpp:17
Read a file that may or may not be Gzipped.
Definition SomeFileReader.hpp:38
SomeFileReader(const char *path, const SomeFileReaderOptions &options)
Definition SomeFileReader.hpp:44
const unsigned char * buffer() const
Definition SomeFileReader.hpp:68
std::size_t available() const
Definition SomeFileReader.hpp:72
bool load()
Definition SomeFileReader.hpp:64
Simple byte readers and writers.
Options for GzipFileReader construction.
Definition GzipFileReader.hpp:26
std::size_t buffer_size
Definition GzipFileReader.hpp:31
Options for the RawFileReader constructor.
Definition RawFileReader.hpp:25
std::size_t buffer_size
Definition RawFileReader.hpp:30
Options for the SomeFileReader constructor.
Definition SomeFileReader.hpp:24
std::size_t buffer_size
Definition SomeFileReader.hpp:29