1.26 <GDataInputStream>

Class: <GDataInputStream>

It derives from <GBufferedInputStream>.

Data input stream implements <GInputStream> and includes functions for reading structured data directly from a binary input stream.

Fields

parent-instance

Properties

Property: data-input-stream:byte-order self

The :byte-order property determines the byte ordering that is used when reading multi-byte entities (such as integers) from the stream.

Its value is a <GDataStreamByteOrder> (or, to set it, one of its symbols).

Set it with (set! (data-input-stream:byte-order self) value).

Property: data-input-stream:newline-type self

The :newline-type property determines what is considered as a line ending when reading complete lines from the stream.

Its value is a <GDataStreamNewlineType> (or, to set it, one of its symbols).

Set it with (set! (data-input-stream:newline-type self) value).

Procedures

Method: data-input-stream:get-byte-order self ⇒ %return
Method: get-byte-order self ⇒ %return

Gets the byte order for the data input stream.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

%return

Returned: a <GDataStreamByteOrder>.

the self’s current <GDataStreamByteOrder>.

Method: data-input-stream:get-newline-type self ⇒ %return
Method: get-newline-type self ⇒ %return

Gets the current newline type for the self.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

%return

Returned: a <GDataStreamNewlineType>.

<GDataStreamNewlineType> for the given self.

Procedure: data-input-stream:new base-stream ⇒ %return

Creates a new data input stream for the base-stream.

base-stream

Passed: a <GInputStream>.

a <GInputStream>.

%return

Returned: a <GDataInputStream>.

a new <GDataInputStream>.

Method: data-input-stream:read-byte self [cancellable] ⇒ %return
Method: read-byte self [cancellable] ⇒ %return

Reads an unsigned 8-bit/1-byte value from self.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: an unsigned 8-bit integer.

an unsigned 8-bit/1-byte value read from the self or 0 if an error occurred.

Method: data-input-stream:read-int16 self [cancellable] ⇒ %return
Method: read-int16 self [cancellable] ⇒ %return

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

In order to get the correct byte order for this read operation, see data-input-stream:get-byte-order and data-input-stream:set-byte-order.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a 16-bit integer.

a signed 16-bit/2-byte value read from self or 0 if an error occurred.

Method: data-input-stream:read-int32 self [cancellable] ⇒ %return
Method: read-int32 self [cancellable] ⇒ %return

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

In order to get the correct byte order for this read operation, see data-input-stream:get-byte-order and data-input-stream:set-byte-order.

If cancellable is not #f, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error cancelled will be returned.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a 32-bit integer.

a signed 32-bit/4-byte value read from the self or 0 if an error occurred.

Method: data-input-stream:read-int64 self [cancellable] ⇒ %return
Method: read-int64 self [cancellable] ⇒ %return

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

In order to get the correct byte order for this read operation, see data-input-stream:get-byte-order and data-input-stream:set-byte-order.

If cancellable is not #f, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error cancelled will be returned.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a 64-bit integer.

a signed 64-bit/8-byte value read from self or 0 if an error occurred.

Method: data-input-stream:read-line self [cancellable] ⇒ %return length
Method: read-line self [cancellable] ⇒ %return length

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 #f, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error cancelled will be returned.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a bytevector, or #f.

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 #f and error will be set. If there’s no content to read, it will still return #f, but error won’t be set.

length

Returned: an unsigned 64-bit integer.

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

Method: data-input-stream:read-line-async self io-priority [cancellable] [callback]
Method: read-line-async self io-priority [cancellable] [callback]

The asynchronous version of 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 data-input-stream:read-line-finish to get the result of the operation.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

io-priority

Passed: a 32-bit integer.

the I/O priority of the request

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied.

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function.

Method: data-input-stream:read-line-finish self result ⇒ %return length
Method: read-line-finish self result ⇒ %return length

Finish an asynchronous call started by data-input-stream:read-line-async. Note the warning about string encoding in data-input-stream:read-line applies here as well.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

result

Passed: a <GAsyncResult>.

the <GAsyncResult> that was provided to the callback.

%return

Returned: a bytevector, or #f.

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 #f and error will be set. If there’s no content to read, it will still return #f, but error won’t be set.

length

Returned: an unsigned 64-bit integer.

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

Method: data-input-stream:read-line-finish-utf8 self result ⇒ %return length
Method: read-line-finish-utf8 self result ⇒ %return length

Finish an asynchronous call started by data-input-stream:read-line-async.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

result

Passed: a <GAsyncResult>.

the <GAsyncResult> that was provided to the callback.

%return

Returned: a string, or #f.

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 #f 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 #f, but error won’t be set.

length

Returned: an unsigned 64-bit integer.

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

Method: data-input-stream:read-line-utf8 self [cancellable] ⇒ %return length
Method: read-line-utf8 self [cancellable] ⇒ %return length

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

If cancellable is not #f, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error cancelled will be returned.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a string, or #f.

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 #f 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 #f, but error won’t be set.

length

Returned: an unsigned 64-bit integer.

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

Method: data-input-stream:read-uint16 self [cancellable] ⇒ %return
Method: read-uint16 self [cancellable] ⇒ %return

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

In order to get the correct byte order for this read operation, see data-input-stream:get-byte-order and data-input-stream:set-byte-order.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: an unsigned 16-bit integer.

an unsigned 16-bit/2-byte value read from the self or 0 if an error occurred.

Method: data-input-stream:read-uint32 self [cancellable] ⇒ %return
Method: read-uint32 self [cancellable] ⇒ %return

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

In order to get the correct byte order for this read operation, see data-input-stream:get-byte-order and data-input-stream:set-byte-order.

If cancellable is not #f, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error cancelled will be returned.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: an unsigned 32-bit integer.

an unsigned 32-bit/4-byte value read from the self or 0 if an error occurred.

Method: data-input-stream:read-uint64 self [cancellable] ⇒ %return
Method: read-uint64 self [cancellable] ⇒ %return

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

In order to get the correct byte order for this read operation, see data-input-stream:get-byte-order.

If cancellable is not #f, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error cancelled will be returned.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: an unsigned 64-bit integer.

an unsigned 64-bit/8-byte read from self or 0 if an error occurred.

Method: data-input-stream:read-until self stop-chars [cancellable] ⇒ %return length
Method: read-until self stop-chars [cancellable] ⇒ %return length

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

Note that, in contrast to 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 data-input-stream:read-until-async. Both functions will be marked as deprecated in a future release. Use data-input-stream:read-upto instead, but note that that function does not consume the stop character.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

stop-chars

Passed: a string.

characters to terminate the read.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a 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 #f on an error.

length

Returned: an unsigned 64-bit integer.

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

Method: data-input-stream:read-until-async self stop-chars io-priority [cancellable] [callback]
Method: read-until-async self stop-chars io-priority [cancellable] [callback]

The asynchronous version of data-input-stream:read-until. It is an error to have two outstanding calls to this function.

Note that, in contrast to 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 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 data-input-stream:read-until. Both functions will be marked as deprecated in a future release. Use data-input-stream:read-upto-async instead.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

stop-chars

Passed: a string.

characters to terminate the read.

io-priority

Passed: a 32-bit integer.

the I/O priority of the request

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied.

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function.

Method: data-input-stream:read-until-finish self result ⇒ %return length
Method: read-until-finish self result ⇒ %return length

Finish an asynchronous call started by data-input-stream:read-until-async.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

result

Passed: a <GAsyncResult>.

the <GAsyncResult> that was provided to the callback.

%return

Returned: a 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 #f on an error.

length

Returned: an unsigned 64-bit integer.

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

Method: data-input-stream:read-upto self stop-chars stop-chars-len [cancellable] ⇒ %return length
Method: read-upto self stop-chars stop-chars-len [cancellable] ⇒ %return length

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

In contrast to data-input-stream:read-until, this function does not consume the stop character. You have to use data-input-stream:read-byte to get it before calling 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.

self

Passed: a <GDataInputStream>.

a <GDataInputStream>

stop-chars

Passed: a string.

characters to terminate the read

stop-chars-len

Passed: a 64-bit integer.

length of stop-chars. May be -1 if stop-chars is nul-terminated

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

%return

Returned: a 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 #f on an error

length

Returned: an unsigned 64-bit integer.

a gsize to get the length of the data read in

Method: data-input-stream:read-upto-async self stop-chars stop-chars-len io-priority [cancellable] [callback]
Method: read-upto-async self stop-chars stop-chars-len io-priority [cancellable] [callback]

The asynchronous version of data-input-stream:read-upto. It is an error to have two outstanding calls to this function.

In contrast to data-input-stream:read-until, this function does not consume the stop character. You have to use data-input-stream:read-byte to get it before calling 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 data-input-stream:read-upto-finish to get the result of the operation.

self

Passed: a <GDataInputStream>.

a <GDataInputStream>

stop-chars

Passed: a string.

characters to terminate the read

stop-chars-len

Passed: a 64-bit integer.

length of stop-chars. May be -1 if stop-chars is nul-terminated

io-priority

Passed: a 32-bit integer.

the I/O priority of the request

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: data-input-stream:read-upto-finish self result ⇒ %return length
Method: read-upto-finish self result ⇒ %return length

Finish an asynchronous call started by data-input-stream:read-upto-async.

Note that this function does not consume the stop character. You have to use data-input-stream:read-byte to get it before calling data-input-stream:read-upto-async again.

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

self

Passed: a <GDataInputStream>.

a <GDataInputStream>

result

Passed: a <GAsyncResult>.

the <GAsyncResult> that was provided to the callback

%return

Returned: a 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 #f on an error.

length

Returned: an unsigned 64-bit integer.

a gsize to get the length of the data read in

Method: data-input-stream:set-byte-order self order
Method: set-byte-order self order

This function sets the byte order for the given self. All subsequent reads from the self will be read in the given order.

self

Passed: a <GDataInputStream>.

a given <GDataInputStream>.

order

Passed: a <GDataStreamByteOrder>, or one of its symbols.

a <GDataStreamByteOrder> to set.

Method: data-input-stream:set-newline-type self type
Method: set-newline-type self type

Sets the newline type for the self.

Note that using G_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 available.

self

Passed: a <GDataInputStream>.

a <GDataInputStream>.

type

Passed: a <GDataStreamNewlineType>, or one of its symbols.

the type of new line return as <GDataStreamNewlineType>.