Remove ostream from class StreamBuffer

This commit is contained in:
2023-10-18 14:22:35 -04:00
parent 67b0265092
commit 3e8aa31a95
5 changed files with 46 additions and 59 deletions

View File

@@ -385,13 +385,13 @@ public:
// Calculate a noncryptographic but good hash of what's in the buffer.
util::HashValue hash() const;
// Get an ostream that writes into the StreamBuffer.
std::ostream &ostream();
// Throw a StreamCorruption exception.
void raise_truncated() { throw StreamCorruption(); }
void raise_string_too_long() { throw StreamCorruption(); }
// This is for unit testing.
bool layout_is(int64_t a, int64_t b, int64_t c);
private:
// Start and end of the allocated block.
char *buf_lo_;
@@ -410,21 +410,14 @@ private:
// True if we're not allowed to expand this buffer.
bool fixed_size_;
// The ostream. Only allocated on demand.
std::unique_ptr<std::ostream> ostream_;
// Initialize with a new buffer.
void init(bool fixed, bool owned, char *buf, int64_t size);
// Function that resizes the buffer during make_space operations.
void make_space_slow(int64_t bytes);
// Implementation for the overwrite_int functions.
char *get_overwrite(int64_t size, int64_t write_count_after);
// This is for unit testing.
bool layout_is(int64_t a, int64_t b, int64_t c);
friend int lfn_unittests_streambuffer(lua_State *L);
};
// Use a streambuffer as a lua_writer.