Serialization for idalloc and animqueue
This commit is contained in:
@@ -308,18 +308,22 @@ public:
|
||||
char *alloc_space(int64_t bytes);
|
||||
void wrote_space(int64_t bytes);
|
||||
|
||||
// Write values into the buffer.
|
||||
// Write numbers into the buffer.
|
||||
void write_int8(int8_t v);
|
||||
void write_int16(int16_t v);
|
||||
void write_int32(int32_t v);
|
||||
void write_int64(int64_t v);
|
||||
void write_float(float f);
|
||||
void write_double(double d);
|
||||
void write_uint8(uint8_t v) { write_int8(v); }
|
||||
void write_uint16(uint16_t v) { write_int16(v); }
|
||||
void write_uint32(uint32_t v) { write_int32(v); }
|
||||
void write_uint64(uint64_t v) { write_int64(v); }
|
||||
|
||||
void write_bytes(const char *bytes, int64_t len);
|
||||
void write_size(size_t sz) { write_int64(sz); }
|
||||
|
||||
// Write strings or blocks of bytes into the buffer.
|
||||
void write_string(const std::string &s);
|
||||
void write_bytes(const char *bytes, int64_t len);
|
||||
void write_ztbytes(const char *bytes);
|
||||
|
||||
// Overwrite values previously written to the buffer.
|
||||
@@ -332,19 +336,26 @@ public:
|
||||
void overwrite_uint32(int64_t write_count_after, uint32_t v) { overwrite_int32(write_count_after, v); }
|
||||
void overwrite_uint64(int64_t write_count_after, uint64_t v) { overwrite_int64(write_count_after, v); }
|
||||
|
||||
// Read integers from the buffer. May throw StreamEof.
|
||||
// Read numbers from the buffer. May throw StreamEof.
|
||||
int8_t read_int8();
|
||||
int16_t read_int16();
|
||||
int32_t read_int32();
|
||||
int64_t read_int64();
|
||||
float read_float();
|
||||
double read_double();
|
||||
uint8_t read_uint8() { return read_int8(); }
|
||||
uint16_t read_uint16() { return read_int16(); }
|
||||
uint32_t read_uint32() { return read_int32(); }
|
||||
uint64_t read_uint64() { return read_int64(); }
|
||||
|
||||
// Read a string of no more than the specified length. May throw StreamEof
|
||||
// or StreamCorruption.
|
||||
std::string read_string(int64_t max_allowed);
|
||||
// May throw StreamEof or StreamCorruption.
|
||||
size_t read_size();
|
||||
size_t read_size_limit(size_t limit);
|
||||
|
||||
// Read a string of no more than the specified length.
|
||||
// May throw StreamEof or StreamCorruption.
|
||||
std::string read_string();
|
||||
std::string read_string_limit(int64_t max_allowed);
|
||||
|
||||
// Read a block of bytes. May throw StreamEof.
|
||||
const char *read_bytes(int64_t bytes);
|
||||
|
||||
Reference in New Issue
Block a user