| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.Gio.Objects.DataInputStream
Contents
Description
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
- 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, MonadIO m) => DataStreamByteOrder -> m (GValueConstruct o)
- getDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> m DataStreamByteOrder
- setDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> DataStreamByteOrder -> m ()
- constructDataInputStreamNewlineType :: (IsDataInputStream o, MonadIO m) => DataStreamNewlineType -> m (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.
Constructors
| DataInputStream (ManagedPtr DataInputStream) |
Instances
| Eq DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream Methods (==) :: DataInputStream -> DataInputStream -> Bool # (/=) :: DataInputStream -> DataInputStream -> Bool # | |
| GObject DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream | |
| ManagedPtrNewtype DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream Methods toManagedPtr :: DataInputStream -> ManagedPtr DataInputStream # | |
| TypedObject DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream | |
| HasParentTypes DataInputStream Source # | |
Defined in GI.Gio.Objects.DataInputStream | |
| IsGValue (Maybe DataInputStream) Source # | Convert |
Defined in GI.Gio.Objects.DataInputStream Methods gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe DataInputStream -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe 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.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, canSeek, canTruncate, clearPending, close, closeAsync, closeFinish, fill, fillAsync, fillFinish, forceFloating, freezeNotify, getv, hasPending, isClosed, isFloating, notify, notifyByPspec, peek, peekBuffer, read, readAll, readAllAsync, readAllFinish, readAsync, readByte, readBytes, readBytesAsync, readBytesFinish, readFinish, readInt16, readInt32, readInt64, readLine, readLineAsync, readLineFinish, readLineFinishUtf8, readLineUtf8, readUint16, readUint32, readUint64, readUntil, readUntilAsync, readUntilFinish, readUpto, readUptoAsync, readUptoFinish, ref, refSink, runDispose, seek, skip, skipAsync, skipFinish, stealData, stealQdata, tell, thawNotify, truncate, unref, watchClosure.
Getters
getAvailable, getBaseStream, getBufferSize, getByteOrder, getCloseBaseStream, getData, getNewlineType, getProperty, getQdata.
Setters
setBufferSize, setByteOrder, setCloseBaseStream, setData, setDataFull, setNewlineType, setPending, setProperty.
getByteOrder
dataInputStreamGetByteOrder Source #
Arguments
| :: (HasCallStack, MonadIO m, IsDataInputStream a) | |
| => a |
|
| -> m DataStreamByteOrder | Returns: the |
Gets the byte order for the data input stream.
getNewlineType
dataInputStreamGetNewlineType Source #
Arguments
| :: (HasCallStack, MonadIO m, IsDataInputStream a) | |
| => a |
|
| -> m DataStreamNewlineType | Returns: |
Gets the current newline type for the stream.
new
Arguments
| :: (HasCallStack, MonadIO m, IsInputStream a) | |
| => a |
|
| -> m DataInputStream | Returns: a new |
Creates a new data input stream for the baseStream.
readByte
dataInputStreamReadByte Source #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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 #
Arguments
| :: (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
The :byte-order property determines the byte ordering that is used when reading multi-byte entities (such as integers) from the stream.
constructDataInputStreamByteOrder :: (IsDataInputStream o, MonadIO m) => DataStreamByteOrder -> m (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
setdataInputStream [ #byteOrder:=value ]
newlineType
The :newline-type property determines what is considered as a line ending when reading complete lines from the stream.
constructDataInputStreamNewlineType :: (IsDataInputStream o, MonadIO m) => DataStreamNewlineType -> m (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
setdataInputStream [ #newlineType:=value ]