pflib v3.0.0-rc1-25-gb91774e
Pretty Fine HGCROC Interaction Library
All Classes Namespaces Files Functions Variables Typedefs Pages
FileReader.h
1#pragma once
2
3#include <fstream>
4#include <iostream> //debuggin
5#include <string>
6#include <type_traits>
7
8#include "pflib/packing/Reader.h"
9
10namespace pflib::packing {
11
25class FileReader : public Reader {
26 public:
32 FileReader();
33
41 void open(const std::string& file_name);
42
48 FileReader(const std::string& file_name);
49
51 ~FileReader() = default;
52
62 void seek(int off) override;
63
69 int tell() override;
70
78 Reader& read(char* w, std::size_t count) override;
79
88 bool good() const override;
89
97 bool eof() override;
98
99 private:
104}; // Reader
105
106} // namespace pflib::packing
Reading a raw data file.
Definition FileReader.h:25
Reader & read(char *w, std::size_t count) override
Read the next count bytes into pointer w.
Definition FileReader.cxx:29
void seek(int off) override
Go ("seek") a specific position in the file.
Definition FileReader.cxx:21
bool good() const override
Check if reader is in a fail state.
Definition FileReader.cxx:34
FileReader()
default constructor
Definition FileReader.cxx:5
bool eof() override
check if file is done
Definition FileReader.cxx:38
void open(const std::string &file_name)
Open a file with this reader.
Definition FileReader.cxx:9
~FileReader()=default
destructor, close the input file stream
std::size_t file_size_
file size in bytes
Definition FileReader.h:103
std::ifstream file_
file stream we are reading from
Definition FileReader.h:101
int tell() override
Tell us where the reader is.
Definition FileReader.cxx:25
Reading a raw data stream with some underlying backend.
Definition Reader.h:19