BufferedInputStream

Buffered input stream implements GFilterInputStream and provides for buffered reads.

By default, GBufferedInputStream's buffer size is set at 4 kilobytes.

To create a buffered input stream, use g_buffered_input_stream_new(), or g_buffered_input_stream_new_sized() to specify the buffer's size at construction.

To get the size of a buffer within a buffered input stream, use g_buffered_input_stream_get_buffer_size(). To change the size of a buffered input stream's buffer, use g_buffered_input_stream_set_buffer_size(). Note that the buffer's size cannot be reduced below the size of the data within the buffer.

Constructors

this
this(GBufferedInputStream* gBufferedInputStream)

Sets our main struct and passes it to the parent class

this
this(InputStream baseStream)

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

this
this(InputStream baseStream, gsize size)

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

Members

Functions

fill
gssize fill(gssize count, Cancellable cancellable)

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 count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer. 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().

fillAsync
void fillAsync(gssize count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

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(). If count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer.

fillFinish
gssize fillFinish(AsyncResultIF result)

Finishes an asynchronous read.

getAvailable
gsize getAvailable()

Gets the size of the available data within the stream.

getBufferSize
gsize getBufferSize()

Gets the size of the input buffer.

getBufferedInputStreamStruct
GBufferedInputStream* getBufferedInputStreamStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

peek
gsize peek(void* buffer, gsize offset, gsize count)

Peeks in the buffer, copying data of size count into buffer, offset offset bytes.

peekBuffer
void* peekBuffer(gsize count)

Returns the buffer with the currently available bytes. The returned buffer must not be modified and will become invalid when reading from the stream or filling the buffer.

readByte
int readByte(Cancellable cancellable)

Tries to read a single byte from the stream or the buffer. Will block during this read. On success, the byte read from the stream is returned. On end of stream -1 is returned but it's not an exceptional error and error is not set. 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.

setBufferSize
void setBufferSize(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.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

gBufferedInputStream
GBufferedInputStream* gBufferedInputStream;

the main Gtk struct

Inherited Members

From FilterInputStream

gFilterInputStream
GFilterInputStream* gFilterInputStream;

the main Gtk struct

getFilterInputStreamStruct
GFilterInputStream* getFilterInputStreamStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
getBaseStream
InputStream getBaseStream()

Gets the base stream for the filter stream.

getCloseBaseStream
int getCloseBaseStream()

Returns whether the base stream will be closed when stream is closed.

setCloseBaseStream
void setCloseBaseStream(int closeBase)

Sets whether the base stream will be closed when stream is closed.

Meta