Add 'ostream' method to class StreamBuffer, and use it.
This commit is contained in:
@@ -239,7 +239,7 @@ public:
|
||||
};
|
||||
|
||||
class StreamBuffer {
|
||||
public:
|
||||
public:
|
||||
// Construct an empty buffer.
|
||||
StreamBuffer();
|
||||
|
||||
@@ -387,6 +387,9 @@ public:
|
||||
static const char *lua_reader(lua_State *L, void *data, size_t *size);
|
||||
void *lua_reader_ud(int64_t bytes);
|
||||
|
||||
// Get an ostream that writes into the StreamBuffer.
|
||||
std::ostream &ostream();
|
||||
|
||||
private:
|
||||
// Start and end of the allocated block.
|
||||
char *buf_lo_;
|
||||
@@ -409,6 +412,9 @@ private:
|
||||
const char *lua_reader_data_;
|
||||
int64_t lua_reader_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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user