pflib v3.0.0-rc1-29-g3a901ac
Pretty Fine HGCROC Interaction Library
All Classes Namespaces Files Functions Variables Typedefs Pages
BufferReader.h
1#pragma once
2
3#include <stdexcept>
4#include <vector>
5
6#include "pflib/packing/Reader.h"
7
8namespace pflib::packing {
9
26class BufferReader : public Reader {
27 public:
32
34 ~BufferReader() = default;
35
37 void seek(int off) override;
39 int tell() override;
41 Reader& read(char* w, std::size_t count) override;
42
48 bool good() const override;
49
50 private:
51 // current buffer we are reading
52 const std::vector<uint8_t>& buffer_;
53 // current index in buffer we are reading
54 std::size_t i_word_;
55}; // BufferReader
56
57} // namespace pflib::packing
This class is a helper class for reading the buffer stored in the raw data format.
Definition BufferReader.h:26
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:12
~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:16
bool good() const override
Return state of buffer.
Definition BufferReader.cxx:24
Reading a raw data stream with some underlying backend.
Definition Reader.h:19