Gio.MemoryOutputStream¶
class — extends OutputStream, 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¶
new_resizable¶
Creates a new MemoryOutputStream, using GLib.realloc and GLib.free
for memory allocation.
Methods¶
get_data¶
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¶
Returns the number of bytes from the start up to including the last byte written in the stream that has not been truncated away.
get_size¶
Gets the size of the currently allocated data area (available from
MemoryOutputStream.get_data).
You probably don't want to use this function on resizable streams.
See MemoryOutputStream.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
g_memory_output_stream_new()) then this is the maximum size of the
stream and further writes will return IOErrorEnum.NO_SPACE.
In any case, if you want the number of bytes currently written to the
stream, use MemoryOutputStream.get_data_size.
steal_as_bytes¶
Returns data from the ostream as a GLib.Bytes. ostream must be
closed before calling this function.
steal_data¶
Gets any loaded data from the ostream. Ownership of the data
is transferred to the caller; when no longer needed it must be
freed using the free function set in ostream's
MemoryOutputStream:destroy-function property.
ostream must be closed before calling this function.
Properties¶
data¶
Pointer to buffer where data will be written.
data_size¶
Size of data written to the buffer.
size¶
Current size of the data buffer.