Some changes to the design of base-writer.hpp
This commit is contained in:
@@ -235,8 +235,12 @@ class ReplayLogfile : public BaseReader<ReplayLogfile>, public std::ifstream {
|
||||
using std::ifstream::ifstream;
|
||||
public:
|
||||
using read_string_type = std::string;
|
||||
void read_bytes_into(char *n, size_t size) { read(n, size); }
|
||||
bool read_beyond_eof() { return !good(); }
|
||||
void read_bytes_into(char *n, size_t size) {
|
||||
read(n, size);
|
||||
if (!good()) {
|
||||
memset(n, 0, size);
|
||||
}
|
||||
}
|
||||
void raise_string_too_long() {
|
||||
fprintf(stderr, "string in logfile is too long");
|
||||
std::abort();
|
||||
|
||||
@@ -302,6 +302,8 @@ public:
|
||||
|
||||
// Copy bytes from the StreamBuffer into an external buffer.
|
||||
//
|
||||
// Returns true if the bytes were successfully read.
|
||||
//
|
||||
void read_bytes_into(char *target, int64_t len);
|
||||
|
||||
// Read a string as a string_view.
|
||||
@@ -387,10 +389,6 @@ public:
|
||||
void raise_truncated() { throw StreamCorruption(); }
|
||||
void raise_string_too_long() { throw StreamCorruption(); }
|
||||
|
||||
// This is always false, because this module throws exceptions
|
||||
// when reading beyond EOF.
|
||||
bool read_beyond_eof() { return false; }
|
||||
|
||||
private:
|
||||
// Start and end of the allocated block.
|
||||
char *buf_lo_;
|
||||
|
||||
Reference in New Issue
Block a user