Yet more refactors in basebuffer.
This commit is contained in:
@@ -226,14 +226,21 @@ enum DrvAction {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class PlayLogfile : public BaseWriteMethods<PlayLogfile>, public std::ofstream {
|
||||
class PlayLogfile : public std::ofstream {
|
||||
using std::ofstream::ofstream;
|
||||
using DS = DataSerializer<PlayLogfile>;
|
||||
public:
|
||||
void write_bytes(const char *n, size_t size) { write(n, size); }
|
||||
void raise_integer_truncated() {
|
||||
fprintf(stderr, "number exceeds allowable size\n");
|
||||
std::abort();
|
||||
}
|
||||
void write_uint8(uint64_t data) { DS(this).write_uint8(data); }
|
||||
void write_uint32(uint64_t data) { DS(this).write_uint32(data); }
|
||||
void write_uint64(uint64_t data) { DS(this).write_uint64(data); }
|
||||
void write_int64(int64_t data) { DS(this).write_int64(data); }
|
||||
void write_double(double data) { DS(this).write_double(data); }
|
||||
void write_string(std::string_view s){ DS(this).write_string(s); }
|
||||
void write_short_string(std::string_view v) {
|
||||
assert(v.size() < DRV_SHORTSTRING_SIZE);
|
||||
write_string(v);
|
||||
@@ -244,10 +251,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class ReplayLogfile : public BaseReadMethods<ReplayLogfile>, public std::ifstream {
|
||||
class ReplayLogfile : public std::ifstream {
|
||||
using std::ifstream::ifstream;
|
||||
using DD = DataDeserializer<ReplayLogfile>;
|
||||
public:
|
||||
using read_string_type = std::string;
|
||||
void read_bytes_into(char *n, size_t size) {
|
||||
read(n, size);
|
||||
if (!good()) {
|
||||
@@ -258,6 +265,13 @@ public:
|
||||
fprintf(stderr, "string in logfile is too long");
|
||||
std::abort();
|
||||
}
|
||||
uint8_t read_uint8() { return DD(this).read_uint8(); }
|
||||
uint32_t read_uint32() { return DD(this).read_uint32(); }
|
||||
uint64_t read_uint64() { return DD(this).read_uint64(); }
|
||||
int64_t read_int64() { return DD(this).read_int64(); }
|
||||
double read_double() { return DD(this).read_double(); }
|
||||
size_t read_length() { return DD(this).read_length(); }
|
||||
std::string read_string() { return DD(this).read_string(); }
|
||||
std::string_view read_short_string(EngineWrapper *w) {
|
||||
size_t size = read_length();
|
||||
assert(size <= DRV_SHORTSTRING_SIZE);
|
||||
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
using LuaValue = BaseLuaValue<eng::string>;
|
||||
|
||||
class StreamBufferConfig {
|
||||
protected:
|
||||
public:
|
||||
using string_type = eng::string;
|
||||
void *basebuffer_malloc(size_t size) { return eng::malloc(size); }
|
||||
void basebuffer_free(void *p) { eng::free(p); }
|
||||
|
||||
Reference in New Issue
Block a user