pflib v3.9.0-rc3-11-g2537d8f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
BufferReader.h
1#pragma once
2
3#include <cstdint>
4#include <stdexcept>
5#include <vector>
6
7#include "pflib/packing/Reader.h"
8
9namespace pflib::packing {
10
27class BufferReader : public Reader {
28 public:
33
35 ~BufferReader() = default;
36
38 void seek(int off) override;
40 int tell() override;
42 Reader& read(char* w, std::size_t count) override;
43
49 bool good() const override;
50 bool eof() const override;
51
52 private:
53 // current buffer we are reading
54 const std::vector<uint8_t>& buffer_;
55 // current index in buffer we are reading
56 std::size_t i_word_;
57}; // BufferReader
58
59} // namespace pflib::packing
This class is a helper class for reading the buffer stored in the raw data format.
Definition BufferReader.h:27
BufferReader(const std::vector< uint8_t > &b)
Initialize a reader by wrapping a buffer to read.
Definition BufferReader.cxx:5
int tell() override
return where in the word we are in bytes
Definition BufferReader.cxx:10
~BufferReader()=default
default destructor so handle to buffer is given up
void seek(int off) override
go to the index off in bytes
Definition BufferReader.cxx:8
Reader & read(char *w, std::size_t count) override
read the next count bytes into array w and move the index
Definition BufferReader.cxx:12
bool eof() const override
check if file is done
Definition BufferReader.cxx:21
bool good() const override
Return state of buffer.
Definition BufferReader.cxx:20
Reading a raw data stream with some underlying backend.
Definition Reader.h:19