1#ifndef BYTEME_ISTREAM_READER_HPP
2#define BYTEME_ISTREAM_READER_HPP
25template<
class Po
inter_ = std::istream*>
32 IstreamReader(Pointer_ input,
size_t buffer_size = 65536) : my_input(std::move(input)), my_buffer(buffer_size) {}
39 my_input->read(
reinterpret_cast<char*
>(my_buffer.data()), my_buffer.size());
40 my_read = my_input->gcount();
42 if (my_read < my_buffer.size()) {
43 if (my_input->eof()) {
46 throw std::runtime_error(
"failed to finish reading the input stream");
53 const unsigned char*
buffer()
const {
54 return my_buffer.data();
63 std::vector<unsigned char> my_buffer;
Read bytes from a std::istream.
Definition IstreamReader.hpp:26
const unsigned char * buffer() const
Definition IstreamReader.hpp:53
size_t available() const
Definition IstreamReader.hpp:57
bool load()
Definition IstreamReader.hpp:34
IstreamReader(Pointer_ input, size_t buffer_size=65536)
Definition IstreamReader.hpp:32
Virtual class for reading bytes from a source.
Definition Reader.hpp:15
Simple byte readers and writers.