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 moveToBuffer().

Header File

#include <ply-runtime/io/OutStream.h>

Also included from <ply-runtime/Base.h>.

Member Functions

MemOutStream(u32 chunkSizeExp = DefaultChunkSizeExp) [code]

Constructs a new MemOutStream object.

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

Buffer moveToBuffer() [code]

Returns a Buffer 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 Buffer takes ownership of it directly.

Members Inherited From ply::OutStream

  • u8* curByte
  • u8* endByte
  • OutStream(OutStream&& other)
  • OutStream(OptionallyOwned<OutPipe>&& outPipe, u32 chunkSizeExp = DefaultChunkSizeExp)
  • ~OutStream()
  • void operator=(OutStream&& other)
  • bool atEOF() const
  • u32 numBytesAvailable() const
  • BufferView viewAvailable()
  • bool anyBytesAvailable() const
  • u64 getSeekPos() const
  • bool flush(bool toDevice = true)
  • void flushMem()
  • u32 tryMakeBytesAvailable(u32 numBytes = 1)
  • void makeBytesAvailable(u32 numBytes = 1)
  • bool writeByte(u8 byte)
  • bool write(ConstBufferView src)
  • StringWriter* strWriter()