gio.DataInputStream — Data Input Stream
class gio.DataInputStream(gio.BufferedInputStream): |
+-- gobject.GObject +-- gio.InputStream +-- gio.FilterInputStream +-- gio.BufferedInputStream +-- gio.DataInputStream
|
gio.DataInputStream
implements gio.InputStream
and includes functions for reading structured data directly from a binary input stream.
gio.DataInputStream(base_stream
)
| a
gio.InputStream .
|
Returns : | a new
gio.DataInputStream
|
Creates a new gio.DataInputStream
from the given base_stream.
def get_byte_order()
Returns : | the stream's current Gio Data Stream Byte Order Constants. |
The get_byte_order
() method gets the byte
order for the data input stream.
def get_newline_type()
Returns : | Gio Data Stream Newline Type Constants for the given stream. |
The get_newline_type
() method gets the current
newline type for the stream.
def read_byte(cancellable
=None)
| 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.
def read_int16(cancellable
=None)
| 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
()
and
().
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.
def read_int32(cancellable
=None)
| 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
()
and
().
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.
def read_int64(cancellable
=None)
| 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
()
and
().
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.
def read_line(cancellable
=None)
| 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.
def read_line_async(callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
| a GAsyncReadyCallback to call when the request is satisfied. |
| the Glib Priority Constants of the request. |
| optional
gio.Cancellable
object, None to ignore. |
| 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
def read_line_finish(result
)
| 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
().
def read_uint16(cancellable
=None)
| 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
()
and
().
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.
def read_uint32(cancellable
=None)
| 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
()
and
().
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.
def read_uint64(cancellable
=None)
| 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
()
and
().
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.
def read_until(stop_chars
, cancellable
=None)
| characters to terminate the read. |
| 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.
def read_until_async(stop_chars
, callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
| characters to terminate the read. |
| a GAsyncReadyCallback to call when the request is satisfied. |
| the Glib Priority Constants of the request. |
| optional
gio.Cancellable
object, None to ignore. |
| 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.
def read_until_finish(result
)
| 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
().
def set_byte_order(order
)
| a Gio Data Stream Byte Order Constants 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.
def set_newline_type(type
)
| a Gio Data Stream Newline Type Constants to set. |
The set_newline_type
() method sets the newline type for the stream.