MemOutStream
A MemOutStream
object is an OutStream
that writes to a memory.
The amount of data that can be written to MemOutStream
is unbounded. Internally, the data is
stored in a list of ChunkListNode
s. As each ChunkListNode
fills up, a new one is allocated and
added to the end of the list.
Once you've finished writing data to a MemOutStream
, you can convert it to a single contiguous
memory block by calling moveToString()
.
Header File
#include <ply-runtime/io/OutStream.h>
Also included from <ply-runtime/Base.h>
.
Member Functions
-
Constructs a new
MemOutStream
object. -
Returns a
ChunkCursor
to the start of the internal list ofChunkListNode
s. It's safe to call this function even before data is written to theMemOutStream
. -
Returns a
String
containing all the data that was written. TheMemOutStream
is reset to a null stream as result of this call, which means that no further data can be written.If all the data written fits in a single
ChunkListNode
(default fewer than 4096 bytes), no new memory is allocated and no data is copied as a result of this call; instead, the memory allocation containing theChunkListNode
is resized and the returnedString
takes ownership of it directly.
Members Inherited From ply::OutStream
char* OutStream::curByte
char* OutStream::endByte
OutStream::OutStream(OutStream&& other)
OutStream::OutStream(OptionallyOwned<OutPipe>&& outPipe, u32 chunkSizeExp = DefaultChunkSizeExp)
OutStream::~OutStream()
void OutStream::operator=(OutStream&& other)
bool OutStream::atEOF() const
u32 OutStream::numBytesAvailable() const
MutableStringView OutStream::viewAvailable()
bool OutStream::anyBytesAvailable() const
u64 OutStream::getSeekPos() const
bool OutStream::flush(bool toDevice = true)
void OutStream::flushMem()
u32 OutStream::tryMakeBytesAvailable(u32 numBytes = 1)
void OutStream::makeBytesAvailable(u32 numBytes = 1)
bool OutStream::writeByte(u8 byte)
bool OutStream::write(StringView src)
template <typename Args>
void OutStream::format(StringView fmt, const Args& args)
template <typename T>
OutStream& OutStream::operator<<(const T& value)