GBufferedInputStream

GBufferedInputStream

Synopsis




                    GBufferedInputStream;
GInputStream*       g_buffered_input_stream_new         (GInputStream *base_stream);
GInputStream*       g_buffered_input_stream_new_sized   (GInputStream *base_stream,
                                                         gsize size);
gsize               g_buffered_input_stream_get_buffer_size
                                                        (GBufferedInputStream *stream);
void                g_buffered_input_stream_set_buffer_size
                                                        (GBufferedInputStream *stream,
                                                         gsize size);
gsize               g_buffered_input_stream_get_available
                                                        (GBufferedInputStream *stream);
gsize               g_buffered_input_stream_peek        (GBufferedInputStream *stream,
                                                         void *buffer,
                                                         gsize offset,
                                                         gsize count);
gssize              g_buffered_input_stream_fill        (GBufferedInputStream *stream,
                                                         gssize count,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_buffered_input_stream_fill_async  (GBufferedInputStream *stream,
                                                         gssize count,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gssize              g_buffered_input_stream_fill_finish (GBufferedInputStream *stream,
                                                         GAsyncResult *result,
                                                         GError **error);


Object Hierarchy


  GObject
   +----GInputStream
         +----GFilterInputStream
               +----GBufferedInputStream
                     +----GDataInputStream

Properties


  "buffer-size"              guint                 : Read / Write / Construct

Description

Details

GBufferedInputStream

typedef struct _GBufferedInputStream GBufferedInputStream;


g_buffered_input_stream_new ()

GInputStream*       g_buffered_input_stream_new         (GInputStream *base_stream);

Creates a new GInputStream from the given base_stream, with a buffer set to the default size (4 kilobytes).

base_stream :

a GInputStream.

Returns :

a GInputStream for the given base_stream.

g_buffered_input_stream_new_sized ()

GInputStream*       g_buffered_input_stream_new_sized   (GInputStream *base_stream,
                                                         gsize size);

Creates a new GBufferedInputStream from the given base_stream, with a buffer set to size.

base_stream :

a GOutputStream.

size :

a gsize.

Returns :

a GInputStream.

g_buffered_input_stream_get_buffer_size ()

gsize               g_buffered_input_stream_get_buffer_size
                                                        (GBufferedInputStream *stream);

stream :

GBufferedInputStream.

Returns :

the current buffer size, or -1 on error.

g_buffered_input_stream_set_buffer_size ()

void                g_buffered_input_stream_set_buffer_size
                                                        (GBufferedInputStream *stream,
                                                         gsize size);

Sets the size of the internal buffer of stream to size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.

stream :

GBufferedInputStream.

size :

a gsize.

g_buffered_input_stream_get_available ()

gsize               g_buffered_input_stream_get_available
                                                        (GBufferedInputStream *stream);

stream :

GBufferedInputStream.

Returns :

size of the available stream.

g_buffered_input_stream_peek ()

gsize               g_buffered_input_stream_peek        (GBufferedInputStream *stream,
                                                         void *buffer,
                                                         gsize offset,
                                                         gsize count);

stream :

a GBufferedInputStream.

buffer :

a pointer to an allocated chunk of memory.

offset :

a gsize.

count :

a gsize.

Returns :


g_buffered_input_stream_fill ()

gssize              g_buffered_input_stream_fill        (GBufferedInputStream *stream,
                                                         gssize count,
                                                         GCancellable *cancellable,
                                                         GError **error);

Tries to read count bytes from the stream into the buffer. Will block during this read.

If count is zero, returns zero and does nothing. A value of count larger than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error.

On success, the number of bytes read into the buffer is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. near the end of a file. Zero is returned on end of file (or if count is zero), but never otherwise.

If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an operation was partially finished when the operation was cancelled the partial result will be returned, without an error.

On error -1 is returned and error is set accordingly.

For the asynchronous, non-blocking, version of this function, see g_buffered_input_stream_fill_async().

stream :

GBufferedInputStream.

count :

the number of bytes that will be read from the stream.

cancellable :

optional GCancellable object, NULL to ignore.

error :

location to store the error occuring, or NULL to ignore.

Returns :

the number of bytes read into stream's buffer, up to count, or -1 on error.

g_buffered_input_stream_fill_async ()

void                g_buffered_input_stream_fill_async  (GBufferedInputStream *stream,
                                                         gssize count,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Reads data into stream's buffer asynchronously, up to count size. io_priority can be used to prioritize reads. For the synchronous version of this function, see g_buffered_input_stream_fill().

stream :

GBufferedInputStream.

count :

a gssize.

io_priority :

the io priority of the request. the io priority of the request.

cancellable :

optional GCancellable object

callback :

a GAsyncReadyCallback.

user_data :

a gpointer.

g_buffered_input_stream_fill_finish ()

gssize              g_buffered_input_stream_fill_finish (GBufferedInputStream *stream,
                                                         GAsyncResult *result,
                                                         GError **error);

stream :

result :

error :

Returns :

Property Details

The "buffer-size" property

  "buffer-size"              guint                 : Read / Write / Construct

The size of the backend buffer.

Allowed values: >= 1

Default value: 4096