Gio.MemoryOutputStream

g GObject.GInterface GObject.GInterface Gio.PollableOutputStream Gio.PollableOutputStream GObject.GInterface->Gio.PollableOutputStream Gio.Seekable Gio.Seekable GObject.GInterface->Gio.Seekable GObject.Object GObject.Object Gio.OutputStream Gio.OutputStream GObject.Object->Gio.OutputStream Gio.MemoryOutputStream Gio.MemoryOutputStream Gio.OutputStream->Gio.MemoryOutputStream Gio.PollableOutputStream->Gio.MemoryOutputStream Gio.Seekable->Gio.MemoryOutputStream

Subclasses:

None

Methods

Inherited:

Gio.OutputStream (29), GObject.Object (37), Gio.PollableOutputStream (5), Gio.Seekable (5)

Structs:

GObject.ObjectClass (5)

class

new_resizable ()

get_data ()

get_data_size ()

get_size ()

steal_as_bytes ()

steal_data ()

Virtual Methods

Inherited:

Gio.OutputStream (15), GObject.Object (7), Gio.PollableOutputStream (5), Gio.Seekable (5)

Properties

Name

Type

Flags

Short Description

data

int

r/w/co

data-size

int

r

size

int

r/w/co

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gio.OutputStream

r

Class Details

class Gio.MemoryOutputStream(**kwargs)
Bases:

Gio.OutputStream, Gio.PollableOutputStream, Gio.Seekable

Abstract:

No

Structure:

Gio.MemoryOutputStreamClass

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

As of GLib 2.34, GMemoryOutputStream trivially implements [iface`Gio`.PollableOutputStream]: it always polls as ready.

classmethod new_resizable()[source]
Return type:

Gio.OutputStream

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

New in version 2.36.

get_data()[source]
Returns:

pointer to the stream’s data, or None if the data has been stolen

Return type:

object or None

Gets any loaded data from the self.

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

get_data_size()[source]
Returns:

the number of bytes written to the stream

Return type:

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.

New in version 2.18.

get_size()[source]
Returns:

the number of bytes allocated for the data buffer

Return type:

int

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

You probably don’t want to use this function on resizable streams. See Gio.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 Gio.IOErrorEnum.NO_SPACE.

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

steal_as_bytes()[source]
Returns:

the stream’s data

Return type:

GLib.Bytes

Returns data from the self as a GLib.Bytes. self must be closed before calling this function.

New in version 2.34.

steal_data()[source]
Returns:

the stream’s data, or None if it has previously been stolen

Return type:

object or None

Gets any loaded data from the self. Ownership of the data is transferred to the caller; when no longer needed it must be freed using the free function set in self's Gio.MemoryOutputStream :destroy-function property.

self must be closed before calling this function.

New in version 2.26.

Property Details

Gio.MemoryOutputStream.props.data
Name:

data

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Pointer to buffer where data will be written.

New in version 2.24.

Gio.MemoryOutputStream.props.data_size
Name:

data-size

Type:

int

Default Value:

0

Flags:

READABLE

Size of data written to the buffer.

New in version 2.24.

Gio.MemoryOutputStream.props.size
Name:

size

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Current size of the data buffer.

New in version 2.24.