Gio.BufferedInputStream - Classes - Gio 2.0 (original) (raw)
g GObject.GInterface GObject.GInterface Gio.Seekable Gio.Seekable GObject.GInterface->Gio.Seekable GObject.Object GObject.Object Gio.InputStream Gio.InputStream GObject.Object->Gio.InputStream Gio.BufferedInputStream Gio.BufferedInputStream Gio.FilterInputStream Gio.FilterInputStream Gio.FilterInputStream->Gio.BufferedInputStream Gio.InputStream->Gio.FilterInputStream Gio.Seekable->Gio.BufferedInputStream
Subclasses:
Methods¶
Inherited:
Gio.FilterInputStream (3), Gio.InputStream (19), GObject.Object (37), Gio.Seekable (5)
Structs:
class | new (base_stream) |
---|---|
class | new_sized (base_stream, size) |
fill (count, cancellable) | |
fill_async (count, io_priority, cancellable, callback, *user_data) | |
fill_finish (result) | |
get_available () | |
get_buffer_size () | |
peek (buffer, offset) | |
peek_buffer () | |
read_byte (cancellable) | |
set_buffer_size (size) |
Virtual Methods¶
Inherited:
Gio.InputStream (9), GObject.Object (7), Gio.Seekable (5)
do_fill (count, cancellable) |
---|
do_fill_async (count, io_priority, cancellable, callback, *user_data) |
do_fill_finish (result) |
Properties¶
Inherited:
Name | Type | Flags | Short Description |
---|---|---|---|
buffer-size | int | r/w/c |
Signals¶
Inherited:
Fields¶
Inherited:
Name | Type | Access | Description |
---|---|---|---|
parent_instance | Gio.FilterInputStream | r |
Class Details¶
class Gio.BufferedInputStream(**kwargs)¶
Bases:
Gio.FilterInputStream, Gio.Seekable
Abstract:
No
Structure:
Buffered input stream implements [class`Gio`.FilterInputStream] and provides for buffered reads.
By default, GBufferedInputStream
’s buffer size is set at 4 kilobytes.
To create a buffered input stream, use [ctor`Gio`.BufferedInputStream.new], or [ctor`Gio`.BufferedInputStream.new_sized] to specify the buffer’s size at construction.
To get the size of a buffer within a buffered input stream, use [method`Gio`.BufferedInputStream.get_buffer_size]. To change the size of a buffered input stream’s buffer, use [method`Gio`.BufferedInputStream.set_buffer_size]. Note that the buffer’s size cannot be reduced below the size of the data within the buffer.
classmethod new(base_stream)[source]¶
Parameters:
base_stream (Gio.InputStream) – a [class`Gio`.InputStream]
Returns:
a [class`Gio`.InputStream] for the given base_stream.
Return type:
Creates a new [class`Gio`.InputStream] from the given base_stream, with a buffer set to the default size (4 kilobytes).
classmethod new_sized(base_stream, size)[source]¶
Parameters:
- base_stream (Gio.InputStream) – a [class`Gio`.InputStream]
- size (int) – a #gsize
Returns:
a [class`Gio`.InputStream].
Return type:
Creates a new [class`Gio`.BufferedInputStream] from the given base_stream, with a buffer set to size.
fill(count, cancellable)[source]¶
Parameters:
- count (int) – the number of bytes that will be read from the stream
- cancellable (Gio.Cancellable or None) – optional [class`Gio`.Cancellable] object,
NULL
to ignore
Raises:
Returns:
the number of bytes read into self's buffer, up to count, or -1
on error.
Return type:
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 countlarger than G_MAXSSIZE
will cause a [error`Gio`.IOErrorEnum.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 [error`Gio`.IOErrorEnum.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 [method`Gio`.BufferedInputStream.fill_async].
fill_async(count, io_priority, cancellable, callback, *user_data)[source]¶
Parameters:
- count (int) – the number of bytes that will be read from the stream
- io_priority (int) – the I/O priority of the request
- cancellable (Gio.Cancellable or None) – optional [class`Gio`.Cancellable] object
- callback (Gio.AsyncReadyCallback or None) – a [callback`Gio`.AsyncReadyCallback]
- user_data (object or None) – a object
Reads data into self's buffer asynchronously, up to count size.io_priority can be used to prioritize reads. For the synchronous version of this function, see [method`Gio`.BufferedInputStream.fill].
If count is -1
then the attempted read size is equal to the number of bytes that are required to fill the buffer.
Parameters:
result (Gio.AsyncResult) – a [iface`Gio`.AsyncResult]
Raises:
Returns:
a #gssize of the read stream, or -1
on an error.
Return type:
Finishes an asynchronous read.
Returns:
size of the available stream.
Return type:
Gets the size of the available data within the stream.
Returns:
the current buffer size.
Return type:
Gets the size of the input buffer.
Parameters:
Returns:
a #gsize of the number of bytes peeked, or -1
on error.
Return type:
Peeks in the buffer, copying data of size count into buffer, offset offset bytes.
Returns:
read-only buffer
Return type:
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.
read_byte(cancellable)[source]¶
Parameters:
cancellable (Gio.Cancellable or None) – optional [class`Gio`.Cancellable] object, NULL
to ignore
Raises:
Returns:
the byte read from the self, or -1
on end of stream or error.
Return type:
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 [error`Gio`.IOErrorEnum.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.
set_buffer_size(size)[source]¶
Parameters:
size (int) – a #gsize
Sets the size of the internal buffer of self to size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.
do_fill(count, cancellable) virtual¶
Parameters:
- count (int) – the number of bytes that will be read from the stream
- cancellable (Gio.Cancellable or None) – optional [class`Gio`.Cancellable] object,
NULL
to ignore
Returns:
the number of bytes read into stream's buffer, up to count, or -1
on error.
Return type:
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 countlarger than G_MAXSSIZE
will cause a [error`Gio`.IOErrorEnum.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 [error`Gio`.IOErrorEnum.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 [method`Gio`.BufferedInputStream.fill_async].
do_fill_async(count, io_priority, cancellable, callback, *user_data) virtual¶
Parameters:
- count (int) – the number of bytes that will be read from the stream
- io_priority (int) – the I/O priority of the request
- cancellable (Gio.Cancellable or None) – optional [class`Gio`.Cancellable] object
- callback (Gio.AsyncReadyCallback or None) – a [callback`Gio`.AsyncReadyCallback]
- user_data (object or None) – a object
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 [method`Gio`.BufferedInputStream.fill].
If count is -1
then the attempted read size is equal to the number of bytes that are required to fill the buffer.
do_fill_finish(result) virtual¶
Parameters:
result (Gio.AsyncResult) – a [iface`Gio`.AsyncResult]
Returns:
a #gssize of the read stream, or -1
on an error.
Return type:
Finishes an asynchronous read.
Property Details¶
Gio.BufferedInputStream.props.buffer_size¶
Name:
buffer-size
Type:
Default Value:
4096
Flags:
The size of the backend buffer, in bytes.