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

    Base class for input stream implementations that perform some
    kind of filtering operation on a base stream. Typical examples
    of filtering operations are character set conversion, compression
    and byte order flipping.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Gio.Objects.FilterInputStream
        (

    -- * Exported types
        FilterInputStream(..)                   ,
        IsFilterInputStream                     ,
        toFilterInputStream                     ,
        noFilterInputStream                     ,

     -- * Methods
    -- ** getBaseStream #method:getBaseStream#

    #if ENABLE_OVERLOADING
        FilterInputStreamGetBaseStreamMethodInfo,
    #endif
        filterInputStreamGetBaseStream          ,

    -- ** getCloseBaseStream #method:getCloseBaseStream#

    #if ENABLE_OVERLOADING
        FilterInputStreamGetCloseBaseStreamMethodInfo,
    #endif
        filterInputStreamGetCloseBaseStream     ,

    -- ** setCloseBaseStream #method:setCloseBaseStream#

    #if ENABLE_OVERLOADING
        FilterInputStreamSetCloseBaseStreamMethodInfo,
    #endif
        filterInputStreamSetCloseBaseStream     ,

     -- * Properties
    -- ** baseStream #attr:baseStream#
    {- | /No description available in the introspection data./
    -}
    #if ENABLE_OVERLOADING
        FilterInputStreamBaseStreamPropertyInfo ,
    #endif
        constructFilterInputStreamBaseStream    ,
    #if ENABLE_OVERLOADING
        filterInputStreamBaseStream             ,
    #endif
        getFilterInputStreamBaseStream          ,

    -- ** closeBaseStream #attr:closeBaseStream#
    {- | /No description available in the introspection data./
    -}
    #if ENABLE_OVERLOADING
        FilterInputStreamCloseBaseStreamPropertyInfo,
    #endif
        constructFilterInputStreamCloseBaseStream,
    #if ENABLE_OVERLOADING
        filterInputStreamCloseBaseStream        ,
    #endif
        getFilterInputStreamCloseBaseStream     ,
        setFilterInputStreamCloseBaseStream     ,

        ) 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.GValue as B.GValue
    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 {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream

    -- | Memory-managed wrapper type.
    newtype FilterInputStream = FilterInputStream (ManagedPtr FilterInputStream)
    foreign import ccall "g_filter_input_stream_get_type"
        c_g_filter_input_stream_get_type :: IO GType

    instance GObject FilterInputStream where
        gobjectType _ = c_g_filter_input_stream_get_type

    -- | Type class for types which can be safely cast to `FilterInputStream`, for instance with `toFilterInputStream`.
    class GObject o => IsFilterInputStream o
    #if MIN_VERSION_base(4,9,0)
    instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError FilterInputStream a) =>
        IsFilterInputStream a
    #endif
    instance IsFilterInputStream FilterInputStream
    instance Gio.InputStream.IsInputStream FilterInputStream
    instance GObject.Object.IsObject FilterInputStream

    -- | Cast to `FilterInputStream`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
    toFilterInputStream :: (MonadIO m, IsFilterInputStream o) => o -> m FilterInputStream
    toFilterInputStream = liftIO . unsafeCastTo FilterInputStream

    -- | A convenience alias for `Nothing` :: `Maybe` `FilterInputStream`.
    noFilterInputStream :: Maybe FilterInputStream
    noFilterInputStream = Nothing

    #if ENABLE_OVERLOADING
    type family ResolveFilterInputStreamMethod (t :: Symbol) (o :: *) :: * where
        ResolveFilterInputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
        ResolveFilterInputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
        ResolveFilterInputStreamMethod "clearPending" o = Gio.InputStream.InputStreamClearPendingMethodInfo
        ResolveFilterInputStreamMethod "close" o = Gio.InputStream.InputStreamCloseMethodInfo
        ResolveFilterInputStreamMethod "closeAsync" o = Gio.InputStream.InputStreamCloseAsyncMethodInfo
        ResolveFilterInputStreamMethod "closeFinish" o = Gio.InputStream.InputStreamCloseFinishMethodInfo
        ResolveFilterInputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
        ResolveFilterInputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
        ResolveFilterInputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
        ResolveFilterInputStreamMethod "hasPending" o = Gio.InputStream.InputStreamHasPendingMethodInfo
        ResolveFilterInputStreamMethod "isClosed" o = Gio.InputStream.InputStreamIsClosedMethodInfo
        ResolveFilterInputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
        ResolveFilterInputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
        ResolveFilterInputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
        ResolveFilterInputStreamMethod "read" o = Gio.InputStream.InputStreamReadMethodInfo
        ResolveFilterInputStreamMethod "readAll" o = Gio.InputStream.InputStreamReadAllMethodInfo
        ResolveFilterInputStreamMethod "readAllAsync" o = Gio.InputStream.InputStreamReadAllAsyncMethodInfo
        ResolveFilterInputStreamMethod "readAllFinish" o = Gio.InputStream.InputStreamReadAllFinishMethodInfo
        ResolveFilterInputStreamMethod "readAsync" o = Gio.InputStream.InputStreamReadAsyncMethodInfo
        ResolveFilterInputStreamMethod "readBytes" o = Gio.InputStream.InputStreamReadBytesMethodInfo
        ResolveFilterInputStreamMethod "readBytesAsync" o = Gio.InputStream.InputStreamReadBytesAsyncMethodInfo
        ResolveFilterInputStreamMethod "readBytesFinish" o = Gio.InputStream.InputStreamReadBytesFinishMethodInfo
        ResolveFilterInputStreamMethod "readFinish" o = Gio.InputStream.InputStreamReadFinishMethodInfo
        ResolveFilterInputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
        ResolveFilterInputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
        ResolveFilterInputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
        ResolveFilterInputStreamMethod "skip" o = Gio.InputStream.InputStreamSkipMethodInfo
        ResolveFilterInputStreamMethod "skipAsync" o = Gio.InputStream.InputStreamSkipAsyncMethodInfo
        ResolveFilterInputStreamMethod "skipFinish" o = Gio.InputStream.InputStreamSkipFinishMethodInfo
        ResolveFilterInputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
        ResolveFilterInputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
        ResolveFilterInputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
        ResolveFilterInputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
        ResolveFilterInputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
        ResolveFilterInputStreamMethod "getBaseStream" o = FilterInputStreamGetBaseStreamMethodInfo
        ResolveFilterInputStreamMethod "getCloseBaseStream" o = FilterInputStreamGetCloseBaseStreamMethodInfo
        ResolveFilterInputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
        ResolveFilterInputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
        ResolveFilterInputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
        ResolveFilterInputStreamMethod "setCloseBaseStream" o = FilterInputStreamSetCloseBaseStreamMethodInfo
        ResolveFilterInputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
        ResolveFilterInputStreamMethod "setPending" o = Gio.InputStream.InputStreamSetPendingMethodInfo
        ResolveFilterInputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
        ResolveFilterInputStreamMethod l o = O.MethodResolutionFailed l o

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

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

    #endif

    -- VVV Prop "base-stream"
       -- Type: TInterface (Name {namespace = "Gio", name = "InputStream"})
       -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
       -- Nullable: (Just False,Nothing)

    {- |
    Get the value of the “@base-stream@” property.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Attributes.get' filterInputStream #baseStream
    @
    -}
    getFilterInputStreamBaseStream :: (MonadIO m, IsFilterInputStream o) => o -> m Gio.InputStream.InputStream
    getFilterInputStreamBaseStream obj = liftIO $ checkUnexpectedNothing "getFilterInputStreamBaseStream" $ getObjectPropertyObject obj "base-stream" Gio.InputStream.InputStream

    {- |
    Construct a `GValueConstruct` with valid value for the “@base-stream@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
    -}
    constructFilterInputStreamBaseStream :: (IsFilterInputStream o, Gio.InputStream.IsInputStream a) => a -> IO (GValueConstruct o)
    constructFilterInputStreamBaseStream val = constructObjectPropertyObject "base-stream" (Just val)

    #if ENABLE_OVERLOADING
    data FilterInputStreamBaseStreamPropertyInfo
    instance AttrInfo FilterInputStreamBaseStreamPropertyInfo where
        type AttrAllowedOps FilterInputStreamBaseStreamPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint FilterInputStreamBaseStreamPropertyInfo = Gio.InputStream.IsInputStream
        type AttrBaseTypeConstraint FilterInputStreamBaseStreamPropertyInfo = IsFilterInputStream
        type AttrGetType FilterInputStreamBaseStreamPropertyInfo = Gio.InputStream.InputStream
        type AttrLabel FilterInputStreamBaseStreamPropertyInfo = "base-stream"
        type AttrOrigin FilterInputStreamBaseStreamPropertyInfo = FilterInputStream
        attrGet _ = getFilterInputStreamBaseStream
        attrSet _ = undefined
        attrConstruct _ = constructFilterInputStreamBaseStream
        attrClear _ = undefined
    #endif

    -- VVV Prop "close-base-stream"
       -- Type: TBasicType TBoolean
       -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
       -- Nullable: (Just False,Just False)

    {- |
    Get the value of the “@close-base-stream@” property.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Attributes.get' filterInputStream #closeBaseStream
    @
    -}
    getFilterInputStreamCloseBaseStream :: (MonadIO m, IsFilterInputStream o) => o -> m Bool
    getFilterInputStreamCloseBaseStream obj = liftIO $ getObjectPropertyBool obj "close-base-stream"

    {- |
    Set the value of the “@close-base-stream@” property.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Attributes.set' filterInputStream [ #closeBaseStream 'Data.GI.Base.Attributes.:=' value ]
    @
    -}
    setFilterInputStreamCloseBaseStream :: (MonadIO m, IsFilterInputStream o) => o -> Bool -> m ()
    setFilterInputStreamCloseBaseStream obj val = liftIO $ setObjectPropertyBool obj "close-base-stream" val

    {- |
    Construct a `GValueConstruct` with valid value for the “@close-base-stream@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
    -}
    constructFilterInputStreamCloseBaseStream :: (IsFilterInputStream o) => Bool -> IO (GValueConstruct o)
    constructFilterInputStreamCloseBaseStream val = constructObjectPropertyBool "close-base-stream" val

    #if ENABLE_OVERLOADING
    data FilterInputStreamCloseBaseStreamPropertyInfo
    instance AttrInfo FilterInputStreamCloseBaseStreamPropertyInfo where
        type AttrAllowedOps FilterInputStreamCloseBaseStreamPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
        type AttrSetTypeConstraint FilterInputStreamCloseBaseStreamPropertyInfo = (~) Bool
        type AttrBaseTypeConstraint FilterInputStreamCloseBaseStreamPropertyInfo = IsFilterInputStream
        type AttrGetType FilterInputStreamCloseBaseStreamPropertyInfo = Bool
        type AttrLabel FilterInputStreamCloseBaseStreamPropertyInfo = "close-base-stream"
        type AttrOrigin FilterInputStreamCloseBaseStreamPropertyInfo = FilterInputStream
        attrGet _ = getFilterInputStreamCloseBaseStream
        attrSet _ = setFilterInputStreamCloseBaseStream
        attrConstruct _ = constructFilterInputStreamCloseBaseStream
        attrClear _ = undefined
    #endif

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList FilterInputStream
    type instance O.AttributeList FilterInputStream = FilterInputStreamAttributeList
    type FilterInputStreamAttributeList = ('[ '("baseStream", FilterInputStreamBaseStreamPropertyInfo), '("closeBaseStream", FilterInputStreamCloseBaseStreamPropertyInfo)] :: [(Symbol, *)])
    #endif

    #if ENABLE_OVERLOADING
    filterInputStreamBaseStream :: AttrLabelProxy "baseStream"
    filterInputStreamBaseStream = AttrLabelProxy

    filterInputStreamCloseBaseStream :: AttrLabelProxy "closeBaseStream"
    filterInputStreamCloseBaseStream = AttrLabelProxy

    #endif

    #if ENABLE_OVERLOADING
    type instance O.SignalList FilterInputStream = FilterInputStreamSignalList
    type FilterInputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

    #endif

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

    foreign import ccall "g_filter_input_stream_get_base_stream" g_filter_input_stream_get_base_stream ::
        Ptr FilterInputStream ->                -- stream : TInterface (Name {namespace = "Gio", name = "FilterInputStream"})
        IO (Ptr Gio.InputStream.InputStream)

    {- |
    Gets the base stream for the filter stream.
    -}
    filterInputStreamGetBaseStream ::
        (B.CallStack.HasCallStack, MonadIO m, IsFilterInputStream a) =>
        a
        {- ^ /@stream@/: a 'GI.Gio.Objects.FilterInputStream.FilterInputStream'. -}
        -> m Gio.InputStream.InputStream
        {- ^ __Returns:__ a 'GI.Gio.Objects.InputStream.InputStream'. -}
    filterInputStreamGetBaseStream stream = liftIO $ do
        stream' <- unsafeManagedPtrCastPtr stream
        result <- g_filter_input_stream_get_base_stream stream'
        checkUnexpectedReturnNULL "filterInputStreamGetBaseStream" result
        result' <- (newObject Gio.InputStream.InputStream) result
        touchManagedPtr stream
        return result'

    #if ENABLE_OVERLOADING
    data FilterInputStreamGetBaseStreamMethodInfo
    instance (signature ~ (m Gio.InputStream.InputStream), MonadIO m, IsFilterInputStream a) => O.MethodInfo FilterInputStreamGetBaseStreamMethodInfo a signature where
        overloadedMethod _ = filterInputStreamGetBaseStream

    #endif

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

    foreign import ccall "g_filter_input_stream_get_close_base_stream" g_filter_input_stream_get_close_base_stream ::
        Ptr FilterInputStream ->                -- stream : TInterface (Name {namespace = "Gio", name = "FilterInputStream"})
        IO CInt

    {- |
    Returns whether the base stream will be closed when /@stream@/ is
    closed.
    -}
    filterInputStreamGetCloseBaseStream ::
        (B.CallStack.HasCallStack, MonadIO m, IsFilterInputStream a) =>
        a
        {- ^ /@stream@/: a 'GI.Gio.Objects.FilterInputStream.FilterInputStream'. -}
        -> m Bool
        {- ^ __Returns:__ 'True' if the base stream will be closed. -}
    filterInputStreamGetCloseBaseStream stream = liftIO $ do
        stream' <- unsafeManagedPtrCastPtr stream
        result <- g_filter_input_stream_get_close_base_stream stream'
        let result' = (/= 0) result
        touchManagedPtr stream
        return result'

    #if ENABLE_OVERLOADING
    data FilterInputStreamGetCloseBaseStreamMethodInfo
    instance (signature ~ (m Bool), MonadIO m, IsFilterInputStream a) => O.MethodInfo FilterInputStreamGetCloseBaseStreamMethodInfo a signature where
        overloadedMethod _ = filterInputStreamGetCloseBaseStream

    #endif

    -- method FilterInputStream::set_close_base_stream
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "FilterInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFilterInputStream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "close_base", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to close the base stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_filter_input_stream_set_close_base_stream" g_filter_input_stream_set_close_base_stream ::
        Ptr FilterInputStream ->                -- stream : TInterface (Name {namespace = "Gio", name = "FilterInputStream"})
        CInt ->                                 -- close_base : TBasicType TBoolean
        IO ()

    {- |
    Sets whether the base stream will be closed when /@stream@/ is closed.
    -}
    filterInputStreamSetCloseBaseStream ::
        (B.CallStack.HasCallStack, MonadIO m, IsFilterInputStream a) =>
        a
        {- ^ /@stream@/: a 'GI.Gio.Objects.FilterInputStream.FilterInputStream'. -}
        -> Bool
        {- ^ /@closeBase@/: 'True' to close the base stream. -}
        -> m ()
    filterInputStreamSetCloseBaseStream stream closeBase = liftIO $ do
        stream' <- unsafeManagedPtrCastPtr stream
        let closeBase' = (fromIntegral . fromEnum) closeBase
        g_filter_input_stream_set_close_base_stream stream' closeBase'
        touchManagedPtr stream
        return ()

    #if ENABLE_OVERLOADING
    data FilterInputStreamSetCloseBaseStreamMethodInfo
    instance (signature ~ (Bool -> m ()), MonadIO m, IsFilterInputStream a) => O.MethodInfo FilterInputStreamSetCloseBaseStreamMethodInfo a signature where
        overloadedMethod _ = filterInputStreamSetCloseBaseStream

    #endif