Class: Gio::DataInputStream

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#byte_orderGio::DataStreamByteOrder

Returns byte-order.

Returns:

#byte_order=(byte_order) ⇒ Gio::DataStreamByteOrder

Parameters:

Returns:

#new(base_stream) ⇒ Gio::DataInputStream

Creates a new data input stream for the base_stream.

Parameters:

Returns:

#newline_typeGio::DataStreamNewlineType

Returns newline-type.

Returns:

#newline_type=(newline_type) ⇒ Gio::DataStreamNewlineType

Parameters:

Returns:

#read_byte(cancellable) ⇒ Integer

Reads an unsigned 8-bit/1-byte value from stream. if an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    an unsigned 8-bit/1-byte value read from the stream or ‘0`

#read_int16(cancellable) ⇒ Integer

Reads a 16-bit/2-byte value from stream.

In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    a signed 16-bit/2-byte value read from stream or ‘0` if

#read_int32(cancellable) ⇒ Integer

Reads a signed 32-bit/4-byte value from stream.

In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

If cancellable is not nil, 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. an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    a signed 32-bit/4-byte value read from the stream or ‘0` if

#read_int64(cancellable) ⇒ Integer

Reads a 64-bit/8-byte value from stream.

In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

If cancellable is not nil, 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. an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    a signed 64-bit/8-byte value read from stream or ‘0` if

#read_line(length, cancellable) ⇒ Array<Integer>

Reads a line from the data input stream. Note that no encoding checks or conversion is performed; the input is not guaranteed to be UTF-8, and may in fact have embedded NUL characters.

If cancellable is not nil, 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.

Parameters:

  • length (Integer)

    a #gsize to get the length of the data read in.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Array<Integer>)

    a NUL terminated byte array 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 nil and error will be set. If there’s no content to read, it will still return nil, but error won’t be set.

#read_line_async(io_priority, cancellable, callback, user_data) ⇒ nil

The asynchronous version of g_data_input_stream_read_line(). It is an error to have two outstanding calls to this function.

When the operation is finished, callback will be called. You can then call g_data_input_stream_read_line_finish() to get the result of the operation.

Parameters:

  • io_priority (Integer)

    the [I/O priority] of the request

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    callback to call when the request is satisfied.

  • user_data (GObject)

    the data to pass to callback function.

Returns:

  • (nil)

#read_line_finish(result, length) ⇒ Array<Integer>

Finish an asynchronous call started by g_data_input_stream_read_line_async(). Note the warning about string encoding in g_data_input_stream_read_line() applies here as well.

Parameters:

  • result (Gio::AsyncResult)

    the GAsync::Result that was provided to the callback.

  • length (Integer)

    a #gsize to get the length of the data read in.

Returns:

  • (Array<Integer>)

    a NUL-terminated byte array 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 nil and error will be set. If there’s no content to read, it will still return nil, but error won’t be set.

#read_line_finish_utf8(result, length) ⇒ String

Finish an asynchronous call started by g_data_input_stream_read_line_async().

Parameters:

  • result (Gio::AsyncResult)

    the GAsync::Result that was provided to the callback.

  • length (Integer)

    a #gsize to get the length of the data read in.

Returns:

  • (String)

    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 nil and error will be set. For UTF-8 conversion errors, the set error domain is %G_CONVERT_ERROR. If there’s no content to read, it will still return nil, but error won’t be set.

#read_line_utf8(length, cancellable) ⇒ String

Reads a UTF-8 encoded line from the data input stream.

If cancellable is not nil, 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.

Parameters:

  • length (Integer)

    a #gsize to get the length of the data read in.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (String)

    a NUL terminated UTF-8 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 nil and error will be set. For UTF-8 conversion errors, the set error domain is %G_CONVERT_ERROR. If there’s no content to read, it will still return nil, but error won’t be set.

#read_uint16(cancellable) ⇒ Integer

Reads an unsigned 16-bit/2-byte value from stream.

In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    an unsigned 16-bit/2-byte value read from the stream or ‘0` if

#read_uint32(cancellable) ⇒ Integer

Reads an unsigned 32-bit/4-byte value from stream.

In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

If cancellable is not nil, 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. an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    an unsigned 32-bit/4-byte value read from the stream or ‘0` if

#read_uint64(cancellable) ⇒ Integer

Reads an unsigned 64-bit/8-byte value from stream.

In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order().

If cancellable is not nil, 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. an error occurred.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (Integer)

    an unsigned 64-bit/8-byte read from stream or ‘0` if

#read_until(stop_chars, length, cancellable) ⇒ String

Reads a string from the data input stream, up to the first occurrence of any of the stop characters.

Note that, in contrast to g_data_input_stream_read_until_async(), this function consumes the stop character that it finds.

Don’t use this function in new code. Its functionality is inconsistent with g_data_input_stream_read_until_async(). Both functions will be marked as deprecated in a future release. Use g_data_input_stream_read_upto() instead, but note that that function does not consume the stop character.

Parameters:

  • stop_chars (String)

    characters to terminate the read.

  • length (Integer)

    a #gsize to get the length of the data read in.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (String)

    a string with the data that was read before encountering any of the stop characters. Set length to a #gsize to get the length of the string. This function will return nil on an error.

#read_until_async(stop_chars, io_priority, cancellable, callback, user_data) ⇒ nil

The asynchronous version of g_data_input_stream_read_until(). It is an error to have two outstanding calls to this function.

Note that, in contrast to g_data_input_stream_read_until(), this function does not consume the stop character that it finds. You must read it for yourself.

When the operation is finished, callback will be called. You can then call g_data_input_stream_read_until_finish() to get the result of the operation.

Don’t use this function in new code. Its functionality is inconsistent with g_data_input_stream_read_until(). Both functions will be marked as deprecated in a future release. Use g_data_input_stream_read_upto_async() instead.

Parameters:

  • stop_chars (String)

    characters to terminate the read.

  • io_priority (Integer)

    the [I/O priority] of the request

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    callback to call when the request is satisfied.

  • user_data (GObject)

    the data to pass to callback function.

Returns:

  • (nil)

#read_until_finish(result, length) ⇒ String

Finish an asynchronous call started by g_data_input_stream_read_until_async().

Parameters:

  • result (Gio::AsyncResult)

    the GAsync::Result that was provided to the callback.

  • length (Integer)

    a #gsize to get the length of the data read in.

Returns:

  • (String)

    a string with the data that was read before encountering any of the stop characters. Set length to a #gsize to get the length of the string. This function will return nil on an error.

#read_upto(stop_chars, stop_chars_len, length, cancellable) ⇒ String

Reads a string from the data input stream, up to the first occurrence of any of the stop characters.

In contrast to g_data_input_stream_read_until(), this function does not consume the stop character. You have to use g_data_input_stream_read_byte() to get it before calling g_data_input_stream_read_upto() again.

Note that stop_chars may contain ‘0’ if stop_chars_len is specified.

The returned string will always be nul-terminated on success.

Parameters:

  • stop_chars (String)

    characters to terminate the read

  • stop_chars_len (Gio::gssize)

    length of stop_chars. May be -1 if stop_chars is nul-terminated

  • length (Integer)

    a #gsize to get the length of the data read in

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

Returns:

  • (String)

    a string with the data that was read before encountering any of the stop characters. Set length to a #gsize to get the length of the string. This function will return nil on an error

#read_upto_async(stop_chars, stop_chars_len, io_priority, cancellable, callback, user_data) ⇒ nil

The asynchronous version of g_data_input_stream_read_upto(). It is an error to have two outstanding calls to this function.

In contrast to g_data_input_stream_read_until(), this function does not consume the stop character. You have to use g_data_input_stream_read_byte() to get it before calling g_data_input_stream_read_upto() again.

Note that stop_chars may contain ‘0’ if stop_chars_len is specified.

When the operation is finished, callback will be called. You can then call g_data_input_stream_read_upto_finish() to get the result of the operation.

Parameters:

  • stop_chars (String)

    characters to terminate the read

  • stop_chars_len (Gio::gssize)

    length of stop_chars. May be -1 if stop_chars is nul-terminated

  • io_priority (Integer)

    the [I/O priority] of the request

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

  • callback (Gio::AsyncReadyCallback)

    callback to call when the request is satisfied

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#read_upto_finish(result, length) ⇒ String

Finish an asynchronous call started by g_data_input_stream_read_upto_async().

Note that this function does not consume the stop character. You have to use g_data_input_stream_read_byte() to get it before calling g_data_input_stream_read_upto_async() again.

The returned string will always be nul-terminated on success.

Parameters:

  • result (Gio::AsyncResult)

    the GAsync::Result that was provided to the callback

  • length (Integer)

    a #gsize to get the length of the data read in

Returns:

  • (String)

    a string with the data that was read before encountering any of the stop characters. Set length to a #gsize to get the length of the string. This function will return nil on an error.