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

Buffered output stream implements 'GI.Gio.Objects.FilterOutputStream.FilterOutputStream' and provides
for buffered writes.

By default, 'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'\'s buffer size is set at 4 kilobytes.

To create a buffered output stream, use 'GI.Gio.Objects.BufferedOutputStream.bufferedOutputStreamNew',
or 'GI.Gio.Objects.BufferedOutputStream.bufferedOutputStreamNewSized' to specify the buffer\'s size
at construction.

To get the size of a buffer within a buffered input stream, use
'GI.Gio.Objects.BufferedOutputStream.bufferedOutputStreamGetBufferSize'. To change the size of a
buffered output stream\'s buffer, use
'GI.Gio.Objects.BufferedOutputStream.bufferedOutputStreamSetBufferSize'. Note that the buffer\'s
size cannot be reduced below the size of the data within the buffer.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.BufferedOutputStream
    (

-- * Exported types
    BufferedOutputStream(..)                ,
    IsBufferedOutputStream                  ,
    toBufferedOutputStream                  ,
    noBufferedOutputStream                  ,


 -- * Methods
-- ** getAutoGrow #method:getAutoGrow#

#if ENABLE_OVERLOADING
    BufferedOutputStreamGetAutoGrowMethodInfo,
#endif
    bufferedOutputStreamGetAutoGrow         ,


-- ** getBufferSize #method:getBufferSize#

#if ENABLE_OVERLOADING
    BufferedOutputStreamGetBufferSizeMethodInfo,
#endif
    bufferedOutputStreamGetBufferSize       ,


-- ** new #method:new#

    bufferedOutputStreamNew                 ,


-- ** newSized #method:newSized#

    bufferedOutputStreamNewSized            ,


-- ** setAutoGrow #method:setAutoGrow#

#if ENABLE_OVERLOADING
    BufferedOutputStreamSetAutoGrowMethodInfo,
#endif
    bufferedOutputStreamSetAutoGrow         ,


-- ** setBufferSize #method:setBufferSize#

#if ENABLE_OVERLOADING
    BufferedOutputStreamSetBufferSizeMethodInfo,
#endif
    bufferedOutputStreamSetBufferSize       ,




 -- * Properties
-- ** autoGrow #attr:autoGrow#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    BufferedOutputStreamAutoGrowPropertyInfo,
#endif
#if ENABLE_OVERLOADING
    bufferedOutputStreamAutoGrow            ,
#endif
    constructBufferedOutputStreamAutoGrow   ,
    getBufferedOutputStreamAutoGrow         ,
    setBufferedOutputStreamAutoGrow         ,


-- ** bufferSize #attr:bufferSize#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    BufferedOutputStreamBufferSizePropertyInfo,
#endif
#if ENABLE_OVERLOADING
    bufferedOutputStreamBufferSize          ,
#endif
    constructBufferedOutputStreamBufferSize ,
    getBufferedOutputStreamBufferSize       ,
    setBufferedOutputStreamBufferSize       ,




    ) 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.Interfaces.Seekable as Gio.Seekable
import {-# SOURCE #-} qualified GI.Gio.Objects.FilterOutputStream as Gio.FilterOutputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.OutputStream as Gio.OutputStream

-- | Memory-managed wrapper type.
newtype BufferedOutputStream = BufferedOutputStream (ManagedPtr BufferedOutputStream)
foreign import ccall "g_buffered_output_stream_get_type"
    c_g_buffered_output_stream_get_type :: IO GType

instance GObject BufferedOutputStream where
    gobjectType _ = c_g_buffered_output_stream_get_type


-- | Type class for types which can be safely cast to `BufferedOutputStream`, for instance with `toBufferedOutputStream`.
class GObject o => IsBufferedOutputStream o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError BufferedOutputStream a) =>
    IsBufferedOutputStream a
#endif
instance IsBufferedOutputStream BufferedOutputStream
instance Gio.FilterOutputStream.IsFilterOutputStream BufferedOutputStream
instance Gio.OutputStream.IsOutputStream BufferedOutputStream
instance GObject.Object.IsObject BufferedOutputStream
instance Gio.Seekable.IsSeekable BufferedOutputStream

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

-- | A convenience alias for `Nothing` :: `Maybe` `BufferedOutputStream`.
noBufferedOutputStream :: Maybe BufferedOutputStream
noBufferedOutputStream = Nothing

#if ENABLE_OVERLOADING
type family ResolveBufferedOutputStreamMethod (t :: Symbol) (o :: *) :: * where
    ResolveBufferedOutputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveBufferedOutputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveBufferedOutputStreamMethod "canSeek" o = Gio.Seekable.SeekableCanSeekMethodInfo
    ResolveBufferedOutputStreamMethod "canTruncate" o = Gio.Seekable.SeekableCanTruncateMethodInfo
    ResolveBufferedOutputStreamMethod "clearPending" o = Gio.OutputStream.OutputStreamClearPendingMethodInfo
    ResolveBufferedOutputStreamMethod "close" o = Gio.OutputStream.OutputStreamCloseMethodInfo
    ResolveBufferedOutputStreamMethod "closeAsync" o = Gio.OutputStream.OutputStreamCloseAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "closeFinish" o = Gio.OutputStream.OutputStreamCloseFinishMethodInfo
    ResolveBufferedOutputStreamMethod "flush" o = Gio.OutputStream.OutputStreamFlushMethodInfo
    ResolveBufferedOutputStreamMethod "flushAsync" o = Gio.OutputStream.OutputStreamFlushAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "flushFinish" o = Gio.OutputStream.OutputStreamFlushFinishMethodInfo
    ResolveBufferedOutputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveBufferedOutputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveBufferedOutputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveBufferedOutputStreamMethod "hasPending" o = Gio.OutputStream.OutputStreamHasPendingMethodInfo
    ResolveBufferedOutputStreamMethod "isClosed" o = Gio.OutputStream.OutputStreamIsClosedMethodInfo
    ResolveBufferedOutputStreamMethod "isClosing" o = Gio.OutputStream.OutputStreamIsClosingMethodInfo
    ResolveBufferedOutputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveBufferedOutputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveBufferedOutputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveBufferedOutputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveBufferedOutputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveBufferedOutputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveBufferedOutputStreamMethod "seek" o = Gio.Seekable.SeekableSeekMethodInfo
    ResolveBufferedOutputStreamMethod "splice" o = Gio.OutputStream.OutputStreamSpliceMethodInfo
    ResolveBufferedOutputStreamMethod "spliceAsync" o = Gio.OutputStream.OutputStreamSpliceAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "spliceFinish" o = Gio.OutputStream.OutputStreamSpliceFinishMethodInfo
    ResolveBufferedOutputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveBufferedOutputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveBufferedOutputStreamMethod "tell" o = Gio.Seekable.SeekableTellMethodInfo
    ResolveBufferedOutputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveBufferedOutputStreamMethod "truncate" o = Gio.Seekable.SeekableTruncateMethodInfo
    ResolveBufferedOutputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveBufferedOutputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveBufferedOutputStreamMethod "write" o = Gio.OutputStream.OutputStreamWriteMethodInfo
    ResolveBufferedOutputStreamMethod "writeAll" o = Gio.OutputStream.OutputStreamWriteAllMethodInfo
    ResolveBufferedOutputStreamMethod "writeAllAsync" o = Gio.OutputStream.OutputStreamWriteAllAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "writeAllFinish" o = Gio.OutputStream.OutputStreamWriteAllFinishMethodInfo
    ResolveBufferedOutputStreamMethod "writeAsync" o = Gio.OutputStream.OutputStreamWriteAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "writeBytes" o = Gio.OutputStream.OutputStreamWriteBytesMethodInfo
    ResolveBufferedOutputStreamMethod "writeBytesAsync" o = Gio.OutputStream.OutputStreamWriteBytesAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "writeBytesFinish" o = Gio.OutputStream.OutputStreamWriteBytesFinishMethodInfo
    ResolveBufferedOutputStreamMethod "writeFinish" o = Gio.OutputStream.OutputStreamWriteFinishMethodInfo
    ResolveBufferedOutputStreamMethod "getAutoGrow" o = BufferedOutputStreamGetAutoGrowMethodInfo
    ResolveBufferedOutputStreamMethod "getBaseStream" o = Gio.FilterOutputStream.FilterOutputStreamGetBaseStreamMethodInfo
    ResolveBufferedOutputStreamMethod "getBufferSize" o = BufferedOutputStreamGetBufferSizeMethodInfo
    ResolveBufferedOutputStreamMethod "getCloseBaseStream" o = Gio.FilterOutputStream.FilterOutputStreamGetCloseBaseStreamMethodInfo
    ResolveBufferedOutputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveBufferedOutputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveBufferedOutputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveBufferedOutputStreamMethod "setAutoGrow" o = BufferedOutputStreamSetAutoGrowMethodInfo
    ResolveBufferedOutputStreamMethod "setBufferSize" o = BufferedOutputStreamSetBufferSizeMethodInfo
    ResolveBufferedOutputStreamMethod "setCloseBaseStream" o = Gio.FilterOutputStream.FilterOutputStreamSetCloseBaseStreamMethodInfo
    ResolveBufferedOutputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveBufferedOutputStreamMethod "setPending" o = Gio.OutputStream.OutputStreamSetPendingMethodInfo
    ResolveBufferedOutputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveBufferedOutputStreamMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveBufferedOutputStreamMethod t BufferedOutputStream, O.MethodInfo info BufferedOutputStream p) => O.IsLabel t (BufferedOutputStream -> 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 "auto-grow"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

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

@
'Data.GI.Base.Attributes.get' bufferedOutputStream #autoGrow
@
-}
getBufferedOutputStreamAutoGrow :: (MonadIO m, IsBufferedOutputStream o) => o -> m Bool
getBufferedOutputStreamAutoGrow obj = liftIO $ getObjectPropertyBool obj "auto-grow"

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

@
'Data.GI.Base.Attributes.set' bufferedOutputStream [ #autoGrow 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBufferedOutputStreamAutoGrow :: (MonadIO m, IsBufferedOutputStream o) => o -> Bool -> m ()
setBufferedOutputStreamAutoGrow obj val = liftIO $ setObjectPropertyBool obj "auto-grow" val

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

#if ENABLE_OVERLOADING
data BufferedOutputStreamAutoGrowPropertyInfo
instance AttrInfo BufferedOutputStreamAutoGrowPropertyInfo where
    type AttrAllowedOps BufferedOutputStreamAutoGrowPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BufferedOutputStreamAutoGrowPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint BufferedOutputStreamAutoGrowPropertyInfo = IsBufferedOutputStream
    type AttrGetType BufferedOutputStreamAutoGrowPropertyInfo = Bool
    type AttrLabel BufferedOutputStreamAutoGrowPropertyInfo = "auto-grow"
    type AttrOrigin BufferedOutputStreamAutoGrowPropertyInfo = BufferedOutputStream
    attrGet _ = getBufferedOutputStreamAutoGrow
    attrSet _ = setBufferedOutputStreamAutoGrow
    attrConstruct _ = constructBufferedOutputStreamAutoGrow
    attrClear _ = undefined
#endif

-- VVV Prop "buffer-size"
   -- Type: TBasicType TUInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Nothing,Nothing)

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

@
'Data.GI.Base.Attributes.get' bufferedOutputStream #bufferSize
@
-}
getBufferedOutputStreamBufferSize :: (MonadIO m, IsBufferedOutputStream o) => o -> m Word32
getBufferedOutputStreamBufferSize obj = liftIO $ getObjectPropertyUInt32 obj "buffer-size"

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

@
'Data.GI.Base.Attributes.set' bufferedOutputStream [ #bufferSize 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBufferedOutputStreamBufferSize :: (MonadIO m, IsBufferedOutputStream o) => o -> Word32 -> m ()
setBufferedOutputStreamBufferSize obj val = liftIO $ setObjectPropertyUInt32 obj "buffer-size" val

{- |
Construct a `GValueConstruct` with valid value for the “@buffer-size@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructBufferedOutputStreamBufferSize :: (IsBufferedOutputStream o) => Word32 -> IO (GValueConstruct o)
constructBufferedOutputStreamBufferSize val = constructObjectPropertyUInt32 "buffer-size" val

#if ENABLE_OVERLOADING
data BufferedOutputStreamBufferSizePropertyInfo
instance AttrInfo BufferedOutputStreamBufferSizePropertyInfo where
    type AttrAllowedOps BufferedOutputStreamBufferSizePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BufferedOutputStreamBufferSizePropertyInfo = (~) Word32
    type AttrBaseTypeConstraint BufferedOutputStreamBufferSizePropertyInfo = IsBufferedOutputStream
    type AttrGetType BufferedOutputStreamBufferSizePropertyInfo = Word32
    type AttrLabel BufferedOutputStreamBufferSizePropertyInfo = "buffer-size"
    type AttrOrigin BufferedOutputStreamBufferSizePropertyInfo = BufferedOutputStream
    attrGet _ = getBufferedOutputStreamBufferSize
    attrSet _ = setBufferedOutputStreamBufferSize
    attrConstruct _ = constructBufferedOutputStreamBufferSize
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList BufferedOutputStream
type instance O.AttributeList BufferedOutputStream = BufferedOutputStreamAttributeList
type BufferedOutputStreamAttributeList = ('[ '("autoGrow", BufferedOutputStreamAutoGrowPropertyInfo), '("baseStream", Gio.FilterOutputStream.FilterOutputStreamBaseStreamPropertyInfo), '("bufferSize", BufferedOutputStreamBufferSizePropertyInfo), '("closeBaseStream", Gio.FilterOutputStream.FilterOutputStreamCloseBaseStreamPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
bufferedOutputStreamAutoGrow :: AttrLabelProxy "autoGrow"
bufferedOutputStreamAutoGrow = AttrLabelProxy

bufferedOutputStreamBufferSize :: AttrLabelProxy "bufferSize"
bufferedOutputStreamBufferSize = AttrLabelProxy

#endif

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

#endif

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

foreign import ccall "g_buffered_output_stream_new" g_buffered_output_stream_new ::
    Ptr Gio.OutputStream.OutputStream ->    -- base_stream : TInterface (Name {namespace = "Gio", name = "OutputStream"})
    IO (Ptr BufferedOutputStream)

{- |
Creates a new buffered output stream for a base stream.
-}
bufferedOutputStreamNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.OutputStream.IsOutputStream a) =>
    a
    {- ^ /@baseStream@/: a 'GI.Gio.Objects.OutputStream.OutputStream'. -}
    -> m BufferedOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.OutputStream.OutputStream' for the given /@baseStream@/. -}
bufferedOutputStreamNew baseStream = liftIO $ do
    baseStream' <- unsafeManagedPtrCastPtr baseStream
    result <- g_buffered_output_stream_new baseStream'
    checkUnexpectedReturnNULL "bufferedOutputStreamNew" result
    result' <- (wrapObject BufferedOutputStream) result
    touchManagedPtr baseStream
    return result'

#if ENABLE_OVERLOADING
#endif

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

foreign import ccall "g_buffered_output_stream_new_sized" g_buffered_output_stream_new_sized ::
    Ptr Gio.OutputStream.OutputStream ->    -- base_stream : TInterface (Name {namespace = "Gio", name = "OutputStream"})
    Word64 ->                               -- size : TBasicType TUInt64
    IO (Ptr BufferedOutputStream)

{- |
Creates a new buffered output stream with a given buffer size.
-}
bufferedOutputStreamNewSized ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.OutputStream.IsOutputStream a) =>
    a
    {- ^ /@baseStream@/: a 'GI.Gio.Objects.OutputStream.OutputStream'. -}
    -> Word64
    {- ^ /@size@/: a @/gsize/@. -}
    -> m BufferedOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.OutputStream.OutputStream' with an internal buffer set to /@size@/. -}
bufferedOutputStreamNewSized baseStream size = liftIO $ do
    baseStream' <- unsafeManagedPtrCastPtr baseStream
    result <- g_buffered_output_stream_new_sized baseStream' size
    checkUnexpectedReturnNULL "bufferedOutputStreamNewSized" result
    result' <- (wrapObject BufferedOutputStream) result
    touchManagedPtr baseStream
    return result'

#if ENABLE_OVERLOADING
#endif

-- method BufferedOutputStream::get_auto_grow
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedOutputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedOutputStream.", 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_buffered_output_stream_get_auto_grow" g_buffered_output_stream_get_auto_grow ::
    Ptr BufferedOutputStream ->             -- stream : TInterface (Name {namespace = "Gio", name = "BufferedOutputStream"})
    IO CInt

{- |
Checks if the buffer automatically grows as data is added.
-}
bufferedOutputStreamGetAutoGrow ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedOutputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@stream@/\'s buffer automatically grows,
'False' otherwise. -}
bufferedOutputStreamGetAutoGrow stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result <- g_buffered_output_stream_get_auto_grow stream'
    let result' = (/= 0) result
    touchManagedPtr stream
    return result'

#if ENABLE_OVERLOADING
data BufferedOutputStreamGetAutoGrowMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsBufferedOutputStream a) => O.MethodInfo BufferedOutputStreamGetAutoGrowMethodInfo a signature where
    overloadedMethod _ = bufferedOutputStreamGetAutoGrow

#endif

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

foreign import ccall "g_buffered_output_stream_get_buffer_size" g_buffered_output_stream_get_buffer_size ::
    Ptr BufferedOutputStream ->             -- stream : TInterface (Name {namespace = "Gio", name = "BufferedOutputStream"})
    IO Word64

{- |
Gets the size of the buffer in the /@stream@/.
-}
bufferedOutputStreamGetBufferSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedOutputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'. -}
    -> m Word64
    {- ^ __Returns:__ the current size of the buffer. -}
bufferedOutputStreamGetBufferSize stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result <- g_buffered_output_stream_get_buffer_size stream'
    touchManagedPtr stream
    return result

#if ENABLE_OVERLOADING
data BufferedOutputStreamGetBufferSizeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsBufferedOutputStream a) => O.MethodInfo BufferedOutputStreamGetBufferSizeMethodInfo a signature where
    overloadedMethod _ = bufferedOutputStreamGetBufferSize

#endif

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

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

{- |
Sets whether or not the /@stream@/\'s buffer should automatically grow.
If /@autoGrow@/ is true, then each write will just make the buffer
larger, and you must manually flush the buffer to actually write out
the data to the underlying stream.
-}
bufferedOutputStreamSetAutoGrow ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedOutputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'. -}
    -> Bool
    {- ^ /@autoGrow@/: a 'Bool'. -}
    -> m ()
bufferedOutputStreamSetAutoGrow stream autoGrow = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    let autoGrow' = (fromIntegral . fromEnum) autoGrow
    g_buffered_output_stream_set_auto_grow stream' autoGrow'
    touchManagedPtr stream
    return ()

#if ENABLE_OVERLOADING
data BufferedOutputStreamSetAutoGrowMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsBufferedOutputStream a) => O.MethodInfo BufferedOutputStreamSetAutoGrowMethodInfo a signature where
    overloadedMethod _ = bufferedOutputStreamSetAutoGrow

#endif

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

foreign import ccall "g_buffered_output_stream_set_buffer_size" g_buffered_output_stream_set_buffer_size ::
    Ptr BufferedOutputStream ->             -- stream : TInterface (Name {namespace = "Gio", name = "BufferedOutputStream"})
    Word64 ->                               -- size : TBasicType TUInt64
    IO ()

{- |
Sets the size of the internal buffer to /@size@/.
-}
bufferedOutputStreamSetBufferSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedOutputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'. -}
    -> Word64
    {- ^ /@size@/: a @/gsize/@. -}
    -> m ()
bufferedOutputStreamSetBufferSize stream size = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    g_buffered_output_stream_set_buffer_size stream' size
    touchManagedPtr stream
    return ()

#if ENABLE_OVERLOADING
data BufferedOutputStreamSetBufferSizeMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsBufferedOutputStream a) => O.MethodInfo BufferedOutputStreamSetBufferSizeMethodInfo a signature where
    overloadedMethod _ = bufferedOutputStreamSetBufferSize

#endif