Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
Data input stream implements InputStream
and includes functions for
reading structured data directly from a binary input stream.
Synopsis
- newtype DataInputStream = DataInputStream (ManagedPtr DataInputStream)
- class (GObject o, IsDescendantOf DataInputStream o) => IsDataInputStream o
- toDataInputStream :: (MonadIO m, IsDataInputStream o) => o -> m DataInputStream
- noDataInputStream :: Maybe DataInputStream
- dataInputStreamGetByteOrder :: (HasCallStack, MonadIO m, IsDataInputStream a) => a -> m DataStreamByteOrder
- dataInputStreamGetNewlineType :: (HasCallStack, MonadIO m, IsDataInputStream a) => a -> m DataStreamNewlineType
- dataInputStreamNew :: (HasCallStack, MonadIO m, IsInputStream a) => a -> m DataInputStream
- dataInputStreamReadByte :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Word8
- dataInputStreamReadInt16 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Int16
- dataInputStreamReadInt32 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Int32
- dataInputStreamReadInt64 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Int64
- dataInputStreamReadLine :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m (Maybe ByteString, Word64)
- dataInputStreamReadLineAsync :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- dataInputStreamReadLineFinish :: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) => a -> b -> m (Maybe ByteString, Word64)
- dataInputStreamReadLineFinishUtf8 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) => a -> b -> m (Maybe Text, Word64)
- dataInputStreamReadLineUtf8 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m (Maybe Text, Word64)
- dataInputStreamReadUint16 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Word16
- dataInputStreamReadUint32 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Word32
- dataInputStreamReadUint64 :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Maybe b -> m Word64
- dataInputStreamReadUntil :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Text -> Maybe b -> m (Text, Word64)
- dataInputStreamReadUntilAsync :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Text -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- dataInputStreamReadUntilFinish :: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) => a -> b -> m (Text, Word64)
- dataInputStreamReadUpto :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Text -> Int64 -> Maybe b -> m (Text, Word64)
- dataInputStreamReadUptoAsync :: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) => a -> Text -> Int64 -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- dataInputStreamReadUptoFinish :: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) => a -> b -> m (Text, Word64)
- dataInputStreamSetByteOrder :: (HasCallStack, MonadIO m, IsDataInputStream a) => a -> DataStreamByteOrder -> m ()
- dataInputStreamSetNewlineType :: (HasCallStack, MonadIO m, IsDataInputStream a) => a -> DataStreamNewlineType -> m ()
- constructDataInputStreamByteOrder :: IsDataInputStream o => DataStreamByteOrder -> IO (GValueConstruct o)
- getDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> m DataStreamByteOrder
- setDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> DataStreamByteOrder -> m ()
- constructDataInputStreamNewlineType :: IsDataInputStream o => DataStreamNewlineType -> IO (GValueConstruct o)
- getDataInputStreamNewlineType :: (MonadIO m, IsDataInputStream o) => o -> m DataStreamNewlineType
- setDataInputStreamNewlineType :: (MonadIO m, IsDataInputStream o) => o -> DataStreamNewlineType -> m ()
Exported types
newtype DataInputStream Source #
Memory-managed wrapper type.
Instances
Eq DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream (==) :: DataInputStream -> DataInputStream -> Bool # (/=) :: DataInputStream -> DataInputStream -> Bool # | |
GObject DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream gobjectType :: IO GType # | |
IsGValue DataInputStream Source # | Convert |
Defined in GI.Gio.Objects.DataInputStream toGValue :: DataInputStream -> IO GValue # fromGValue :: GValue -> IO DataInputStream # | |
HasParentTypes DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream | |
type ParentTypes DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream |
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
(GObject o, IsDescendantOf DataInputStream o) => IsDataInputStream o Source # | |
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
.
noDataInputStream :: Maybe DataInputStream Source #
A convenience alias for Nothing
:: Maybe
DataInputStream
.
Methods
Overloaded methods
getByteOrder
dataInputStreamGetByteOrder Source #
:: (HasCallStack, MonadIO m, IsDataInputStream a) | |
=> a |
|
-> m DataStreamByteOrder | Returns: the |
Gets the byte order for the data input stream.
getNewlineType
dataInputStreamGetNewlineType Source #
:: (HasCallStack, MonadIO m, IsDataInputStream a) | |
=> a |
|
-> m DataStreamNewlineType | Returns: |
Gets the current newline type for the stream
.
new
:: (HasCallStack, MonadIO m, IsInputStream a) | |
=> a |
|
-> m DataInputStream | Returns: a new |
Creates a new data input stream for the baseStream
.
readByte
dataInputStreamReadByte Source #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Word8 | Returns: an unsigned 8-bit/1-byte value read from the |
Reads an unsigned 8-bit/1-byte value from stream
.
readInt16
dataInputStreamReadInt16 Source #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Int16 | Returns: a signed 16-bit/2-byte value read from |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Int32 | Returns: a signed 32-bit/4-byte value read from the |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Int64 | Returns: a signed 64-bit/8-byte value read from |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m (Maybe ByteString, Word64) | Returns:
a NUL terminated byte array with the line that was read in
(without the newlines). Set |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Maybe ByteString, Word64) | Returns:
a NUL-terminated byte array with the line that was read in
(without the newlines). Set |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Maybe Text, Word64) | Returns: a string with the line that
was read in (without the newlines). Set |
Finish an asynchronous call started by
dataInputStreamReadLineAsync
.
Since: 2.30
readLineUtf8
dataInputStreamReadLineUtf8 Source #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m (Maybe Text, Word64) | Returns: a NUL terminated UTF-8 string
with the line that was read in (without the newlines). Set
|
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Word16 | Returns: an unsigned 16-bit/2-byte value read from the |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Word32 | Returns: an unsigned 32-bit/4-byte value read from the |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Word64 | Returns: an unsigned 64-bit/8-byte read from |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Maybe b |
|
-> m (Text, Word64) | Returns: a string with the data that was read
before encountering any of the stop characters. Set |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Text, Word64) | Returns: a string with the data that was read
before encountering any of the stop characters. Set |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int64 |
|
-> Maybe b |
|
-> m (Text, Word64) | Returns: a string with the data that was read
before encountering any of the stop characters. Set |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int64 |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Text, Word64) | Returns: a string with the data that was read
before encountering any of the stop characters. Set |
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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a) | |
=> a |
|
-> DataStreamByteOrder |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsDataInputStream a) | |
=> a |
|
-> 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 ]