MemoryOutputStream#

class MemoryOutputStream(**properties: Any)#

Superclasses: OutputStream, Object

Implemented Interfaces: PollableOutputStream, Seekable

GMemoryOutputStream is a class for using arbitrary memory chunks as output for GIO streaming output operations.

As of GLib 2.34, GMemoryOutputStream trivially implements PollableOutputStream: it always polls as ready.

Constructors#

class MemoryOutputStream
classmethod new_resizable() OutputStream#

Creates a new MemoryOutputStream, using realloc() and free() for memory allocation.

Added in version 2.36.

Methods#

class MemoryOutputStream
get_data() Any | None#

Gets any loaded data from the ostream.

Note that the returned pointer may become invalid on the next write or truncate operation on the stream.

get_data_size() int#

Returns the number of bytes from the start up to including the last byte written in the stream that has not been truncated away.

Added in version 2.18.

get_size() int#

Gets the size of the currently allocated data area (available from get_data()).

You probably don’t want to use this function on resizable streams. See get_data_size() instead. For resizable streams the size returned by this function is an implementation detail and may be change at any time in response to operations on the stream.

If the stream is fixed-sized (ie: no realloc was passed to new()) then this is the maximum size of the stream and further writes will return NO_SPACE.

In any case, if you want the number of bytes currently written to the stream, use get_data_size().

Properties#

class MemoryOutputStream
props.data: Any#

The type of the None singleton.

Added in version 2.24.

props.data_size: int#

The type of the None singleton.

Added in version 2.24.

props.size: int#

The type of the None singleton.

Added in version 2.24.

Fields#

class MemoryOutputStream
parent_instance#
priv#