Get Involved

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 ChunkListNodes. 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

  MemOutStream::MemOutStream(u32 chunkSizeExp = DefaultChunkSizeExp) [code]

Constructs a new MemOutStream object.

 ChunkCursor MemOutStream::getHeadCursor() [code]

Returns a ChunkCursor to the start of the internal list of ChunkListNodes. It's safe to call this function even before data is written to the MemOutStream.

 String MemOutStream::moveToString() [code]

Returns a String containing all the data that was written. The MemOutStream 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 the ChunkListNode is resized and the returned String takes ownership of it directly.

Members Inherited From ply::OutStream