gi-gio-2.0.25: Gio bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Objects.DataInputStream

Description

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

Synopsis

Exported types

class (GObject o, IsDescendantOf DataInputStream o) => IsDataInputStream o Source #

Type class for types which can be safely cast to DataInputStream, for instance with toDataInputStream.

Instances

Instances details
(GObject o, IsDescendantOf DataInputStream o) => IsDataInputStream o Source # 
Instance details

Defined in GI.Gio.Objects.DataInputStream

toDataInputStream :: (MonadIO m, IsDataInputStream o) => o -> m DataInputStream Source #

Cast to DataInputStream, for types for which this is known to be safe. For general casts, use castTo.

Methods

Overloaded methods

getByteOrder

dataInputStreamGetByteOrder Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a) 
=> a

stream: a given DataInputStream.

-> m DataStreamByteOrder

Returns: the stream's current DataStreamByteOrder.

Gets the byte order for the data input stream.

getNewlineType

dataInputStreamGetNewlineType Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a) 
=> a

stream: a given DataInputStream.

-> m DataStreamNewlineType

Returns: DataStreamNewlineType for the given stream.

Gets the current newline type for the stream.

new

dataInputStreamNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsInputStream a) 
=> a

baseStream: a InputStream.

-> m DataInputStream

Returns: a new DataInputStream.

Creates a new data input stream for the baseStream.

readByte

dataInputStreamReadByte Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Word8

Returns: an unsigned 8-bit/1-byte value read from the stream or 0 if an error occurred. (Can throw GError)

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

readInt16

dataInputStreamReadInt16 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Int16

Returns: a signed 16-bit/2-byte value read from stream or 0 if an error occurred. (Can throw GError)

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

In order to get the correct byte order for this read operation, see dataInputStreamGetByteOrder and dataInputStreamSetByteOrder.

readInt32

dataInputStreamReadInt32 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Int32

Returns: a signed 32-bit/4-byte value read from the stream or 0 if an error occurred. (Can throw GError)

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

In order to get the correct byte order for this read operation, see dataInputStreamGetByteOrder and dataInputStreamSetByteOrder.

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

readInt64

dataInputStreamReadInt64 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Int64

Returns: a signed 64-bit/8-byte value read from stream or 0 if an error occurred. (Can throw GError)

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

In order to get the correct byte order for this read operation, see dataInputStreamGetByteOrder and dataInputStreamSetByteOrder.

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

readLine

dataInputStreamReadLine Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m (Maybe ByteString, Word64)

Returns: 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 Nothing and error will be set. If there's no content to read, it will still return Nothing, but error won't be set. (Can throw GError)

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

readLineAsync

dataInputStreamReadLineAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> Maybe AsyncReadyCallback

callback: callback to call when the request is satisfied.

-> m () 

The asynchronous version of dataInputStreamReadLine. 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 dataInputStreamReadLineFinish to get the result of the operation.

Since: 2.20

readLineFinish

dataInputStreamReadLineFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) 
=> a

stream: a given DataInputStream.

-> b

result: the AsyncResult that was provided to the callback.

-> m (Maybe ByteString, Word64)

Returns: 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 Nothing and error will be set. If there's no content to read, it will still return Nothing, but error won't be set. (Can throw GError)

Finish an asynchronous call started by dataInputStreamReadLineAsync. Note the warning about string encoding in dataInputStreamReadLine applies here as well.

Since: 2.20

readLineFinishUtf8

dataInputStreamReadLineFinishUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) 
=> a

stream: a given DataInputStream.

-> b

result: the AsyncResult that was provided to the callback.

-> m (Maybe Text, Word64)

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 Nothing 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 Nothing, but error won't be set. (Can throw GError)

Finish an asynchronous call started by dataInputStreamReadLineAsync.

Since: 2.30

readLineUtf8

dataInputStreamReadLineUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m (Maybe Text, Word64)

Returns: 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 Nothing 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 Nothing, but error won't be set. (Can throw GError)

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

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

Since: 2.30

readUint16

dataInputStreamReadUint16 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Word16

Returns: an unsigned 16-bit/2-byte value read from the stream or 0 if an error occurred. (Can throw GError)

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

In order to get the correct byte order for this read operation, see dataInputStreamGetByteOrder and dataInputStreamSetByteOrder.

readUint32

dataInputStreamReadUint32 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Word32

Returns: an unsigned 32-bit/4-byte value read from the stream or 0 if an error occurred. (Can throw GError)

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

In order to get the correct byte order for this read operation, see dataInputStreamGetByteOrder and dataInputStreamSetByteOrder.

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

readUint64

dataInputStreamReadUint64 Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m Word64

Returns: an unsigned 64-bit/8-byte read from stream or 0 if an error occurred. (Can throw GError)

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

In order to get the correct byte order for this read operation, see dataInputStreamGetByteOrder.

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

readUntil

dataInputStreamReadUntil Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Text

stopChars: characters to terminate the read.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m (Text, Word64)

Returns: 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 Nothing on an error. (Can throw GError)

Deprecated: (Since version 2.56)Use dataInputStreamReadUpto instead, which has more consistent behaviour regarding the stop character.

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

Note that, in contrast to dataInputStreamReadUntilAsync, this function consumes the stop character that it finds.

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

readUntilAsync

dataInputStreamReadUntilAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a given DataInputStream.

-> Text

stopChars: characters to terminate the read.

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> Maybe AsyncReadyCallback

callback: callback to call when the request is satisfied.

-> m () 

Deprecated: (Since version 2.56)Use dataInputStreamReadUptoAsync instead, which has more consistent behaviour regarding the stop character.

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

Note that, in contrast to dataInputStreamReadUntil, 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 dataInputStreamReadUntilFinish to get the result of the operation.

Don't use this function in new code. Its functionality is inconsistent with dataInputStreamReadUntil. Both functions will be marked as deprecated in a future release. Use dataInputStreamReadUptoAsync instead.

Since: 2.20

readUntilFinish

dataInputStreamReadUntilFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) 
=> a

stream: a given DataInputStream.

-> b

result: the AsyncResult that was provided to the callback.

-> m (Text, Word64)

Returns: 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 Nothing on an error. (Can throw GError)

Deprecated: (Since version 2.56)Use dataInputStreamReadUptoFinish instead, which has more consistent behaviour regarding the stop character.

Finish an asynchronous call started by dataInputStreamReadUntilAsync.

Since: 2.20

readUpto

dataInputStreamReadUpto Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a DataInputStream

-> Text

stopChars: characters to terminate the read

-> Int64

stopCharsLen: length of stopChars. May be -1 if stopChars is nul-terminated

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m (Text, Word64)

Returns: 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 Nothing on an error (Can throw GError)

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

In contrast to dataInputStreamReadUntil, this function does not consume the stop character. You have to use dataInputStreamReadByte to get it before calling dataInputStreamReadUpto again.

Note that stopChars may contain '\0' if stopCharsLen is specified.

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

Since: 2.26

readUptoAsync

dataInputStreamReadUptoAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) 
=> a

stream: a DataInputStream

-> Text

stopChars: characters to terminate the read

-> Int64

stopCharsLen: length of stopChars. May be -1 if stopChars is nul-terminated

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: callback to call when the request is satisfied

-> m () 

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

In contrast to dataInputStreamReadUntil, this function does not consume the stop character. You have to use dataInputStreamReadByte to get it before calling dataInputStreamReadUpto again.

Note that stopChars may contain '\0' if stopCharsLen is specified.

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

Since: 2.26

readUptoFinish

dataInputStreamReadUptoFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) 
=> a

stream: a DataInputStream

-> b

result: the AsyncResult that was provided to the callback

-> m (Text, Word64)

Returns: 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 Nothing on an error. (Can throw GError)

Finish an asynchronous call started by dataInputStreamReadUptoAsync.

Note that this function does not consume the stop character. You have to use dataInputStreamReadByte to get it before calling dataInputStreamReadUptoAsync again.

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

Since: 2.24

setByteOrder

dataInputStreamSetByteOrder Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a) 
=> a

stream: a given DataInputStream.

-> DataStreamByteOrder

order: a DataStreamByteOrder to set.

-> m () 

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

setNewlineType

dataInputStreamSetNewlineType Source #

Arguments

:: (HasCallStack, MonadIO m, IsDataInputStream a) 
=> a

stream: a DataInputStream.

-> DataStreamNewlineType

type: the type of new line return as DataStreamNewlineType.

-> m () 

Sets the newline type for the stream.

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.

Properties

byteOrder

No description available in the introspection data.

constructDataInputStreamByteOrder :: IsDataInputStream o => DataStreamByteOrder -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “byte-order” property. This is rarely needed directly, but it is used by new.

getDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> m DataStreamByteOrder Source #

Get the value of the “byte-order” property. When overloading is enabled, this is equivalent to

get dataInputStream #byteOrder

setDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> DataStreamByteOrder -> m () Source #

Set the value of the “byte-order” property. When overloading is enabled, this is equivalent to

set dataInputStream [ #byteOrder := value ]

newlineType

No description available in the introspection data.

constructDataInputStreamNewlineType :: IsDataInputStream o => DataStreamNewlineType -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “newline-type” property. This is rarely needed directly, but it is used by new.

getDataInputStreamNewlineType :: (MonadIO m, IsDataInputStream o) => o -> m DataStreamNewlineType Source #

Get the value of the “newline-type” property. When overloading is enabled, this is equivalent to

get dataInputStream #newlineType

setDataInputStreamNewlineType :: (MonadIO m, IsDataInputStream o) => o -> DataStreamNewlineType -> m () Source #

Set the value of the “newline-type” property. When overloading is enabled, this is equivalent to

set dataInputStream [ #newlineType := value ]