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

    'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' is a class for using arbitrary
    memory chunks as output for GIO streaming output operations.

    As of GLib 2.34, 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' trivially implements
    'GI.Gio.Interfaces.PollableOutputStream.PollableOutputStream': it always polls as ready.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Gio.Objects.MemoryOutputStream
        (

    -- * Exported types
        MemoryOutputStream(..)                  ,
        IsMemoryOutputStream                    ,
        toMemoryOutputStream                    ,
        noMemoryOutputStream                    ,

     -- * Methods
    -- ** getData #method:getData#

    #if ENABLE_OVERLOADING
        MemoryOutputStreamGetDataMethodInfo     ,
    #endif
        memoryOutputStreamGetData               ,

    -- ** getDataSize #method:getDataSize#

    #if ENABLE_OVERLOADING
        MemoryOutputStreamGetDataSizeMethodInfo ,
    #endif
        memoryOutputStreamGetDataSize           ,

    -- ** getSize #method:getSize#

    #if ENABLE_OVERLOADING
        MemoryOutputStreamGetSizeMethodInfo     ,
    #endif
        memoryOutputStreamGetSize               ,

    -- ** newResizable #method:newResizable#

        memoryOutputStreamNewResizable          ,

    -- ** stealAsBytes #method:stealAsBytes#

    #if ENABLE_OVERLOADING
        MemoryOutputStreamStealAsBytesMethodInfo,
    #endif
        memoryOutputStreamStealAsBytes          ,

    -- ** stealData #method:stealData#

    #if ENABLE_OVERLOADING
        MemoryOutputStreamStealDataMethodInfo   ,
    #endif
        memoryOutputStreamStealData             ,

     -- * Properties
    -- ** data #attr:data#
    {- | Pointer to buffer where data will be written.

    /Since: 2.24/
    -}
    #if ENABLE_OVERLOADING
        MemoryOutputStreamDataPropertyInfo      ,
    #endif
        constructMemoryOutputStreamData         ,
        getMemoryOutputStreamData               ,
    #if ENABLE_OVERLOADING
        memoryOutputStreamData                  ,
    #endif

    -- ** dataSize #attr:dataSize#
    {- | Size of data written to the buffer.

    /Since: 2.24/
    -}
    #if ENABLE_OVERLOADING
        MemoryOutputStreamDataSizePropertyInfo  ,
    #endif
        getMemoryOutputStreamDataSize           ,
    #if ENABLE_OVERLOADING
        memoryOutputStreamDataSize              ,
    #endif

    -- ** size #attr:size#
    {- | Current size of the data buffer.

    /Since: 2.24/
    -}
    #if ENABLE_OVERLOADING
        MemoryOutputStreamSizePropertyInfo      ,
    #endif
        constructMemoryOutputStreamSize         ,
        getMemoryOutputStreamSize               ,
    #if ENABLE_OVERLOADING
        memoryOutputStreamSize                  ,
    #endif

        ) 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.GLib.Structs.Bytes as GLib.Bytes
    import qualified GI.GObject.Objects.Object as GObject.Object
    import {-# SOURCE #-} qualified GI.Gio.Interfaces.PollableOutputStream as Gio.PollableOutputStream
    import {-# SOURCE #-} qualified GI.Gio.Interfaces.Seekable as Gio.Seekable
    import {-# SOURCE #-} qualified GI.Gio.Objects.OutputStream as Gio.OutputStream

    -- | Memory-managed wrapper type.
    newtype MemoryOutputStream = MemoryOutputStream (ManagedPtr MemoryOutputStream)
    foreign import ccall "g_memory_output_stream_get_type"
        c_g_memory_output_stream_get_type :: IO GType

    instance GObject MemoryOutputStream where
        gobjectType _ = c_g_memory_output_stream_get_type

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

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

    -- | A convenience alias for `Nothing` :: `Maybe` `MemoryOutputStream`.
    noMemoryOutputStream :: Maybe MemoryOutputStream
    noMemoryOutputStream = Nothing

    #if ENABLE_OVERLOADING
    type family ResolveMemoryOutputStreamMethod (t :: Symbol) (o :: *) :: * where
        ResolveMemoryOutputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
        ResolveMemoryOutputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
        ResolveMemoryOutputStreamMethod "canPoll" o = Gio.PollableOutputStream.PollableOutputStreamCanPollMethodInfo
        ResolveMemoryOutputStreamMethod "canSeek" o = Gio.Seekable.SeekableCanSeekMethodInfo
        ResolveMemoryOutputStreamMethod "canTruncate" o = Gio.Seekable.SeekableCanTruncateMethodInfo
        ResolveMemoryOutputStreamMethod "clearPending" o = Gio.OutputStream.OutputStreamClearPendingMethodInfo
        ResolveMemoryOutputStreamMethod "close" o = Gio.OutputStream.OutputStreamCloseMethodInfo
        ResolveMemoryOutputStreamMethod "closeAsync" o = Gio.OutputStream.OutputStreamCloseAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "closeFinish" o = Gio.OutputStream.OutputStreamCloseFinishMethodInfo
        ResolveMemoryOutputStreamMethod "createSource" o = Gio.PollableOutputStream.PollableOutputStreamCreateSourceMethodInfo
        ResolveMemoryOutputStreamMethod "flush" o = Gio.OutputStream.OutputStreamFlushMethodInfo
        ResolveMemoryOutputStreamMethod "flushAsync" o = Gio.OutputStream.OutputStreamFlushAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "flushFinish" o = Gio.OutputStream.OutputStreamFlushFinishMethodInfo
        ResolveMemoryOutputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
        ResolveMemoryOutputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
        ResolveMemoryOutputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
        ResolveMemoryOutputStreamMethod "hasPending" o = Gio.OutputStream.OutputStreamHasPendingMethodInfo
        ResolveMemoryOutputStreamMethod "isClosed" o = Gio.OutputStream.OutputStreamIsClosedMethodInfo
        ResolveMemoryOutputStreamMethod "isClosing" o = Gio.OutputStream.OutputStreamIsClosingMethodInfo
        ResolveMemoryOutputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
        ResolveMemoryOutputStreamMethod "isWritable" o = Gio.PollableOutputStream.PollableOutputStreamIsWritableMethodInfo
        ResolveMemoryOutputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
        ResolveMemoryOutputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
        ResolveMemoryOutputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
        ResolveMemoryOutputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
        ResolveMemoryOutputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
        ResolveMemoryOutputStreamMethod "seek" o = Gio.Seekable.SeekableSeekMethodInfo
        ResolveMemoryOutputStreamMethod "splice" o = Gio.OutputStream.OutputStreamSpliceMethodInfo
        ResolveMemoryOutputStreamMethod "spliceAsync" o = Gio.OutputStream.OutputStreamSpliceAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "spliceFinish" o = Gio.OutputStream.OutputStreamSpliceFinishMethodInfo
        ResolveMemoryOutputStreamMethod "stealAsBytes" o = MemoryOutputStreamStealAsBytesMethodInfo
        ResolveMemoryOutputStreamMethod "stealData" o = MemoryOutputStreamStealDataMethodInfo
        ResolveMemoryOutputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
        ResolveMemoryOutputStreamMethod "tell" o = Gio.Seekable.SeekableTellMethodInfo
        ResolveMemoryOutputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
        ResolveMemoryOutputStreamMethod "truncate" o = Gio.Seekable.SeekableTruncateMethodInfo
        ResolveMemoryOutputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
        ResolveMemoryOutputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
        ResolveMemoryOutputStreamMethod "write" o = Gio.OutputStream.OutputStreamWriteMethodInfo
        ResolveMemoryOutputStreamMethod "writeAll" o = Gio.OutputStream.OutputStreamWriteAllMethodInfo
        ResolveMemoryOutputStreamMethod "writeAllAsync" o = Gio.OutputStream.OutputStreamWriteAllAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "writeAllFinish" o = Gio.OutputStream.OutputStreamWriteAllFinishMethodInfo
        ResolveMemoryOutputStreamMethod "writeAsync" o = Gio.OutputStream.OutputStreamWriteAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "writeBytes" o = Gio.OutputStream.OutputStreamWriteBytesMethodInfo
        ResolveMemoryOutputStreamMethod "writeBytesAsync" o = Gio.OutputStream.OutputStreamWriteBytesAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "writeBytesFinish" o = Gio.OutputStream.OutputStreamWriteBytesFinishMethodInfo
        ResolveMemoryOutputStreamMethod "writeFinish" o = Gio.OutputStream.OutputStreamWriteFinishMethodInfo
        ResolveMemoryOutputStreamMethod "writeNonblocking" o = Gio.PollableOutputStream.PollableOutputStreamWriteNonblockingMethodInfo
        ResolveMemoryOutputStreamMethod "writev" o = Gio.OutputStream.OutputStreamWritevMethodInfo
        ResolveMemoryOutputStreamMethod "writevAll" o = Gio.OutputStream.OutputStreamWritevAllMethodInfo
        ResolveMemoryOutputStreamMethod "writevAllAsync" o = Gio.OutputStream.OutputStreamWritevAllAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "writevAllFinish" o = Gio.OutputStream.OutputStreamWritevAllFinishMethodInfo
        ResolveMemoryOutputStreamMethod "writevAsync" o = Gio.OutputStream.OutputStreamWritevAsyncMethodInfo
        ResolveMemoryOutputStreamMethod "writevFinish" o = Gio.OutputStream.OutputStreamWritevFinishMethodInfo
        ResolveMemoryOutputStreamMethod "writevNonblocking" o = Gio.PollableOutputStream.PollableOutputStreamWritevNonblockingMethodInfo
        ResolveMemoryOutputStreamMethod "getData" o = MemoryOutputStreamGetDataMethodInfo
        ResolveMemoryOutputStreamMethod "getDataSize" o = MemoryOutputStreamGetDataSizeMethodInfo
        ResolveMemoryOutputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
        ResolveMemoryOutputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
        ResolveMemoryOutputStreamMethod "getSize" o = MemoryOutputStreamGetSizeMethodInfo
        ResolveMemoryOutputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
        ResolveMemoryOutputStreamMethod "setPending" o = Gio.OutputStream.OutputStreamSetPendingMethodInfo
        ResolveMemoryOutputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
        ResolveMemoryOutputStreamMethod l o = O.MethodResolutionFailed l o

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

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveMemoryOutputStreamMethod t MemoryOutputStream, O.MethodInfo info MemoryOutputStream p) => O.IsLabel t (MemoryOutputStream -> 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 "data"
       -- Type: TBasicType TPtr
       -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
       -- Nullable: (Just True,Nothing)

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

    @
    'Data.GI.Base.Attributes.get' memoryOutputStream #data
    @
    -}
    getMemoryOutputStreamData :: (MonadIO m, IsMemoryOutputStream o) => o -> m (Ptr ())
    getMemoryOutputStreamData obj = liftIO $ getObjectPropertyPtr obj "data"

    {- |
    Construct a `GValueConstruct` with valid value for the “@data@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
    -}
    constructMemoryOutputStreamData :: (IsMemoryOutputStream o) => Ptr () -> IO (GValueConstruct o)
    constructMemoryOutputStreamData val = constructObjectPropertyPtr "data" val

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamDataPropertyInfo
    instance AttrInfo MemoryOutputStreamDataPropertyInfo where
        type AttrAllowedOps MemoryOutputStreamDataPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
        type AttrSetTypeConstraint MemoryOutputStreamDataPropertyInfo = (~) (Ptr ())
        type AttrBaseTypeConstraint MemoryOutputStreamDataPropertyInfo = IsMemoryOutputStream
        type AttrGetType MemoryOutputStreamDataPropertyInfo = (Ptr ())
        type AttrLabel MemoryOutputStreamDataPropertyInfo = "data"
        type AttrOrigin MemoryOutputStreamDataPropertyInfo = MemoryOutputStream
        attrGet _ = getMemoryOutputStreamData
        attrSet _ = undefined
        attrConstruct _ = constructMemoryOutputStreamData
        attrClear _ = undefined
    #endif

    -- VVV Prop "data-size"
       -- Type: TBasicType TULong
       -- Flags: [PropertyReadable]
       -- Nullable: (Nothing,Nothing)

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

    @
    'Data.GI.Base.Attributes.get' memoryOutputStream #dataSize
    @
    -}
    getMemoryOutputStreamDataSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong
    getMemoryOutputStreamDataSize obj = liftIO $ getObjectPropertyULong obj "data-size"

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamDataSizePropertyInfo
    instance AttrInfo MemoryOutputStreamDataSizePropertyInfo where
        type AttrAllowedOps MemoryOutputStreamDataSizePropertyInfo = '[ 'AttrGet]
        type AttrSetTypeConstraint MemoryOutputStreamDataSizePropertyInfo = (~) ()
        type AttrBaseTypeConstraint MemoryOutputStreamDataSizePropertyInfo = IsMemoryOutputStream
        type AttrGetType MemoryOutputStreamDataSizePropertyInfo = CULong
        type AttrLabel MemoryOutputStreamDataSizePropertyInfo = "data-size"
        type AttrOrigin MemoryOutputStreamDataSizePropertyInfo = MemoryOutputStream
        attrGet _ = getMemoryOutputStreamDataSize
        attrSet _ = undefined
        attrConstruct _ = undefined
        attrClear _ = undefined
    #endif

    -- VVV Prop "size"
       -- Type: TBasicType TULong
       -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
       -- Nullable: (Nothing,Nothing)

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

    @
    'Data.GI.Base.Attributes.get' memoryOutputStream #size
    @
    -}
    getMemoryOutputStreamSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong
    getMemoryOutputStreamSize obj = liftIO $ getObjectPropertyULong obj "size"

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

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamSizePropertyInfo
    instance AttrInfo MemoryOutputStreamSizePropertyInfo where
        type AttrAllowedOps MemoryOutputStreamSizePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
        type AttrSetTypeConstraint MemoryOutputStreamSizePropertyInfo = (~) CULong
        type AttrBaseTypeConstraint MemoryOutputStreamSizePropertyInfo = IsMemoryOutputStream
        type AttrGetType MemoryOutputStreamSizePropertyInfo = CULong
        type AttrLabel MemoryOutputStreamSizePropertyInfo = "size"
        type AttrOrigin MemoryOutputStreamSizePropertyInfo = MemoryOutputStream
        attrGet _ = getMemoryOutputStreamSize
        attrSet _ = undefined
        attrConstruct _ = constructMemoryOutputStreamSize
        attrClear _ = undefined
    #endif

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList MemoryOutputStream
    type instance O.AttributeList MemoryOutputStream = MemoryOutputStreamAttributeList
    type MemoryOutputStreamAttributeList = ('[ '("data", MemoryOutputStreamDataPropertyInfo), '("dataSize", MemoryOutputStreamDataSizePropertyInfo), '("size", MemoryOutputStreamSizePropertyInfo)] :: [(Symbol, *)])
    #endif

    #if ENABLE_OVERLOADING
    memoryOutputStreamData :: AttrLabelProxy "data"
    memoryOutputStreamData = AttrLabelProxy

    memoryOutputStreamDataSize :: AttrLabelProxy "dataSize"
    memoryOutputStreamDataSize = AttrLabelProxy

    memoryOutputStreamSize :: AttrLabelProxy "size"
    memoryOutputStreamSize = AttrLabelProxy

    #endif

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

    #endif

    -- method MemoryOutputStream::new_resizable
    -- method type : Constructor
    -- Args : []
    -- Lengths : []
    -- returnType : Just (TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"}))
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_memory_output_stream_new_resizable" g_memory_output_stream_new_resizable ::
        IO (Ptr MemoryOutputStream)

    {- |
    Creates a new 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream', using 'GI.GLib.Functions.realloc' and 'GI.GLib.Functions.free'
    for memory allocation.

    /Since: 2.36/
    -}
    memoryOutputStreamNewResizable ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        m MemoryOutputStream
    memoryOutputStreamNewResizable  = liftIO $ do
        result <- g_memory_output_stream_new_resizable
        checkUnexpectedReturnNULL "memoryOutputStreamNewResizable" result
        result' <- (wrapObject MemoryOutputStream) result
        return result'

    #if ENABLE_OVERLOADING
    #endif

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

    foreign import ccall "g_memory_output_stream_get_data" g_memory_output_stream_get_data ::
        Ptr MemoryOutputStream ->               -- ostream : TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"})
        IO (Ptr ())

    {- |
    Gets any loaded data from the /@ostream@/.

    Note that the returned pointer may become invalid on the next
    write or truncate operation on the stream.
    -}
    memoryOutputStreamGetData ::
        (B.CallStack.HasCallStack, MonadIO m, IsMemoryOutputStream a) =>
        a
        {- ^ /@ostream@/: a 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' -}
        -> m (Ptr ())
        {- ^ __Returns:__ pointer to the stream\'s data, or 'Nothing' if the data
       has been stolen -}
    memoryOutputStreamGetData ostream = liftIO $ do
        ostream' <- unsafeManagedPtrCastPtr ostream
        result <- g_memory_output_stream_get_data ostream'
        touchManagedPtr ostream
        return result

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamGetDataMethodInfo
    instance (signature ~ (m (Ptr ())), MonadIO m, IsMemoryOutputStream a) => O.MethodInfo MemoryOutputStreamGetDataMethodInfo a signature where
        overloadedMethod _ = memoryOutputStreamGetData

    #endif

    -- method MemoryOutputStream::get_data_size
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "ostream", argType = TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMemoryOutputStream", 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_memory_output_stream_get_data_size" g_memory_output_stream_get_data_size ::
        Ptr MemoryOutputStream ->               -- ostream : TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"})
        IO Word64

    {- |
    Returns the number of bytes from the start up to including the last
    byte written in the stream that has not been truncated away.

    /Since: 2.18/
    -}
    memoryOutputStreamGetDataSize ::
        (B.CallStack.HasCallStack, MonadIO m, IsMemoryOutputStream a) =>
        a
        {- ^ /@ostream@/: a 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' -}
        -> m Word64
        {- ^ __Returns:__ the number of bytes written to the stream -}
    memoryOutputStreamGetDataSize ostream = liftIO $ do
        ostream' <- unsafeManagedPtrCastPtr ostream
        result <- g_memory_output_stream_get_data_size ostream'
        touchManagedPtr ostream
        return result

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamGetDataSizeMethodInfo
    instance (signature ~ (m Word64), MonadIO m, IsMemoryOutputStream a) => O.MethodInfo MemoryOutputStreamGetDataSizeMethodInfo a signature where
        overloadedMethod _ = memoryOutputStreamGetDataSize

    #endif

    -- method MemoryOutputStream::get_size
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "ostream", argType = TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMemoryOutputStream", 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_memory_output_stream_get_size" g_memory_output_stream_get_size ::
        Ptr MemoryOutputStream ->               -- ostream : TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"})
        IO Word64

    {- |
    Gets the size of the currently allocated data area (available from
    'GI.Gio.Objects.MemoryOutputStream.memoryOutputStreamGetData').

    You probably don\'t want to use this function on resizable streams.
    See 'GI.Gio.Objects.MemoryOutputStream.memoryOutputStreamGetDataSize' instead.  For resizable
    streams the size returned by this function is an implementation
    detail and may be change at any time in response to operations on the
    stream.

    If the stream is fixed-sized (ie: no realloc was passed to
    @/g_memory_output_stream_new()/@) then this is the maximum size of the
    stream and further writes will return 'GI.Gio.Enums.IOErrorEnumNoSpace'.

    In any case, if you want the number of bytes currently written to the
    stream, use 'GI.Gio.Objects.MemoryOutputStream.memoryOutputStreamGetDataSize'.
    -}
    memoryOutputStreamGetSize ::
        (B.CallStack.HasCallStack, MonadIO m, IsMemoryOutputStream a) =>
        a
        {- ^ /@ostream@/: a 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' -}
        -> m Word64
        {- ^ __Returns:__ the number of bytes allocated for the data buffer -}
    memoryOutputStreamGetSize ostream = liftIO $ do
        ostream' <- unsafeManagedPtrCastPtr ostream
        result <- g_memory_output_stream_get_size ostream'
        touchManagedPtr ostream
        return result

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamGetSizeMethodInfo
    instance (signature ~ (m Word64), MonadIO m, IsMemoryOutputStream a) => O.MethodInfo MemoryOutputStreamGetSizeMethodInfo a signature where
        overloadedMethod _ = memoryOutputStreamGetSize

    #endif

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

    foreign import ccall "g_memory_output_stream_steal_as_bytes" g_memory_output_stream_steal_as_bytes ::
        Ptr MemoryOutputStream ->               -- ostream : TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"})
        IO (Ptr GLib.Bytes.Bytes)

    {- |
    Returns data from the /@ostream@/ as a 'GI.GLib.Structs.Bytes.Bytes'. /@ostream@/ must be
    closed before calling this function.

    /Since: 2.34/
    -}
    memoryOutputStreamStealAsBytes ::
        (B.CallStack.HasCallStack, MonadIO m, IsMemoryOutputStream a) =>
        a
        {- ^ /@ostream@/: a 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' -}
        -> m GLib.Bytes.Bytes
        {- ^ __Returns:__ the stream\'s data -}
    memoryOutputStreamStealAsBytes ostream = liftIO $ do
        ostream' <- unsafeManagedPtrCastPtr ostream
        result <- g_memory_output_stream_steal_as_bytes ostream'
        checkUnexpectedReturnNULL "memoryOutputStreamStealAsBytes" result
        result' <- (wrapBoxed GLib.Bytes.Bytes) result
        touchManagedPtr ostream
        return result'

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamStealAsBytesMethodInfo
    instance (signature ~ (m GLib.Bytes.Bytes), MonadIO m, IsMemoryOutputStream a) => O.MethodInfo MemoryOutputStreamStealAsBytesMethodInfo a signature where
        overloadedMethod _ = memoryOutputStreamStealAsBytes

    #endif

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

    foreign import ccall "g_memory_output_stream_steal_data" g_memory_output_stream_steal_data ::
        Ptr MemoryOutputStream ->               -- ostream : TInterface (Name {namespace = "Gio", name = "MemoryOutputStream"})
        IO (Ptr ())

    {- |
    Gets any loaded data from the /@ostream@/. Ownership of the data
    is transferred to the caller; when no longer needed it must be
    freed using the free function set in /@ostream@/\'s
    'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream':@/destroy-function/@ property.

    /@ostream@/ must be closed before calling this function.

    /Since: 2.26/
    -}
    memoryOutputStreamStealData ::
        (B.CallStack.HasCallStack, MonadIO m, IsMemoryOutputStream a) =>
        a
        {- ^ /@ostream@/: a 'GI.Gio.Objects.MemoryOutputStream.MemoryOutputStream' -}
        -> m (Ptr ())
        {- ^ __Returns:__ the stream\'s data, or 'Nothing' if it has previously
       been stolen -}
    memoryOutputStreamStealData ostream = liftIO $ do
        ostream' <- unsafeManagedPtrCastPtr ostream
        result <- g_memory_output_stream_steal_data ostream'
        touchManagedPtr ostream
        return result

    #if ENABLE_OVERLOADING
    data MemoryOutputStreamStealDataMethodInfo
    instance (signature ~ (m (Ptr ())), MonadIO m, IsMemoryOutputStream a) => O.MethodInfo MemoryOutputStreamStealDataMethodInfo a signature where
        overloadedMethod _ = memoryOutputStreamStealData

    #endif