{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Data input stream implements 'GI.Gio.Objects.InputStream.InputStream' and includes functions for
reading structured data directly from a binary input stream.
-}

module GI.Gio.Objects.DataInputStream
    ( 

-- * Exported types
    DataInputStream(..)                     ,
    IsDataInputStream                       ,
    toDataInputStream                       ,
    noDataInputStream                       ,


 -- * Methods
-- ** getByteOrder #method:getByteOrder#
    DataInputStreamGetByteOrderMethodInfo   ,
    dataInputStreamGetByteOrder             ,


-- ** getNewlineType #method:getNewlineType#
    DataInputStreamGetNewlineTypeMethodInfo ,
    dataInputStreamGetNewlineType           ,


-- ** new #method:new#
    dataInputStreamNew                      ,


-- ** readByte #method:readByte#
    DataInputStreamReadByteMethodInfo       ,
    dataInputStreamReadByte                 ,


-- ** readInt16 #method:readInt16#
    DataInputStreamReadInt16MethodInfo      ,
    dataInputStreamReadInt16                ,


-- ** readInt32 #method:readInt32#
    DataInputStreamReadInt32MethodInfo      ,
    dataInputStreamReadInt32                ,


-- ** readInt64 #method:readInt64#
    DataInputStreamReadInt64MethodInfo      ,
    dataInputStreamReadInt64                ,


-- ** readLine #method:readLine#
    DataInputStreamReadLineMethodInfo       ,
    dataInputStreamReadLine                 ,


-- ** readLineAsync #method:readLineAsync#
    DataInputStreamReadLineAsyncMethodInfo  ,
    dataInputStreamReadLineAsync            ,


-- ** readLineFinish #method:readLineFinish#
    DataInputStreamReadLineFinishMethodInfo ,
    dataInputStreamReadLineFinish           ,


-- ** readLineFinishUtf8 #method:readLineFinishUtf8#
    DataInputStreamReadLineFinishUtf8MethodInfo,
    dataInputStreamReadLineFinishUtf8       ,


-- ** readLineUtf8 #method:readLineUtf8#
    DataInputStreamReadLineUtf8MethodInfo   ,
    dataInputStreamReadLineUtf8             ,


-- ** readUint16 #method:readUint16#
    DataInputStreamReadUint16MethodInfo     ,
    dataInputStreamReadUint16               ,


-- ** readUint32 #method:readUint32#
    DataInputStreamReadUint32MethodInfo     ,
    dataInputStreamReadUint32               ,


-- ** readUint64 #method:readUint64#
    DataInputStreamReadUint64MethodInfo     ,
    dataInputStreamReadUint64               ,


-- ** readUntil #method:readUntil#
    DataInputStreamReadUntilMethodInfo      ,
    dataInputStreamReadUntil                ,


-- ** readUntilAsync #method:readUntilAsync#
    DataInputStreamReadUntilAsyncMethodInfo ,
    dataInputStreamReadUntilAsync           ,


-- ** readUntilFinish #method:readUntilFinish#
    DataInputStreamReadUntilFinishMethodInfo,
    dataInputStreamReadUntilFinish          ,


-- ** readUpto #method:readUpto#
    DataInputStreamReadUptoMethodInfo       ,
    dataInputStreamReadUpto                 ,


-- ** readUptoAsync #method:readUptoAsync#
    DataInputStreamReadUptoAsyncMethodInfo  ,
    dataInputStreamReadUptoAsync            ,


-- ** readUptoFinish #method:readUptoFinish#
    DataInputStreamReadUptoFinishMethodInfo ,
    dataInputStreamReadUptoFinish           ,


-- ** setByteOrder #method:setByteOrder#
    DataInputStreamSetByteOrderMethodInfo   ,
    dataInputStreamSetByteOrder             ,


-- ** setNewlineType #method:setNewlineType#
    DataInputStreamSetNewlineTypeMethodInfo ,
    dataInputStreamSetNewlineType           ,




 -- * Properties
-- ** byteOrder #attr:byteOrder#
    DataInputStreamByteOrderPropertyInfo    ,
    constructDataInputStreamByteOrder       ,
    dataInputStreamByteOrder                ,
    getDataInputStreamByteOrder             ,
    setDataInputStreamByteOrder             ,


-- ** newlineType #attr:newlineType#
    DataInputStreamNewlineTypePropertyInfo  ,
    constructDataInputStreamNewlineType     ,
    dataInputStreamNewlineType              ,
    getDataInputStreamNewlineType           ,
    setDataInputStreamNewlineType           ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Seekable as Gio.Seekable
import {-# SOURCE #-} qualified GI.Gio.Objects.BufferedInputStream as Gio.BufferedInputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.FilterInputStream as Gio.FilterInputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream

newtype DataInputStream = DataInputStream (ManagedPtr DataInputStream)
foreign import ccall "g_data_input_stream_get_type"
    c_g_data_input_stream_get_type :: IO GType

instance GObject DataInputStream where
    gobjectType _ = c_g_data_input_stream_get_type
    

class GObject o => IsDataInputStream o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DataInputStream a) =>
    IsDataInputStream a
#endif
instance IsDataInputStream DataInputStream
instance Gio.BufferedInputStream.IsBufferedInputStream DataInputStream
instance Gio.FilterInputStream.IsFilterInputStream DataInputStream
instance Gio.InputStream.IsInputStream DataInputStream
instance GObject.Object.IsObject DataInputStream
instance Gio.Seekable.IsSeekable DataInputStream

toDataInputStream :: IsDataInputStream o => o -> IO DataInputStream
toDataInputStream = unsafeCastTo DataInputStream

noDataInputStream :: Maybe DataInputStream
noDataInputStream = Nothing

type family ResolveDataInputStreamMethod (t :: Symbol) (o :: *) :: * where
    ResolveDataInputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDataInputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDataInputStreamMethod "canSeek" o = Gio.Seekable.SeekableCanSeekMethodInfo
    ResolveDataInputStreamMethod "canTruncate" o = Gio.Seekable.SeekableCanTruncateMethodInfo
    ResolveDataInputStreamMethod "clearPending" o = Gio.InputStream.InputStreamClearPendingMethodInfo
    ResolveDataInputStreamMethod "close" o = Gio.InputStream.InputStreamCloseMethodInfo
    ResolveDataInputStreamMethod "closeAsync" o = Gio.InputStream.InputStreamCloseAsyncMethodInfo
    ResolveDataInputStreamMethod "closeFinish" o = Gio.InputStream.InputStreamCloseFinishMethodInfo
    ResolveDataInputStreamMethod "fill" o = Gio.BufferedInputStream.BufferedInputStreamFillMethodInfo
    ResolveDataInputStreamMethod "fillAsync" o = Gio.BufferedInputStream.BufferedInputStreamFillAsyncMethodInfo
    ResolveDataInputStreamMethod "fillFinish" o = Gio.BufferedInputStream.BufferedInputStreamFillFinishMethodInfo
    ResolveDataInputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDataInputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDataInputStreamMethod "hasPending" o = Gio.InputStream.InputStreamHasPendingMethodInfo
    ResolveDataInputStreamMethod "isClosed" o = Gio.InputStream.InputStreamIsClosedMethodInfo
    ResolveDataInputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDataInputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDataInputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDataInputStreamMethod "peek" o = Gio.BufferedInputStream.BufferedInputStreamPeekMethodInfo
    ResolveDataInputStreamMethod "peekBuffer" o = Gio.BufferedInputStream.BufferedInputStreamPeekBufferMethodInfo
    ResolveDataInputStreamMethod "read" o = Gio.InputStream.InputStreamReadMethodInfo
    ResolveDataInputStreamMethod "readAll" o = Gio.InputStream.InputStreamReadAllMethodInfo
    ResolveDataInputStreamMethod "readAllAsync" o = Gio.InputStream.InputStreamReadAllAsyncMethodInfo
    ResolveDataInputStreamMethod "readAllFinish" o = Gio.InputStream.InputStreamReadAllFinishMethodInfo
    ResolveDataInputStreamMethod "readAsync" o = Gio.InputStream.InputStreamReadAsyncMethodInfo
    ResolveDataInputStreamMethod "readByte" o = DataInputStreamReadByteMethodInfo
    ResolveDataInputStreamMethod "readBytes" o = Gio.InputStream.InputStreamReadBytesMethodInfo
    ResolveDataInputStreamMethod "readBytesAsync" o = Gio.InputStream.InputStreamReadBytesAsyncMethodInfo
    ResolveDataInputStreamMethod "readBytesFinish" o = Gio.InputStream.InputStreamReadBytesFinishMethodInfo
    ResolveDataInputStreamMethod "readFinish" o = Gio.InputStream.InputStreamReadFinishMethodInfo
    ResolveDataInputStreamMethod "readInt16" o = DataInputStreamReadInt16MethodInfo
    ResolveDataInputStreamMethod "readInt32" o = DataInputStreamReadInt32MethodInfo
    ResolveDataInputStreamMethod "readInt64" o = DataInputStreamReadInt64MethodInfo
    ResolveDataInputStreamMethod "readLine" o = DataInputStreamReadLineMethodInfo
    ResolveDataInputStreamMethod "readLineAsync" o = DataInputStreamReadLineAsyncMethodInfo
    ResolveDataInputStreamMethod "readLineFinish" o = DataInputStreamReadLineFinishMethodInfo
    ResolveDataInputStreamMethod "readLineFinishUtf8" o = DataInputStreamReadLineFinishUtf8MethodInfo
    ResolveDataInputStreamMethod "readLineUtf8" o = DataInputStreamReadLineUtf8MethodInfo
    ResolveDataInputStreamMethod "readUint16" o = DataInputStreamReadUint16MethodInfo
    ResolveDataInputStreamMethod "readUint32" o = DataInputStreamReadUint32MethodInfo
    ResolveDataInputStreamMethod "readUint64" o = DataInputStreamReadUint64MethodInfo
    ResolveDataInputStreamMethod "readUntil" o = DataInputStreamReadUntilMethodInfo
    ResolveDataInputStreamMethod "readUntilAsync" o = DataInputStreamReadUntilAsyncMethodInfo
    ResolveDataInputStreamMethod "readUntilFinish" o = DataInputStreamReadUntilFinishMethodInfo
    ResolveDataInputStreamMethod "readUpto" o = DataInputStreamReadUptoMethodInfo
    ResolveDataInputStreamMethod "readUptoAsync" o = DataInputStreamReadUptoAsyncMethodInfo
    ResolveDataInputStreamMethod "readUptoFinish" o = DataInputStreamReadUptoFinishMethodInfo
    ResolveDataInputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDataInputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDataInputStreamMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDataInputStreamMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDataInputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDataInputStreamMethod "seek" o = Gio.Seekable.SeekableSeekMethodInfo
    ResolveDataInputStreamMethod "skip" o = Gio.InputStream.InputStreamSkipMethodInfo
    ResolveDataInputStreamMethod "skipAsync" o = Gio.InputStream.InputStreamSkipAsyncMethodInfo
    ResolveDataInputStreamMethod "skipFinish" o = Gio.InputStream.InputStreamSkipFinishMethodInfo
    ResolveDataInputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDataInputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDataInputStreamMethod "tell" o = Gio.Seekable.SeekableTellMethodInfo
    ResolveDataInputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDataInputStreamMethod "truncate" o = Gio.Seekable.SeekableTruncateMethodInfo
    ResolveDataInputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDataInputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDataInputStreamMethod "getAvailable" o = Gio.BufferedInputStream.BufferedInputStreamGetAvailableMethodInfo
    ResolveDataInputStreamMethod "getBaseStream" o = Gio.FilterInputStream.FilterInputStreamGetBaseStreamMethodInfo
    ResolveDataInputStreamMethod "getBufferSize" o = Gio.BufferedInputStream.BufferedInputStreamGetBufferSizeMethodInfo
    ResolveDataInputStreamMethod "getByteOrder" o = DataInputStreamGetByteOrderMethodInfo
    ResolveDataInputStreamMethod "getCloseBaseStream" o = Gio.FilterInputStream.FilterInputStreamGetCloseBaseStreamMethodInfo
    ResolveDataInputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDataInputStreamMethod "getNewlineType" o = DataInputStreamGetNewlineTypeMethodInfo
    ResolveDataInputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDataInputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDataInputStreamMethod "setBufferSize" o = Gio.BufferedInputStream.BufferedInputStreamSetBufferSizeMethodInfo
    ResolveDataInputStreamMethod "setByteOrder" o = DataInputStreamSetByteOrderMethodInfo
    ResolveDataInputStreamMethod "setCloseBaseStream" o = Gio.FilterInputStream.FilterInputStreamSetCloseBaseStreamMethodInfo
    ResolveDataInputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDataInputStreamMethod "setNewlineType" o = DataInputStreamSetNewlineTypeMethodInfo
    ResolveDataInputStreamMethod "setPending" o = Gio.InputStream.InputStreamSetPendingMethodInfo
    ResolveDataInputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDataInputStreamMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDataInputStreamMethod t DataInputStream, O.MethodInfo info DataInputStream p) => O.IsLabelProxy t (DataInputStream -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDataInputStreamMethod t DataInputStream, O.MethodInfo info DataInputStream p) => O.IsLabel t (DataInputStream -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "byte-order"
   -- Type: TInterface (Name {namespace = "Gio", name = "DataStreamByteOrder"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> m Gio.Enums.DataStreamByteOrder
getDataInputStreamByteOrder obj = liftIO $ getObjectPropertyEnum obj "byte-order"

setDataInputStreamByteOrder :: (MonadIO m, IsDataInputStream o) => o -> Gio.Enums.DataStreamByteOrder -> m ()
setDataInputStreamByteOrder obj val = liftIO $ setObjectPropertyEnum obj "byte-order" val

constructDataInputStreamByteOrder :: (IsDataInputStream o) => Gio.Enums.DataStreamByteOrder -> IO (GValueConstruct o)
constructDataInputStreamByteOrder val = constructObjectPropertyEnum "byte-order" val

data DataInputStreamByteOrderPropertyInfo
instance AttrInfo DataInputStreamByteOrderPropertyInfo where
    type AttrAllowedOps DataInputStreamByteOrderPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DataInputStreamByteOrderPropertyInfo = (~) Gio.Enums.DataStreamByteOrder
    type AttrBaseTypeConstraint DataInputStreamByteOrderPropertyInfo = IsDataInputStream
    type AttrGetType DataInputStreamByteOrderPropertyInfo = Gio.Enums.DataStreamByteOrder
    type AttrLabel DataInputStreamByteOrderPropertyInfo = "byte-order"
    type AttrOrigin DataInputStreamByteOrderPropertyInfo = DataInputStream
    attrGet _ = getDataInputStreamByteOrder
    attrSet _ = setDataInputStreamByteOrder
    attrConstruct _ = constructDataInputStreamByteOrder
    attrClear _ = undefined

-- VVV Prop "newline-type"
   -- Type: TInterface (Name {namespace = "Gio", name = "DataStreamNewlineType"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getDataInputStreamNewlineType :: (MonadIO m, IsDataInputStream o) => o -> m Gio.Enums.DataStreamNewlineType
getDataInputStreamNewlineType obj = liftIO $ getObjectPropertyEnum obj "newline-type"

setDataInputStreamNewlineType :: (MonadIO m, IsDataInputStream o) => o -> Gio.Enums.DataStreamNewlineType -> m ()
setDataInputStreamNewlineType obj val = liftIO $ setObjectPropertyEnum obj "newline-type" val

constructDataInputStreamNewlineType :: (IsDataInputStream o) => Gio.Enums.DataStreamNewlineType -> IO (GValueConstruct o)
constructDataInputStreamNewlineType val = constructObjectPropertyEnum "newline-type" val

data DataInputStreamNewlineTypePropertyInfo
instance AttrInfo DataInputStreamNewlineTypePropertyInfo where
    type AttrAllowedOps DataInputStreamNewlineTypePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DataInputStreamNewlineTypePropertyInfo = (~) Gio.Enums.DataStreamNewlineType
    type AttrBaseTypeConstraint DataInputStreamNewlineTypePropertyInfo = IsDataInputStream
    type AttrGetType DataInputStreamNewlineTypePropertyInfo = Gio.Enums.DataStreamNewlineType
    type AttrLabel DataInputStreamNewlineTypePropertyInfo = "newline-type"
    type AttrOrigin DataInputStreamNewlineTypePropertyInfo = DataInputStream
    attrGet _ = getDataInputStreamNewlineType
    attrSet _ = setDataInputStreamNewlineType
    attrConstruct _ = constructDataInputStreamNewlineType
    attrClear _ = undefined

instance O.HasAttributeList DataInputStream
type instance O.AttributeList DataInputStream = DataInputStreamAttributeList
type DataInputStreamAttributeList = ('[ '("baseStream", Gio.FilterInputStream.FilterInputStreamBaseStreamPropertyInfo), '("bufferSize", Gio.BufferedInputStream.BufferedInputStreamBufferSizePropertyInfo), '("byteOrder", DataInputStreamByteOrderPropertyInfo), '("closeBaseStream", Gio.FilterInputStream.FilterInputStreamCloseBaseStreamPropertyInfo), '("newlineType", DataInputStreamNewlineTypePropertyInfo)] :: [(Symbol, *)])

dataInputStreamByteOrder :: AttrLabelProxy "byteOrder"
dataInputStreamByteOrder = AttrLabelProxy

dataInputStreamNewlineType :: AttrLabelProxy "newlineType"
dataInputStreamNewlineType = AttrLabelProxy

type instance O.SignalList DataInputStream = DataInputStreamSignalList
type DataInputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method DataInputStream::new
-- method type : Constructor
-- Args : [Arg {argCName = "base_stream", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DataInputStream"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_new" g_data_input_stream_new :: 
    Ptr Gio.InputStream.InputStream ->      -- base_stream : TInterface (Name {namespace = "Gio", name = "InputStream"})
    IO (Ptr DataInputStream)

{- |
Creates a new data input stream for the /@baseStream@/.
-}
dataInputStreamNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a) =>
    a
    {- ^ /@baseStream@/: a 'GI.Gio.Objects.InputStream.InputStream'. -}
    -> m DataInputStream
    {- ^ __Returns:__ a new 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
dataInputStreamNew baseStream = liftIO $ do
    baseStream' <- unsafeManagedPtrCastPtr baseStream
    result <- g_data_input_stream_new baseStream'
    checkUnexpectedReturnNULL "dataInputStreamNew" result
    result' <- (wrapObject DataInputStream) result
    touchManagedPtr baseStream
    return result'

-- method DataInputStream::get_byte_order
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DataStreamByteOrder"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_get_byte_order" g_data_input_stream_get_byte_order :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    IO CUInt

{- |
Gets the byte order for the data input stream.
-}
dataInputStreamGetByteOrder ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> m Gio.Enums.DataStreamByteOrder
    {- ^ __Returns:__ the /@stream@/\'s current 'GI.Gio.Enums.DataStreamByteOrder'. -}
dataInputStreamGetByteOrder stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result <- g_data_input_stream_get_byte_order stream'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr stream
    return result'

data DataInputStreamGetByteOrderMethodInfo
instance (signature ~ (m Gio.Enums.DataStreamByteOrder), MonadIO m, IsDataInputStream a) => O.MethodInfo DataInputStreamGetByteOrderMethodInfo a signature where
    overloadedMethod _ = dataInputStreamGetByteOrder

-- method DataInputStream::get_newline_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DataStreamNewlineType"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_get_newline_type" g_data_input_stream_get_newline_type :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    IO CUInt

{- |
Gets the current newline type for the /@stream@/.
-}
dataInputStreamGetNewlineType ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> m Gio.Enums.DataStreamNewlineType
    {- ^ __Returns:__ 'GI.Gio.Enums.DataStreamNewlineType' for the given /@stream@/. -}
dataInputStreamGetNewlineType stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result <- g_data_input_stream_get_newline_type stream'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr stream
    return result'

data DataInputStreamGetNewlineTypeMethodInfo
instance (signature ~ (m Gio.Enums.DataStreamNewlineType), MonadIO m, IsDataInputStream a) => O.MethodInfo DataInputStreamGetNewlineTypeMethodInfo a signature where
    overloadedMethod _ = dataInputStreamGetNewlineType

-- method DataInputStream::read_byte
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_byte" g_data_input_stream_read_byte :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Word8

{- |
Reads an unsigned 8-bit\/1-byte value from /@stream@/.
-}
dataInputStreamReadByte ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadByte stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_byte stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadByteMethodInfo
instance (signature ~ (Maybe (b) -> m Word8), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadByteMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadByte

-- method DataInputStream::read_int16
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt16)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_int16" g_data_input_stream_read_int16 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Int16

{- |
Reads a 16-bit\/2-byte value from /@stream@/.

In order to get the correct byte order for this read operation,
see 'GI.Gio.Objects.DataInputStream.dataInputStreamGetByteOrder' and 'GI.Gio.Objects.DataInputStream.dataInputStreamSetByteOrder'.
-}
dataInputStreamReadInt16 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadInt16 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_int16 stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadInt16MethodInfo
instance (signature ~ (Maybe (b) -> m Int16), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadInt16MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadInt16

-- method DataInputStream::read_int32
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt32)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_int32" g_data_input_stream_read_int32 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Int32

{- |
Reads a signed 32-bit\/4-byte value from /@stream@/.

In order to get the correct byte order for this read operation,
see 'GI.Gio.Objects.DataInputStream.dataInputStreamGetByteOrder' and 'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
dataInputStreamReadInt32 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadInt32 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_int32 stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadInt32MethodInfo
instance (signature ~ (Maybe (b) -> m Int32), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadInt32MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadInt32

-- method DataInputStream::read_int64
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_int64" g_data_input_stream_read_int64 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Int64

{- |
Reads a 64-bit\/8-byte value from /@stream@/.

In order to get the correct byte order for this read operation,
see 'GI.Gio.Objects.DataInputStream.dataInputStreamGetByteOrder' and 'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
dataInputStreamReadInt64 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadInt64 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_int64 stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadInt64MethodInfo
instance (signature ~ (Maybe (b) -> m Int64), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadInt64MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadInt64

-- method DataInputStream::read_line
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUInt8))
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_line" g_data_input_stream_read_line :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Word8)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
dataInputStreamReadLine ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadLine stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    length_ <- allocMem :: IO (Ptr Word64)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_line stream' length_ maybeCancellable
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- unpackZeroTerminatedByteString result'
            freeMem result'
            return result''
        length_' <- peek length_
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        freeMem length_
        return (maybeResult, length_')
     ) (do
        freeMem length_
     )

data DataInputStreamReadLineMethodInfo
instance (signature ~ (Maybe (b) -> m ((Maybe ByteString),Word64)), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadLineMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadLine

-- method DataInputStream::read_line_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback to call when the request is satisfied.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_read_line_async" g_data_input_stream_read_line_async :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
The asynchronous version of 'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Objects.DataInputStream.dataInputStreamReadLineFinish' to get
the result of the operation.

@since 2.20
-}
dataInputStreamReadLineAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: callback to call when the request is satisfied. -}
    -> m ()
dataInputStreamReadLineAsync stream ioPriority cancellable callback = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_data_input_stream_read_line_async stream' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr stream
    whenJust cancellable touchManagedPtr
    return ()

data DataInputStreamReadLineAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadLineAsyncMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadLineAsync

-- method DataInputStream::read_line_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult that was provided to the callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUInt8))
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_line_finish" g_data_input_stream_read_line_finish :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Word8)

{- |
Finish an asynchronous call started by
'GI.Gio.Objects.DataInputStream.dataInputStreamReadLineAsync'.  Note the warning about
string encoding in 'GI.Gio.Objects.DataInputStream.dataInputStreamReadLine' applies here as
well.

@since 2.20
-}
dataInputStreamReadLineFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadLineFinish stream result_ = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result_' <- unsafeManagedPtrCastPtr result_
    length_ <- allocMem :: IO (Ptr Word64)
    onException (do
        result <- propagateGError $ g_data_input_stream_read_line_finish stream' result_' length_
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- unpackZeroTerminatedByteString result'
            freeMem result'
            return result''
        length_' <- peek length_
        touchManagedPtr stream
        touchManagedPtr result_
        freeMem length_
        return (maybeResult, length_')
     ) (do
        freeMem length_
     )

data DataInputStreamReadLineFinishMethodInfo
instance (signature ~ (b -> m ((Maybe ByteString),Word64)), MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DataInputStreamReadLineFinishMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadLineFinish

-- method DataInputStream::read_line_finish_utf8
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult that was provided to the callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_line_finish_utf8" g_data_input_stream_read_line_finish_utf8 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
Finish an asynchronous call started by
'GI.Gio.Objects.DataInputStream.dataInputStreamReadLineAsync'.

@since 2.30
-}
dataInputStreamReadLineFinishUtf8 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' that was provided to the callback. -}
    -> m ((Maybe T.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadLineFinishUtf8 stream result_ = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result_' <- unsafeManagedPtrCastPtr result_
    length_ <- allocMem :: IO (Ptr Word64)
    onException (do
        result <- propagateGError $ g_data_input_stream_read_line_finish_utf8 stream' result_' length_
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- cstringToText result'
            freeMem result'
            return result''
        length_' <- peek length_
        touchManagedPtr stream
        touchManagedPtr result_
        freeMem length_
        return (maybeResult, length_')
     ) (do
        freeMem length_
     )

data DataInputStreamReadLineFinishUtf8MethodInfo
instance (signature ~ (b -> m ((Maybe T.Text),Word64)), MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DataInputStreamReadLineFinishUtf8MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadLineFinishUtf8

-- method DataInputStream::read_line_utf8
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_line_utf8" g_data_input_stream_read_line_utf8 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

@since 2.30
-}
dataInputStreamReadLineUtf8 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> m ((Maybe T.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadLineUtf8 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    length_ <- allocMem :: IO (Ptr Word64)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_line_utf8 stream' length_ maybeCancellable
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- cstringToText result'
            freeMem result'
            return result''
        length_' <- peek length_
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        freeMem length_
        return (maybeResult, length_')
     ) (do
        freeMem length_
     )

data DataInputStreamReadLineUtf8MethodInfo
instance (signature ~ (Maybe (b) -> m ((Maybe T.Text),Word64)), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadLineUtf8MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadLineUtf8

-- method DataInputStream::read_uint16
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt16)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_uint16" g_data_input_stream_read_uint16 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Word16

{- |
Reads an unsigned 16-bit\/2-byte value from /@stream@/.

In order to get the correct byte order for this read operation,
see 'GI.Gio.Objects.DataInputStream.dataInputStreamGetByteOrder' and 'GI.Gio.Objects.DataInputStream.dataInputStreamSetByteOrder'.
-}
dataInputStreamReadUint16 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUint16 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_uint16 stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadUint16MethodInfo
instance (signature ~ (Maybe (b) -> m Word16), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUint16MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUint16

-- method DataInputStream::read_uint32
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt32)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_uint32" g_data_input_stream_read_uint32 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Word32

{- |
Reads an unsigned 32-bit\/4-byte value from /@stream@/.

In order to get the correct byte order for this read operation,
see 'GI.Gio.Objects.DataInputStream.dataInputStreamGetByteOrder' and 'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
dataInputStreamReadUint32 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUint32 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_uint32 stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadUint32MethodInfo
instance (signature ~ (Maybe (b) -> m Word32), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUint32MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUint32

-- method DataInputStream::read_uint64
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_uint64" g_data_input_stream_read_uint64 :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Word64

{- |
Reads an unsigned 64-bit\/8-byte value from /@stream@/.

In order to get the correct byte order for this read operation,
see 'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
dataInputStreamReadUint64 ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUint64 stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_uint64 stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

data DataInputStreamReadUint64MethodInfo
instance (signature ~ (Maybe (b) -> m Word64), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUint64MethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUint64

-- method DataInputStream::read_until
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_chars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "characters to terminate the read.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_until" g_data_input_stream_read_until :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    CString ->                              -- stop_chars : TBasicType TUTF8
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

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

Note that, in contrast to 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUntilAsync',
this function consumes the stop character that it finds.

Don\'t use this function in new code.  Its functionality is
inconsistent with 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUntilAsync'.  Both
functions will be marked as deprecated in a future release.  Use
'GI.Gio.Objects.DataInputStream.dataInputStreamReadUpto' instead, but note that that function
does not consume the stop character.
-}
dataInputStreamReadUntil ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> T.Text
    {- ^ /@stopChars@/: characters to terminate the read. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> m (T.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUntil stream stopChars cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    stopChars' <- textToCString stopChars
    length_ <- allocMem :: IO (Ptr Word64)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_until stream' stopChars' length_ maybeCancellable
        checkUnexpectedReturnNULL "dataInputStreamReadUntil" result
        result' <- cstringToText result
        freeMem result
        length_' <- peek length_
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        freeMem stopChars'
        freeMem length_
        return (result', length_')
     ) (do
        freeMem stopChars'
        freeMem length_
     )

data DataInputStreamReadUntilMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m (T.Text,Word64)), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUntilMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUntil

-- method DataInputStream::read_until_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_chars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "characters to terminate the read.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback to call when the request is satisfied.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_read_until_async" g_data_input_stream_read_until_async :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    CString ->                              -- stop_chars : TBasicType TUTF8
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
The asynchronous version of 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUntil'.
It is an error to have two outstanding calls to this function.

Note that, in contrast to 'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUntilFinish' to get
the result of the operation.

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

@since 2.20
-}
dataInputStreamReadUntilAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> T.Text
    {- ^ /@stopChars@/: characters to terminate the read. -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: callback to call when the request is satisfied. -}
    -> m ()
dataInputStreamReadUntilAsync stream stopChars ioPriority cancellable callback = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    stopChars' <- textToCString stopChars
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_data_input_stream_read_until_async stream' stopChars' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr stream
    whenJust cancellable touchManagedPtr
    freeMem stopChars'
    return ()

data DataInputStreamReadUntilAsyncMethodInfo
instance (signature ~ (T.Text -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUntilAsyncMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUntilAsync

-- method DataInputStream::read_until_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult that was provided to the callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_until_finish" g_data_input_stream_read_until_finish :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
Finish an asynchronous call started by
'GI.Gio.Objects.DataInputStream.dataInputStreamReadUntilAsync'.

@since 2.20
-}
dataInputStreamReadUntilFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' that was provided to the callback. -}
    -> m (T.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUntilFinish stream result_ = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result_' <- unsafeManagedPtrCastPtr result_
    length_ <- allocMem :: IO (Ptr Word64)
    onException (do
        result <- propagateGError $ g_data_input_stream_read_until_finish stream' result_' length_
        checkUnexpectedReturnNULL "dataInputStreamReadUntilFinish" result
        result' <- cstringToText result
        freeMem result
        length_' <- peek length_
        touchManagedPtr stream
        touchManagedPtr result_
        freeMem length_
        return (result', length_')
     ) (do
        freeMem length_
     )

data DataInputStreamReadUntilFinishMethodInfo
instance (signature ~ (b -> m (T.Text,Word64)), MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DataInputStreamReadUntilFinishMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUntilFinish

-- method DataInputStream::read_upto
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDataInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_chars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "characters to terminate the read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_chars_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @stop_chars. May be -1 if @stop_chars is\n    nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_upto" g_data_input_stream_read_upto :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    CString ->                              -- stop_chars : TBasicType TUTF8
    Int64 ->                                -- stop_chars_len : TBasicType TInt64
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

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

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

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

@since 2.26
-}
dataInputStreamReadUpto ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.DataInputStream.DataInputStream' -}
    -> T.Text
    {- ^ /@stopChars@/: characters to terminate the read -}
    -> Int64
    {- ^ /@stopCharsLen@/: length of /@stopChars@/. May be -1 if /@stopChars@/ is
    nul-terminated -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> m (T.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUpto stream stopChars stopCharsLen cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    stopChars' <- textToCString stopChars
    length_ <- allocMem :: IO (Ptr Word64)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_data_input_stream_read_upto stream' stopChars' stopCharsLen length_ maybeCancellable
        checkUnexpectedReturnNULL "dataInputStreamReadUpto" result
        result' <- cstringToText result
        freeMem result
        length_' <- peek length_
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        freeMem stopChars'
        freeMem length_
        return (result', length_')
     ) (do
        freeMem stopChars'
        freeMem length_
     )

data DataInputStreamReadUptoMethodInfo
instance (signature ~ (T.Text -> Int64 -> Maybe (b) -> m (T.Text,Word64)), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUptoMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUpto

-- method DataInputStream::read_upto_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDataInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_chars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "characters to terminate the read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_chars_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @stop_chars. May be -1 if @stop_chars is\n    nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback to call when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 6, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_read_upto_async" g_data_input_stream_read_upto_async :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    CString ->                              -- stop_chars : TBasicType TUTF8
    Int64 ->                                -- stop_chars_len : TBasicType TInt64
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
The asynchronous version of 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUpto'.
It is an error to have two outstanding calls to this function.

In contrast to 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUntil', this function
does not consume the stop character. You have to use
'GI.Gio.Objects.DataInputStream.dataInputStreamReadByte' to get it before calling
'GI.Gio.Objects.DataInputStream.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 'GI.Gio.Objects.DataInputStream.dataInputStreamReadUptoFinish' to get
the result of the operation.

@since 2.26
-}
dataInputStreamReadUptoAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.DataInputStream.DataInputStream' -}
    -> T.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 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: callback to call when the request is satisfied -}
    -> m ()
dataInputStreamReadUptoAsync stream stopChars stopCharsLen ioPriority cancellable callback = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    stopChars' <- textToCString stopChars
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_data_input_stream_read_upto_async stream' stopChars' stopCharsLen ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr stream
    whenJust cancellable touchManagedPtr
    freeMem stopChars'
    return ()

data DataInputStreamReadUptoAsyncMethodInfo
instance (signature ~ (T.Text -> Int64 -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDataInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DataInputStreamReadUptoAsyncMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUptoAsync

-- method DataInputStream::read_upto_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDataInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult that was provided to the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the length of the data read in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_data_input_stream_read_upto_finish" g_data_input_stream_read_upto_finish :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
Finish an asynchronous call started by
'GI.Gio.Objects.DataInputStream.dataInputStreamReadUptoAsync'.

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

@since 2.24
-}
dataInputStreamReadUptoFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.DataInputStream.DataInputStream' -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' that was provided to the callback -}
    -> m (T.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 'Data.GI.Base.GError.GError')/ -}
dataInputStreamReadUptoFinish stream result_ = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result_' <- unsafeManagedPtrCastPtr result_
    length_ <- allocMem :: IO (Ptr Word64)
    onException (do
        result <- propagateGError $ g_data_input_stream_read_upto_finish stream' result_' length_
        checkUnexpectedReturnNULL "dataInputStreamReadUptoFinish" result
        result' <- cstringToText result
        freeMem result
        length_' <- peek length_
        touchManagedPtr stream
        touchManagedPtr result_
        freeMem length_
        return (result', length_')
     ) (do
        freeMem length_
     )

data DataInputStreamReadUptoFinishMethodInfo
instance (signature ~ (b -> m (T.Text,Word64)), MonadIO m, IsDataInputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DataInputStreamReadUptoFinishMethodInfo a signature where
    overloadedMethod _ = dataInputStreamReadUptoFinish

-- method DataInputStream::set_byte_order
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "order", argType = TInterface (Name {namespace = "Gio", name = "DataStreamByteOrder"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDataStreamByteOrder to set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_set_byte_order" g_data_input_stream_set_byte_order :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    CUInt ->                                -- order : TInterface (Name {namespace = "Gio", name = "DataStreamByteOrder"})
    IO ()

{- |
This function sets the byte order for the given /@stream@/. All subsequent
reads from the /@stream@/ will be read in the given /@order@/.
-}
dataInputStreamSetByteOrder ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a) =>
    a
    {- ^ /@stream@/: a given 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Gio.Enums.DataStreamByteOrder
    {- ^ /@order@/: a 'GI.Gio.Enums.DataStreamByteOrder' to set. -}
    -> m ()
dataInputStreamSetByteOrder stream order = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    let order' = (fromIntegral . fromEnum) order
    g_data_input_stream_set_byte_order stream' order'
    touchManagedPtr stream
    return ()

data DataInputStreamSetByteOrderMethodInfo
instance (signature ~ (Gio.Enums.DataStreamByteOrder -> m ()), MonadIO m, IsDataInputStream a) => O.MethodInfo DataInputStreamSetByteOrderMethodInfo a signature where
    overloadedMethod _ = dataInputStreamSetByteOrder

-- method DataInputStream::set_newline_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "DataInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDataInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Gio", name = "DataStreamNewlineType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of new line return as #GDataStreamNewlineType.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_data_input_stream_set_newline_type" g_data_input_stream_set_newline_type :: 
    Ptr DataInputStream ->                  -- stream : TInterface (Name {namespace = "Gio", name = "DataInputStream"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Gio", name = "DataStreamNewlineType"})
    IO ()

{- |
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.
-}
dataInputStreamSetNewlineType ::
    (B.CallStack.HasCallStack, MonadIO m, IsDataInputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.DataInputStream.DataInputStream'. -}
    -> Gio.Enums.DataStreamNewlineType
    {- ^ /@type@/: the type of new line return as 'GI.Gio.Enums.DataStreamNewlineType'. -}
    -> m ()
dataInputStreamSetNewlineType stream type_ = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    let type_' = (fromIntegral . fromEnum) type_
    g_data_input_stream_set_newline_type stream' type_'
    touchManagedPtr stream
    return ()

data DataInputStreamSetNewlineTypeMethodInfo
instance (signature ~ (Gio.Enums.DataStreamNewlineType -> m ()), MonadIO m, IsDataInputStream a) => O.MethodInfo DataInputStreamSetNewlineTypeMethodInfo a signature where
    overloadedMethod _ = dataInputStreamSetNewlineType