6namespace pflib::packing {
42 virtual void seek(
int off) = 0;
55 template <
typename WordType,
56 std::enable_if_t<std::is_integral<WordType>::value,
bool> =
true>
58 seek(off *
sizeof(WordType));
73 template <
typename WordType>
75 return tell() /
sizeof(WordType);
99 template <
typename WordType,
100 std::enable_if_t<std::is_integral<WordType>::value,
bool> =
true>
102 return read(
reinterpret_cast<char*
>(w),
sizeof(WordType)*count);
118 template <
typename WordType,
119 std::enable_if_t<std::is_integral<WordType>::value,
bool> =
true>
137 template <
typename ObjectType,
138 std::enable_if_t<std::is_class<ObjectType>::value,
bool> =
true>
140 return o.
read(*
this);
158 template <
typename ContentType>
162 if (!(*
this >> vec[i]))
return *
this;
197 virtual operator bool()
const {
197 virtual operator bool()
const {
…}
Reading a raw data stream with some underlying backend.
Definition Reader.h:19
void seek(int off)
Seek by number of words.
Definition Reader.h:57
Reader & read(std::vector< ContentType > &vec, std::size_t count, std::size_t offset=0)
Read the next 'count' objects into the input vector.
Definition Reader.h:159
virtual Reader & read(char *w, std::size_t count)=0
Read the next 'count' bytes into the input handle w.
virtual bool operator!() const
Check if reader is in a fail state.
Definition Reader.h:179
virtual bool eof()=0
check if file is done
int tell()
Tell by number of words.
Definition Reader.h:74
virtual ~Reader()=default
virtual destructor for inheritance
Reader & read(WordType *w, std::size_t count)
Read the next 'count' words into the input handle.
Definition Reader.h:101
virtual void seek(int off)=0
Go ("seek") a specific position in the stream.
Reader()=default
default constructor
Reader & operator>>(WordType &w)
Stream the next word into the input handle.
Definition Reader.h:120
virtual int tell()=0
Tell us where the reader is.
Reader & operator>>(ObjectType &o)
Stream into a class object.
Definition Reader.h:139
virtual bool good() const =0
Check if reader is in a good state.