GMemoryOutputStream

GMemoryOutputStream — Streaming output operations on memory chunks

Synopsis


#include <gio.h>


                    GMemoryOutputStream;
GOutputStream*      g_memory_output_stream_new          (GByteArray *data);
void                g_memory_output_stream_set_max_size (GMemoryOutputStream *ostream,
                                                         guint max_size);
GByteArray*         g_memory_output_stream_get_data     (GMemoryOutputStream *ostream);
void                g_memory_output_stream_set_free_data
                                                        (GMemoryOutputStream *ostream,
                                                         gboolean free_data);


Object Hierarchy


  GObject
   +----GOutputStream
         +----GMemoryOutputStream

Implemented Interfaces

GMemoryOutputStream implements GSeekable.

Properties


  "data"                     gpointer              : Read / Write / Construct
  "free-array"               gboolean              : Read / Write
  "size-limit"               guint                 : Read / Write

Description

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

Details

GMemoryOutputStream

typedef struct _GMemoryOutputStream GMemoryOutputStream;

Implements GOutputStream for arbitrary memory chunks.


g_memory_output_stream_new ()

GOutputStream*      g_memory_output_stream_new          (GByteArray *data);

Creates a new GMemoryOutputStream. If data is non-NULL it will use that for its internal storage otherwise it will create a new GByteArray. In both cases the internal GByteArray can later be accessed through the "data" property, or with g_memory_output_stream_get_data().

Note: The new stream will not take ownership of the supplied data so you have to free it yourself after use or explicitly ask for it be freed on close by setting the "free-array" property to TRUE.

data :

a GByteArray.

Returns :

A newly created GMemoryOutputStream object.

g_memory_output_stream_set_max_size ()

void                g_memory_output_stream_set_max_size (GMemoryOutputStream *ostream,
                                                         guint max_size);

Sets a size limit on the data contained within the output stream.

ostream :

a GMemoryOutputStream.

max_size :

a guint to set as the maximum stream size.

g_memory_output_stream_get_data ()

GByteArray*         g_memory_output_stream_get_data     (GMemoryOutputStream *ostream);

Gets any loaded data from the ostream.

ostream :

a GMemoryOutputStream

Returns :

GByteArray of the stream's data.

g_memory_output_stream_set_free_data ()

void                g_memory_output_stream_set_free_data
                                                        (GMemoryOutputStream *ostream,
                                                         gboolean free_data);

Sets if the data within the stream should be freed when the stream is freed.

ostream :

a GMemoryOutputStream.

free_data :

a gboolean. If TRUE, frees the data within stream.

Property Details

The "data" property

  "data"                     gpointer              : Read / Write / Construct

The byte array used as internal storage.


The "free-array" property

  "free-array"               gboolean              : Read / Write

Wether or not the interal array should be free on close.

Default value: FALSE


The "size-limit" property

  "size-limit"               guint                 : Read / Write

Maximum amount of bytes that can be written to the stream.

Default value: 0

See Also

GMemoryInputStream