gio.DataInputStream Data Input Stream Synopsis gio.DataInputStream gio.BufferedInputStream gio.DataInputStream base_stream get_byte_order get_newline_type read_byte cancellableNone read_int16 cancellableNone read_int32 cancellableNone read_int64 cancellableNone read_line cancellableNone read_line_async callback io_priorityglib.PRIORITY_DEFAULT cancellableNone user_dataNone read_line_finish result read_uint16 cancellableNone read_uint32 cancellableNone read_uint64 cancellableNone read_until stop_chars cancellableNone read_until_async stop_chars callback io_priorityglib.PRIORITY_DEFAULT cancellableNone user_dataNone read_until_finish result set_byte_order order set_newline_type type Ancestry +-- gobject.GObject +-- gio.InputStream +-- gio.FilterInputStream +-- gio.BufferedInputStream +-- gio.DataInputStream gio.DataInputStream Properties
"byte-order" Read - Write The byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN. "newline-type" Read - Write The accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.
Description gio.DataInputStream implements gio.InputStream and includes functions for reading structured data directly from a binary input stream. Constructor gio.DataInputStream base_stream base_stream : a gio.InputStream. Returns : a new gio.DataInputStream Creates a new gio.DataInputStream from the given base_stream. Methods gio.DataInputStream.get_byte_order get_byte_order Returns : the stream's current . The get_byte_order() method gets the byte order for the data input stream. gio.DataInputStream.get_newline_type get_newline_type Returns : for the given stream. The get_newline_type() method gets the current newline type for the stream. gio.DataInputStream.read_byte read_byte cancellableNone cancellable : 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_int16 read_int16 cancellableNone cancellable : 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_int32 read_int32 cancellableNone cancellable : 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_int64 read_int64 cancellableNone cancellable : 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_line read_line cancellableNone cancellable : 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_async read_line_async callback io_priorityglib.PRIORITY_DEFAULT cancellableNone user_dataNone 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_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_finish read_line_finish result 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(). gio.DataInputStream.read_uint16 read_uint16 cancellableNone cancellable : 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_uint32 read_uint32 cancellableNone cancellable : 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_uint64 read_uint64 cancellableNone cancellable : 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_until read_until stop_chars cancellableNone stop_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_async read_until_async stop_chars callback io_priorityglib.PRIORITY_DEFAULT cancellableNone user_dataNone stop_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_finish read_until_finish result 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(). gio.DataInputStream.set_byte_order set_byte_order order order : 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_type set_newline_type type type : 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.