1.51 <GMemoryOutputStream>

Class: <GMemoryOutputStream>

It derives from <GOutputStream>.

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

As of GLib 2.34, <GMemoryOutputStream> trivially implements <GPollableOutputStream>: it always polls as ready.

Fields

parent-instance

Properties

Property: memory-output-stream:data self

Pointer to buffer where data will be written.

Its value is a foreign pointer (or, to set it, a bytevector).

It can only be set when the object is made, with #:data.

Property: memory-output-stream:data-size self

Size of data written to the buffer.

Its value is an unsigned 64-bit integer.

It is read only.

Property: memory-output-stream:size self

Current size of the data buffer.

Its value is an unsigned 64-bit integer.

It can only be set when the object is made, with #:size.

Procedures

Method: memory-output-stream:get-data self ⇒ %return
Method: get-data self ⇒ %return

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.

self

Passed: a <GMemoryOutputStream>.

a <GMemoryOutputStream>

%return

Returned: a foreign pointer, or #f.

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

Method: memory-output-stream:get-data-size self ⇒ %return
Method: get-data-size self ⇒ %return

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

self

Passed: a <GMemoryOutputStream>.

a <GMemoryOutputStream>

%return

Returned: an unsigned 64-bit integer.

the number of bytes written to the stream

Method: memory-output-stream:get-size self ⇒ %return
Method: get-size self ⇒ %return

Gets the size of the currently allocated data area (available from memory-output-stream:get-data).

You probably don’t want to use this function on resizable streams. See memory-output-stream: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 no-space.

In any case, if you want the number of bytes currently written to the stream, use memory-output-stream:get-data-size.

self

Passed: a <GMemoryOutputStream>.

a <GMemoryOutputStream>

%return

Returned: an unsigned 64-bit integer.

the number of bytes allocated for the data buffer

Procedure: memory-output-stream:new-resizable ⇒ %return

Creates a new <GMemoryOutputStream>, using realloc and byte-array:free for memory allocation.

%return

Returned: a <GOutputStream>.

Method: memory-output-stream:steal-as-bytes self ⇒ %return
Method: steal-as-bytes self ⇒ %return

Returns data from the self as a <GBytes>. self must be closed before calling this function.

self

Passed: a <GMemoryOutputStream>.

a <GMemoryOutputStream>

%return

Returned: a <GBytes>.

the stream’s data

Method: memory-output-stream:steal-data self ⇒ %return
Method: steal-data self ⇒ %return

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 destroy-function property.

self must be closed before calling this function.

self

Passed: a <GMemoryOutputStream>.

a <GMemoryOutputStream>

%return

Returned: a foreign pointer, or #f.

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