{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Buffered output stream implements t'GI.Gio.Objects.FilterOutputStream.FilterOutputStream' and provides
-- for buffered writes.
-- 
-- By default, t'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.

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

module GI.Gio.Objects.BufferedOutputStream
    ( 

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


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveBufferedOutputStreamMethod       ,
#endif


-- ** getAutoGrow #method:getAutoGrow#

#if defined(ENABLE_OVERLOADING)
    BufferedOutputStreamGetAutoGrowMethodInfo,
#endif
    bufferedOutputStreamGetAutoGrow         ,


-- ** getBufferSize #method:getBufferSize#

#if defined(ENABLE_OVERLOADING)
    BufferedOutputStreamGetBufferSizeMethodInfo,
#endif
    bufferedOutputStreamGetBufferSize       ,


-- ** new #method:new#

    bufferedOutputStreamNew                 ,


-- ** newSized #method:newSized#

    bufferedOutputStreamNewSized            ,


-- ** setAutoGrow #method:setAutoGrow#

#if defined(ENABLE_OVERLOADING)
    BufferedOutputStreamSetAutoGrowMethodInfo,
#endif
    bufferedOutputStreamSetAutoGrow         ,


-- ** setBufferSize #method:setBufferSize#

#if defined(ENABLE_OVERLOADING)
    BufferedOutputStreamSetBufferSizeMethodInfo,
#endif
    bufferedOutputStreamSetBufferSize       ,




 -- * Properties
-- ** autoGrow #attr:autoGrow#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    BufferedOutputStreamAutoGrowPropertyInfo,
#endif
#if defined(ENABLE_OVERLOADING)
    bufferedOutputStreamAutoGrow            ,
#endif
    constructBufferedOutputStreamAutoGrow   ,
    getBufferedOutputStreamAutoGrow         ,
    setBufferedOutputStreamAutoGrow         ,


-- ** bufferSize #attr:bufferSize#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    BufferedOutputStreamBufferSizePropertyInfo,
#endif
#if defined(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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 GHC.OverloadedLabels as OL

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 (SP.ManagedPtr BufferedOutputStream)
    deriving (BufferedOutputStream -> BufferedOutputStream -> Bool
(BufferedOutputStream -> BufferedOutputStream -> Bool)
-> (BufferedOutputStream -> BufferedOutputStream -> Bool)
-> Eq BufferedOutputStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BufferedOutputStream -> BufferedOutputStream -> Bool
$c/= :: BufferedOutputStream -> BufferedOutputStream -> Bool
== :: BufferedOutputStream -> BufferedOutputStream -> Bool
$c== :: BufferedOutputStream -> BufferedOutputStream -> Bool
Eq)

instance SP.ManagedPtrNewtype BufferedOutputStream where
    toManagedPtr :: BufferedOutputStream -> ManagedPtr BufferedOutputStream
toManagedPtr (BufferedOutputStream ManagedPtr BufferedOutputStream
p) = ManagedPtr BufferedOutputStream
p

foreign import ccall "g_buffered_output_stream_get_type"
    c_g_buffered_output_stream_get_type :: IO B.Types.GType

instance B.Types.TypedObject BufferedOutputStream where
    glibType :: IO GType
glibType = IO GType
c_g_buffered_output_stream_get_type

instance B.Types.GObject BufferedOutputStream

-- | Convert 'BufferedOutputStream' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue BufferedOutputStream where
    toGValue :: BufferedOutputStream -> IO GValue
toGValue BufferedOutputStream
o = do
        GType
gtype <- IO GType
c_g_buffered_output_stream_get_type
        BufferedOutputStream
-> (Ptr BufferedOutputStream -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr BufferedOutputStream
o (GType
-> (GValue -> Ptr BufferedOutputStream -> IO ())
-> Ptr BufferedOutputStream
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr BufferedOutputStream -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO BufferedOutputStream
fromGValue GValue
gv = do
        Ptr BufferedOutputStream
ptr <- GValue -> IO (Ptr BufferedOutputStream)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr BufferedOutputStream)
        (ManagedPtr BufferedOutputStream -> BufferedOutputStream)
-> Ptr BufferedOutputStream -> IO BufferedOutputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr BufferedOutputStream -> BufferedOutputStream
BufferedOutputStream Ptr BufferedOutputStream
ptr
        
    

-- | Type class for types which can be safely cast to `BufferedOutputStream`, for instance with `toBufferedOutputStream`.
class (SP.GObject o, O.IsDescendantOf BufferedOutputStream o) => IsBufferedOutputStream o
instance (SP.GObject o, O.IsDescendantOf BufferedOutputStream o) => IsBufferedOutputStream o

instance O.HasParentTypes BufferedOutputStream
type instance O.ParentTypes BufferedOutputStream = '[Gio.FilterOutputStream.FilterOutputStream, Gio.OutputStream.OutputStream, GObject.Object.Object, Gio.Seekable.Seekable]

-- | 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 :: o -> m BufferedOutputStream
toBufferedOutputStream = IO BufferedOutputStream -> m BufferedOutputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO BufferedOutputStream -> m BufferedOutputStream)
-> (o -> IO BufferedOutputStream) -> o -> m BufferedOutputStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr BufferedOutputStream -> BufferedOutputStream)
-> o -> IO BufferedOutputStream
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr BufferedOutputStream -> BufferedOutputStream
BufferedOutputStream

#if defined(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 "writev" o = Gio.OutputStream.OutputStreamWritevMethodInfo
    ResolveBufferedOutputStreamMethod "writevAll" o = Gio.OutputStream.OutputStreamWritevAllMethodInfo
    ResolveBufferedOutputStreamMethod "writevAllAsync" o = Gio.OutputStream.OutputStreamWritevAllAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "writevAllFinish" o = Gio.OutputStream.OutputStreamWritevAllFinishMethodInfo
    ResolveBufferedOutputStreamMethod "writevAsync" o = Gio.OutputStream.OutputStreamWritevAsyncMethodInfo
    ResolveBufferedOutputStreamMethod "writevFinish" o = Gio.OutputStream.OutputStreamWritevFinishMethodInfo
    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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    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) => OL.IsLabel t (BufferedOutputStream -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#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 :: o -> m Bool
getBufferedOutputStreamAutoGrow o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"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 :: o -> Bool -> m ()
setBufferedOutputStreamAutoGrow o
obj Bool
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Bool -> IO ()
forall a. GObject a => a -> String -> Bool -> IO ()
B.Properties.setObjectPropertyBool o
obj String
"auto-grow" Bool
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, MIO.MonadIO m) => Bool -> m (GValueConstruct o)
constructBufferedOutputStreamAutoGrow :: Bool -> m (GValueConstruct o)
constructBufferedOutputStreamAutoGrow Bool
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBool String
"auto-grow" Bool
val

#if defined(ENABLE_OVERLOADING)
data BufferedOutputStreamAutoGrowPropertyInfo
instance AttrInfo BufferedOutputStreamAutoGrowPropertyInfo where
    type AttrAllowedOps BufferedOutputStreamAutoGrowPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint BufferedOutputStreamAutoGrowPropertyInfo = IsBufferedOutputStream
    type AttrSetTypeConstraint BufferedOutputStreamAutoGrowPropertyInfo = (~) Bool
    type AttrTransferTypeConstraint BufferedOutputStreamAutoGrowPropertyInfo = (~) Bool
    type AttrTransferType BufferedOutputStreamAutoGrowPropertyInfo = Bool
    type AttrGetType BufferedOutputStreamAutoGrowPropertyInfo = Bool
    type AttrLabel BufferedOutputStreamAutoGrowPropertyInfo = "auto-grow"
    type AttrOrigin BufferedOutputStreamAutoGrowPropertyInfo = BufferedOutputStream
    attrGet = getBufferedOutputStreamAutoGrow
    attrSet = setBufferedOutputStreamAutoGrow
    attrTransfer _ v = do
        return v
    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 :: o -> m Word32
getBufferedOutputStreamBufferSize o
obj = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Word32
forall a. GObject a => a -> String -> IO Word32
B.Properties.getObjectPropertyUInt32 o
obj String
"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 :: o -> Word32 -> m ()
setBufferedOutputStreamBufferSize o
obj Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Word32 -> IO ()
forall a. GObject a => a -> String -> Word32 -> IO ()
B.Properties.setObjectPropertyUInt32 o
obj String
"buffer-size" Word32
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, MIO.MonadIO m) => Word32 -> m (GValueConstruct o)
constructBufferedOutputStreamBufferSize :: Word32 -> m (GValueConstruct o)
constructBufferedOutputStreamBufferSize Word32
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Word32 -> IO (GValueConstruct o)
forall o. String -> Word32 -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyUInt32 String
"buffer-size" Word32
val

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

#if defined(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 defined(ENABLE_OVERLOADING)
bufferedOutputStreamAutoGrow :: AttrLabelProxy "autoGrow"
bufferedOutputStreamAutoGrow = AttrLabelProxy

bufferedOutputStreamBufferSize :: AttrLabelProxy "bufferSize"
bufferedOutputStreamBufferSize = AttrLabelProxy

#endif

#if defined(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 t'GI.Gio.Objects.OutputStream.OutputStream'.
    -> m BufferedOutputStream
    -- ^ __Returns:__ a t'GI.Gio.Objects.OutputStream.OutputStream' for the given /@baseStream@/.
bufferedOutputStreamNew :: a -> m BufferedOutputStream
bufferedOutputStreamNew a
baseStream = IO BufferedOutputStream -> m BufferedOutputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO BufferedOutputStream -> m BufferedOutputStream)
-> IO BufferedOutputStream -> m BufferedOutputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr OutputStream
baseStream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
baseStream
    Ptr BufferedOutputStream
result <- Ptr OutputStream -> IO (Ptr BufferedOutputStream)
g_buffered_output_stream_new Ptr OutputStream
baseStream'
    Text -> Ptr BufferedOutputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferedOutputStreamNew" Ptr BufferedOutputStream
result
    BufferedOutputStream
result' <- ((ManagedPtr BufferedOutputStream -> BufferedOutputStream)
-> Ptr BufferedOutputStream -> IO BufferedOutputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr BufferedOutputStream -> BufferedOutputStream
BufferedOutputStream) Ptr BufferedOutputStream
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
baseStream
    BufferedOutputStream -> IO BufferedOutputStream
forall (m :: * -> *) a. Monad m => a -> m a
return BufferedOutputStream
result'

#if defined(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 t'GI.Gio.Objects.OutputStream.OutputStream'.
    -> Word64
    -- ^ /@size@/: a @/gsize/@.
    -> m BufferedOutputStream
    -- ^ __Returns:__ a t'GI.Gio.Objects.OutputStream.OutputStream' with an internal buffer set to /@size@/.
bufferedOutputStreamNewSized :: a -> Word64 -> m BufferedOutputStream
bufferedOutputStreamNewSized a
baseStream Word64
size = IO BufferedOutputStream -> m BufferedOutputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO BufferedOutputStream -> m BufferedOutputStream)
-> IO BufferedOutputStream -> m BufferedOutputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr OutputStream
baseStream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
baseStream
    Ptr BufferedOutputStream
result <- Ptr OutputStream -> Word64 -> IO (Ptr BufferedOutputStream)
g_buffered_output_stream_new_sized Ptr OutputStream
baseStream' Word64
size
    Text -> Ptr BufferedOutputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferedOutputStreamNewSized" Ptr BufferedOutputStream
result
    BufferedOutputStream
result' <- ((ManagedPtr BufferedOutputStream -> BufferedOutputStream)
-> Ptr BufferedOutputStream -> IO BufferedOutputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr BufferedOutputStream -> BufferedOutputStream
BufferedOutputStream) Ptr BufferedOutputStream
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
baseStream
    BufferedOutputStream -> IO BufferedOutputStream
forall (m :: * -> *) a. Monad m => a -> m a
return BufferedOutputStream
result'

#if defined(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 t'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the /@stream@/\'s buffer automatically grows,
    -- 'P.False' otherwise.
bufferedOutputStreamGetAutoGrow :: a -> m Bool
bufferedOutputStreamGetAutoGrow a
stream = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr BufferedOutputStream
stream' <- a -> IO (Ptr BufferedOutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
    CInt
result <- Ptr BufferedOutputStream -> IO CInt
g_buffered_output_stream_get_auto_grow Ptr BufferedOutputStream
stream'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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 t'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'.
    -> m Word64
    -- ^ __Returns:__ the current size of the buffer.
bufferedOutputStreamGetBufferSize :: a -> m Word64
bufferedOutputStreamGetBufferSize a
stream = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr BufferedOutputStream
stream' <- a -> IO (Ptr BufferedOutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
    Word64
result <- Ptr BufferedOutputStream -> IO Word64
g_buffered_output_stream_get_buffer_size Ptr BufferedOutputStream
stream'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(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 t'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'.
    -> Bool
    -- ^ /@autoGrow@/: a t'P.Bool'.
    -> m ()
bufferedOutputStreamSetAutoGrow :: a -> Bool -> m ()
bufferedOutputStreamSetAutoGrow a
stream Bool
autoGrow = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr BufferedOutputStream
stream' <- a -> IO (Ptr BufferedOutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
    let autoGrow' :: CInt
autoGrow' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
autoGrow
    Ptr BufferedOutputStream -> CInt -> IO ()
g_buffered_output_stream_set_auto_grow Ptr BufferedOutputStream
stream' CInt
autoGrow'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 t'GI.Gio.Objects.BufferedOutputStream.BufferedOutputStream'.
    -> Word64
    -- ^ /@size@/: a @/gsize/@.
    -> m ()
bufferedOutputStreamSetBufferSize :: a -> Word64 -> m ()
bufferedOutputStreamSetBufferSize a
stream Word64
size = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr BufferedOutputStream
stream' <- a -> IO (Ptr BufferedOutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
    Ptr BufferedOutputStream -> Word64 -> IO ()
g_buffered_output_stream_set_buffer_size Ptr BufferedOutputStream
stream' Word64
size
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif