Small overhaul using string_view

This commit is contained in:
2022-03-04 16:45:47 -05:00
parent b17b34924e
commit cfeeb2eaf3
6 changed files with 60 additions and 39 deletions

View File

@@ -269,6 +269,9 @@ public:
// Get a pointer to the data.
const char *data() const;
// Get entire contents as a string_view
std::string_view view() const;
// Discard all data. Reset total read and write counts.
// Frees up as much space as possible.
void clear();
@@ -284,7 +287,7 @@ public:
// It just writes the bytes.
//
void write_bytes(const char *bytes, int64_t len);
void write_bytes(const eng::string &bytes);
void write_bytes(std::string_view bytes);
// Read a block of bytes from the buffer.
//
@@ -333,7 +336,7 @@ public:
//
void write_bool(bool b) { write_int8(b ? 1 : 0); }
void write_hashvalue(const util::HashValue &hv);
void write_string(const eng::string &s);
void write_string(std::string_view s);
// Read other types from the buffer.
//