15 lines
No EOL
524 B
C++
15 lines
No EOL
524 B
C++
#pragma once
|
|
#include <string>
|
|
#include <cstdint>
|
|
|
|
// Abstract Reader class: read bytes/strings from a source (file, string, etc.)
|
|
class Reader {
|
|
public:
|
|
virtual ~Reader() = default;
|
|
// return 0..255 on success, -1 on EOF/error
|
|
virtual int readByte() = 0;
|
|
// read exactly len bytes into buf; return true on success
|
|
virtual bool readBytes(uint8_t* buf, size_t len) = 0;
|
|
// read up to len bytes into a std::string; may return shorter string on EOF
|
|
virtual std::string readString(size_t len) = 0;
|
|
}; |