"byte-order"Read - WriteThe byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN."newline-type"Read - WriteThe accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.
Descriptiongio.DataInputStream
implements gio.InputStream
and includes functions for reading structured data directly from a binary input stream.
Constructorgio.DataInputStreambase_streambase_stream :a
gio.InputStream.
Returns :a new
gio.DataInputStream
Creates a new gio.DataInputStream
from the given base_stream.
Methodsgio.DataInputStream.get_byte_orderget_byte_orderReturns :the stream's current
.
The get_byte_order() method gets the byte
order for the data input stream.
gio.DataInputStream.get_newline_typeget_newline_typeReturns :
for the given stream.
The get_newline_type() method gets the current
newline type for the stream.
gio.DataInputStream.read_byteread_bytecancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :an unsigned 8-bit/1-byte value read from the
stream or 0 if an error occurred.
The read_byte() method reads an unsigned 8-bit/1-byte value from stream.
gio.DataInputStream.read_int16read_int16cancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a signed 16-bit/2-byte value read from stream or 0 if an error occurred.
The read_int16() method reads a 16-bit/2-byte value from stream.
In order to get the correct byte order for this read operation, see
gio.DataInputStream.get_byte_order()
and
gio.DataInputStream.set_byte_order().
If cancellable is not None, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation was cancelled,
the error gio.ERROR_CANCELLED will be returned.
gio.DataInputStream.read_int32read_int32cancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a signed 32-bit/4-byte value read from the stream
or 0 if an error occurred.
The read_int32() method reads a signed 32-bit/4-byte value from stream.
In order to get the correct byte order for this read operation, see
gio.DataInputStream.get_byte_order()
and
gio.DataInputStream.set_byte_order().
If cancellable is not None, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation was cancelled,
the error gio.ERROR_CANCELLED will be returned.
gio.DataInputStream.read_int64read_int64cancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a signed 64-bit/8-byte value read from the stream
or 0 if an error occurred.
The read_int64() method reads a signed 64-bit/8-byte value from stream.
In order to get the correct byte order for this read operation, see
gio.DataInputStream.get_byte_order()
and
gio.DataInputStream.set_byte_order().
If cancellable is not None, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation was cancelled,
the error gio.ERROR_CANCELLED will be returned.
gio.DataInputStream.read_lineread_linecancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a string with the line that was read in (without the newlines).
Set length to a gsize to get the length of the read line. On an error, it will return
None and error will be set. If there's no content to read, it
will still return None, but error won't be set.
The read_line() reads a line from the data input stream.
If cancellable is not None, then the operation can
be cancelled by triggering the cancellable object from another thread.
If the operation was cancelled, the error gio.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.
gio.DataInputStream.read_line_asyncread_line_asynccallbackio_priorityglib.PRIORITY_DEFAULTcancellableNoneuser_dataNonecallback :a GAsyncReadyCallback to call when the request is satisfied.
io_priority :the
of the request.
cancellable :optional
gio.Cancellable
object, None to ignore.user_data :the data to pass to callback function.
The read_line_async() method is the asynchronous version of
gio.DataInputStream.read_line().
It is an error to have two outstanding calls to this function.
For the synchronous version of this function, see
gio.DataInputStream.read_line().
If cancellable is not None, then the operation can be cancelled
by triggering the cancellable object from another thread. If the operation was
cancelled, the error gio.ERROR_CANCELLED will be set
gio.DataInputStream.read_line_finishread_line_finishresultresult :a gio.AsyncResult.
Returns :a string with the line that was read in (without the newlines).
On an error, it will return None and error will be set.
If there's no content to read, it will still return None,
but error won't be set.
The read_line_finish() method finishes an asynchronous
file append operation started with
gio.DataInputStream.read_line_async().
gio.DataInputStream.read_uint16read_uint16cancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a signed 16-bit/2-byte value read from stream or 0 if an error occurred.
The read_uint16() method reads a 16-bit/2-byte value from stream.
In order to get the correct byte order for this read operation, see
gio.DataInputStream.get_byte_order()
and
gio.DataInputStream.set_byte_order().
If cancellable is not None, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation was cancelled,
the error gio.ERROR_CANCELLED will be returned.
gio.DataInputStream.read_uint32read_uint32cancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a signed 32-bit/4-byte value read from the stream
or 0 if an error occurred.
The read_uint32() method reads a signed 32-bit/4-byte value from stream.
In order to get the correct byte order for this read operation, see
gio.DataInputStream.get_byte_order()
and
gio.DataInputStream.set_byte_order().
If cancellable is not None, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation was cancelled,
the error gio.ERROR_CANCELLED will be returned.
gio.DataInputStream.read_uint64read_uint64cancellableNonecancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a signed 64-bit/8-byte value read from the stream
or 0 if an error occurred.
The read_uint64() method reads a signed 64-bit/8-byte value from stream.
In order to get the correct byte order for this read operation, see
gio.DataInputStream.get_byte_order()
and
gio.DataInputStream.set_byte_order().
If cancellable is not None, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation was cancelled,
the error gio.ERROR_CANCELLED will be returned.
gio.DataInputStream.read_untilread_untilstop_charscancellableNonestop_chars :characters to terminate the read.
cancellable :optional
gio.Cancellable
object, None to ignore.
Returns :a string with the data that was read before encountering
any of the stop characters. This function will return NULL on an error.
The read_until() reads a string from the data input
stream, up to the first occurrence of any of the stop characters.
gio.DataInputStream.read_until_asyncread_until_asyncstop_charscallbackio_priorityglib.PRIORITY_DEFAULTcancellableNoneuser_dataNonestop_chars :characters to terminate the read.
callback :a GAsyncReadyCallback to call when the request is satisfied.
io_priority :the
of the request.
cancellable :optional
gio.Cancellable
object, None to ignore.user_data :the data to pass to callback function.
The read_until_async() method it's the asynchronous version of
gio.DataInputStream.read_until().
It is an error to have two outstanding calls to this function.
For the synchronous version of this function, see
gio.DataInputStream.read_until().
If cancellable is not None, then the operation can be cancelled
by triggering the cancellable object from another thread. If the operation was
cancelled, the error gio.ERROR_CANCELLED will be set
When the operation is finished, callback will be called. You can then call
gio.DataInputStream.read_until_finish()
to get the result of the operation.
gio.DataInputStream.read_until_finishread_until_finishresultresult :a gio.AsyncResult.
Returns :a string with the data that was read before encountering
any of the stop characters. This function will return None on an error.
The read_until_finish() method finishes an asynchronous
file append operation started with
gio.DataInputStream.read_until_async().
gio.DataInputStream.set_byte_orderset_byte_orderorderorder :a
to set.
The set_byte_order() method sets the byte order for
the given stream. All subsequent reads from the stream will be read in the given order.
gio.DataInputStream.set_newline_typeset_newline_typetypetype :a
to set.
The set_newline_type() method sets the newline type for the stream.
Note that using gio.DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a
read chunk ends in "CR" we must read an additional byte to know if this is
"CR" or "CR LF", and this might block if there is no more data availible.