C++ Portable Types Library (PTypes) Version 1.7

Top: Streams: outmemory

#include <pstreams.h>

outmemory::outmemory(int limit = -1, int increment = 1024);
const char* outmemory::get_data();
string outmemory::get_strdata();

Use outmemory to write data to a dynamic memory buffer by means of the streaming interface. Outmemory is derived from outstm.

outmemory::outmemory(int limit = -1, int increment = 1024) creates an outmemory object. The memory buffer grows as data is written to the stream. You can optionally assign the reallocation delta for the memory buffer through increment and also limit its size to limit (-1 means unlimited).

const char* outmemory::get_data() returns a pointer to the memory buffer. Note that this buffer is NOT null-terminated unless you explicitly write a null character to the stream at the end. Use iobase::tell() to determine the actual data size, i.e. bytes written to an outmemory object.

string outmemory::get_strdata() returns data written to the stream as a dynamic string and closes the stream. Unlike get_data(), this function returns the exact number of bytes written to the stream.

See also: iobase, outstm

PTypes home