{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- @GStrvBuilder@ is a helper object to build a 'P.Nothing'-terminated string arrays.
-- 
-- The following example shows how to build a two element array:
-- 
-- 
-- === /c code/
-- >  g_autoptr(GStrvBuilder) builder = g_strv_builder_new ();
-- >  g_strv_builder_add (builder, "hello");
-- >  g_strv_builder_add (builder, "world");
-- >  g_auto(GStrv) array = g_strv_builder_end (builder);
-- 
-- 
-- /Since: 2.68/

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

module GI.GLib.Structs.StrvBuilder
    ( 

-- * Exported types
    StrvBuilder(..)                         ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [add]("GI.GLib.Structs.StrvBuilder#g:method:add"), [addv]("GI.GLib.Structs.StrvBuilder#g:method:addv"), [end]("GI.GLib.Structs.StrvBuilder#g:method:end"), [ref]("GI.GLib.Structs.StrvBuilder#g:method:ref"), [take]("GI.GLib.Structs.StrvBuilder#g:method:take"), [unref]("GI.GLib.Structs.StrvBuilder#g:method:unref").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveStrvBuilderMethod                ,
#endif

-- ** add #method:add#

#if defined(ENABLE_OVERLOADING)
    StrvBuilderAddMethodInfo                ,
#endif
    strvBuilderAdd                          ,


-- ** addv #method:addv#

#if defined(ENABLE_OVERLOADING)
    StrvBuilderAddvMethodInfo               ,
#endif
    strvBuilderAddv                         ,


-- ** end #method:end#

#if defined(ENABLE_OVERLOADING)
    StrvBuilderEndMethodInfo                ,
#endif
    strvBuilderEnd                          ,


-- ** new #method:new#

    strvBuilderNew                          ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    StrvBuilderRefMethodInfo                ,
#endif
    strvBuilderRef                          ,


-- ** take #method:take#

#if defined(ENABLE_OVERLOADING)
    StrvBuilderTakeMethodInfo               ,
#endif
    strvBuilderTake                         ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    StrvBuilderUnrefMethodInfo              ,
#endif
    strvBuilderUnref                        ,




    ) 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.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)

#else

#endif

-- | Memory-managed wrapper type.
newtype StrvBuilder = StrvBuilder (SP.ManagedPtr StrvBuilder)
    deriving (StrvBuilder -> StrvBuilder -> Bool
(StrvBuilder -> StrvBuilder -> Bool)
-> (StrvBuilder -> StrvBuilder -> Bool) -> Eq StrvBuilder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StrvBuilder -> StrvBuilder -> Bool
== :: StrvBuilder -> StrvBuilder -> Bool
$c/= :: StrvBuilder -> StrvBuilder -> Bool
/= :: StrvBuilder -> StrvBuilder -> Bool
Eq)

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

foreign import ccall "g_strv_builder_get_type" c_g_strv_builder_get_type :: 
    IO GType

type instance O.ParentTypes StrvBuilder = '[]
instance O.HasParentTypes StrvBuilder

instance B.Types.TypedObject StrvBuilder where
    glibType :: IO GType
glibType = IO GType
c_g_strv_builder_get_type

instance B.Types.GBoxed StrvBuilder

-- | Convert 'StrvBuilder' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe StrvBuilder) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_strv_builder_get_type
    gvalueSet_ :: Ptr GValue -> Maybe StrvBuilder -> IO ()
gvalueSet_ Ptr GValue
gv Maybe StrvBuilder
P.Nothing = Ptr GValue -> Ptr StrvBuilder -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr StrvBuilder
forall a. Ptr a
FP.nullPtr :: FP.Ptr StrvBuilder)
    gvalueSet_ Ptr GValue
gv (P.Just StrvBuilder
obj) = StrvBuilder -> (Ptr StrvBuilder -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr StrvBuilder
obj (Ptr GValue -> Ptr StrvBuilder -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe StrvBuilder)
gvalueGet_ Ptr GValue
gv = do
        Ptr StrvBuilder
ptr <- Ptr GValue -> IO (Ptr StrvBuilder)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr StrvBuilder)
        if Ptr StrvBuilder
ptr Ptr StrvBuilder -> Ptr StrvBuilder -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr StrvBuilder
forall a. Ptr a
FP.nullPtr
        then StrvBuilder -> Maybe StrvBuilder
forall a. a -> Maybe a
P.Just (StrvBuilder -> Maybe StrvBuilder)
-> IO StrvBuilder -> IO (Maybe StrvBuilder)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr StrvBuilder -> StrvBuilder)
-> Ptr StrvBuilder -> IO StrvBuilder
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr StrvBuilder -> StrvBuilder
StrvBuilder Ptr StrvBuilder
ptr
        else Maybe StrvBuilder -> IO (Maybe StrvBuilder)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe StrvBuilder
forall a. Maybe a
P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList StrvBuilder
type instance O.AttributeList StrvBuilder = StrvBuilderAttributeList
type StrvBuilderAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

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

foreign import ccall "g_strv_builder_new" g_strv_builder_new :: 
    IO (Ptr StrvBuilder)

-- | Creates a new t'GI.GLib.Structs.StrvBuilder.StrvBuilder' with a reference count of 1.
-- Use 'GI.GLib.Structs.StrvBuilder.strvBuilderUnref' on the returned value when no longer needed.
-- 
-- /Since: 2.68/
strvBuilderNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m StrvBuilder
    -- ^ __Returns:__ the new t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
strvBuilderNew :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m StrvBuilder
strvBuilderNew  = IO StrvBuilder -> m StrvBuilder
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO StrvBuilder -> m StrvBuilder)
-> IO StrvBuilder -> m StrvBuilder
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
result <- IO (Ptr StrvBuilder)
g_strv_builder_new
    Text -> Ptr StrvBuilder -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"strvBuilderNew" Ptr StrvBuilder
result
    StrvBuilder
result' <- ((ManagedPtr StrvBuilder -> StrvBuilder)
-> Ptr StrvBuilder -> IO StrvBuilder
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr StrvBuilder -> StrvBuilder
StrvBuilder) Ptr StrvBuilder
result
    StrvBuilder -> IO StrvBuilder
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return StrvBuilder
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method StrvBuilder::add
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "builder"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "StrvBuilder" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GStrvBuilder" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_builder_add" g_strv_builder_add :: 
    Ptr StrvBuilder ->                      -- builder : TInterface (Name {namespace = "GLib", name = "StrvBuilder"})
    CString ->                              -- value : TBasicType TUTF8
    IO ()

-- | Add a string to the end of the array.
-- 
-- Since 2.68
strvBuilderAdd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    StrvBuilder
    -- ^ /@builder@/: a t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
    -> T.Text
    -- ^ /@value@/: a string.
    -> m ()
strvBuilderAdd :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
StrvBuilder -> Text -> m ()
strvBuilderAdd StrvBuilder
builder Text
value = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
builder' <- StrvBuilder -> IO (Ptr StrvBuilder)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StrvBuilder
builder
    CString
value' <- Text -> IO CString
textToCString Text
value
    Ptr StrvBuilder -> CString -> IO ()
g_strv_builder_add Ptr StrvBuilder
builder' CString
value'
    StrvBuilder -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StrvBuilder
builder
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data StrvBuilderAddMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.OverloadedMethod StrvBuilderAddMethodInfo StrvBuilder signature where
    overloadedMethod = strvBuilderAdd

instance O.OverloadedMethodInfo StrvBuilderAddMethodInfo StrvBuilder where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.StrvBuilder.strvBuilderAdd",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-StrvBuilder.html#v:strvBuilderAdd"
        })


#endif

-- method StrvBuilder::addv
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "builder"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "StrvBuilder" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GStrvBuilder" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the vector of strings to add"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_builder_addv" g_strv_builder_addv :: 
    Ptr StrvBuilder ->                      -- builder : TInterface (Name {namespace = "GLib", name = "StrvBuilder"})
    Ptr CString ->                          -- value : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()

-- | Appends all the strings in the given vector to the builder.
-- 
-- Since 2.70
strvBuilderAddv ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    StrvBuilder
    -- ^ /@builder@/: a t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
    -> [T.Text]
    -- ^ /@value@/: the vector of strings to add
    -> m ()
strvBuilderAddv :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
StrvBuilder -> [Text] -> m ()
strvBuilderAddv StrvBuilder
builder [Text]
value = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
builder' <- StrvBuilder -> IO (Ptr StrvBuilder)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StrvBuilder
builder
    Ptr CString
value' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
value
    Ptr StrvBuilder -> Ptr CString -> IO ()
g_strv_builder_addv Ptr StrvBuilder
builder' Ptr CString
value'
    StrvBuilder -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StrvBuilder
builder
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
value'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
value'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data StrvBuilderAddvMethodInfo
instance (signature ~ ([T.Text] -> m ()), MonadIO m) => O.OverloadedMethod StrvBuilderAddvMethodInfo StrvBuilder signature where
    overloadedMethod = strvBuilderAddv

instance O.OverloadedMethodInfo StrvBuilderAddvMethodInfo StrvBuilder where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.StrvBuilder.strvBuilderAddv",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-StrvBuilder.html#v:strvBuilderAddv"
        })


#endif

-- method StrvBuilder::end
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "builder"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "StrvBuilder" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GStrvBuilder" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_builder_end" g_strv_builder_end :: 
    Ptr StrvBuilder ->                      -- builder : TInterface (Name {namespace = "GLib", name = "StrvBuilder"})
    IO (Ptr CString)

-- | Ends the builder process and returns the constructed NULL-terminated string
-- array. The returned value should be freed with 'GI.GLib.Functions.strfreev' when no longer
-- needed.
strvBuilderEnd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    StrvBuilder
    -- ^ /@builder@/: a t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
    -> m [T.Text]
    -- ^ __Returns:__ the constructed string array.
    -- 
    -- Since 2.68
strvBuilderEnd :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
StrvBuilder -> m [Text]
strvBuilderEnd StrvBuilder
builder = IO [Text] -> m [Text]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
builder' <- StrvBuilder -> IO (Ptr StrvBuilder)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StrvBuilder
builder
    Ptr CString
result <- Ptr StrvBuilder -> IO (Ptr CString)
g_strv_builder_end Ptr StrvBuilder
builder'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"strvBuilderEnd" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    StrvBuilder -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StrvBuilder
builder
    [Text] -> IO [Text]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if defined(ENABLE_OVERLOADING)
data StrvBuilderEndMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m) => O.OverloadedMethod StrvBuilderEndMethodInfo StrvBuilder signature where
    overloadedMethod = strvBuilderEnd

instance O.OverloadedMethodInfo StrvBuilderEndMethodInfo StrvBuilder where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.StrvBuilder.strvBuilderEnd",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-StrvBuilder.html#v:strvBuilderEnd"
        })


#endif

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

foreign import ccall "g_strv_builder_ref" g_strv_builder_ref :: 
    Ptr StrvBuilder ->                      -- builder : TInterface (Name {namespace = "GLib", name = "StrvBuilder"})
    IO (Ptr StrvBuilder)

-- | Atomically increments the reference count of /@builder@/ by one.
-- This function is thread-safe and may be called from any thread.
-- 
-- /Since: 2.68/
strvBuilderRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    StrvBuilder
    -- ^ /@builder@/: a t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
    -> m StrvBuilder
    -- ^ __Returns:__ The passed in t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
strvBuilderRef :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
StrvBuilder -> m StrvBuilder
strvBuilderRef StrvBuilder
builder = IO StrvBuilder -> m StrvBuilder
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO StrvBuilder -> m StrvBuilder)
-> IO StrvBuilder -> m StrvBuilder
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
builder' <- StrvBuilder -> IO (Ptr StrvBuilder)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StrvBuilder
builder
    Ptr StrvBuilder
result <- Ptr StrvBuilder -> IO (Ptr StrvBuilder)
g_strv_builder_ref Ptr StrvBuilder
builder'
    Text -> Ptr StrvBuilder -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"strvBuilderRef" Ptr StrvBuilder
result
    StrvBuilder
result' <- ((ManagedPtr StrvBuilder -> StrvBuilder)
-> Ptr StrvBuilder -> IO StrvBuilder
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr StrvBuilder -> StrvBuilder
StrvBuilder) Ptr StrvBuilder
result
    StrvBuilder -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StrvBuilder
builder
    StrvBuilder -> IO StrvBuilder
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return StrvBuilder
result'

#if defined(ENABLE_OVERLOADING)
data StrvBuilderRefMethodInfo
instance (signature ~ (m StrvBuilder), MonadIO m) => O.OverloadedMethod StrvBuilderRefMethodInfo StrvBuilder signature where
    overloadedMethod = strvBuilderRef

instance O.OverloadedMethodInfo StrvBuilderRefMethodInfo StrvBuilder where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.StrvBuilder.strvBuilderRef",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-StrvBuilder.html#v:strvBuilderRef"
        })


#endif

-- method StrvBuilder::take
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "builder"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "StrvBuilder" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GStrvBuilder" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a string.\n    Ownership of the string is transferred to the #GStrvBuilder"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_builder_take" g_strv_builder_take :: 
    Ptr StrvBuilder ->                      -- builder : TInterface (Name {namespace = "GLib", name = "StrvBuilder"})
    CString ->                              -- value : TBasicType TUTF8
    IO ()

-- | Add a string to the end of the array. After /@value@/ belongs to the
-- t'GI.GLib.Structs.StrvBuilder.StrvBuilder' and may no longer be modified by the caller.
-- 
-- Since 2.80
strvBuilderTake ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    StrvBuilder
    -- ^ /@builder@/: a t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
    -> T.Text
    -- ^ /@value@/: a string.
    --     Ownership of the string is transferred to the t'GI.GLib.Structs.StrvBuilder.StrvBuilder'
    -> m ()
strvBuilderTake :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
StrvBuilder -> Text -> m ()
strvBuilderTake StrvBuilder
builder Text
value = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
builder' <- StrvBuilder -> IO (Ptr StrvBuilder)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StrvBuilder
builder
    CString
value' <- Text -> IO CString
textToCString Text
value
    Ptr StrvBuilder -> CString -> IO ()
g_strv_builder_take Ptr StrvBuilder
builder' CString
value'
    StrvBuilder -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StrvBuilder
builder
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data StrvBuilderTakeMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.OverloadedMethod StrvBuilderTakeMethodInfo StrvBuilder signature where
    overloadedMethod = strvBuilderTake

instance O.OverloadedMethodInfo StrvBuilderTakeMethodInfo StrvBuilder where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.StrvBuilder.strvBuilderTake",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-StrvBuilder.html#v:strvBuilderTake"
        })


#endif

-- method StrvBuilder::unref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "builder"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "StrvBuilder" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #GStrvBuilder allocated by g_strv_builder_new()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_builder_unref" g_strv_builder_unref :: 
    Ptr StrvBuilder ->                      -- builder : TInterface (Name {namespace = "GLib", name = "StrvBuilder"})
    IO ()

-- | Decreases the reference count on /@builder@/.
-- 
-- In the event that there are no more references, releases all memory
-- associated with the t'GI.GLib.Structs.StrvBuilder.StrvBuilder'.
-- 
-- /Since: 2.68/
strvBuilderUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    StrvBuilder
    -- ^ /@builder@/: a t'GI.GLib.Structs.StrvBuilder.StrvBuilder' allocated by 'GI.GLib.Structs.StrvBuilder.strvBuilderNew'
    -> m ()
strvBuilderUnref :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
StrvBuilder -> m ()
strvBuilderUnref StrvBuilder
builder = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr StrvBuilder
builder' <- StrvBuilder -> IO (Ptr StrvBuilder)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed StrvBuilder
builder
    Ptr StrvBuilder -> IO ()
g_strv_builder_unref Ptr StrvBuilder
builder'
    StrvBuilder -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StrvBuilder
builder
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data StrvBuilderUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod StrvBuilderUnrefMethodInfo StrvBuilder signature where
    overloadedMethod = strvBuilderUnref

instance O.OverloadedMethodInfo StrvBuilderUnrefMethodInfo StrvBuilder where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.StrvBuilder.strvBuilderUnref",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-StrvBuilder.html#v:strvBuilderUnref"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveStrvBuilderMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveStrvBuilderMethod "add" o = StrvBuilderAddMethodInfo
    ResolveStrvBuilderMethod "addv" o = StrvBuilderAddvMethodInfo
    ResolveStrvBuilderMethod "end" o = StrvBuilderEndMethodInfo
    ResolveStrvBuilderMethod "ref" o = StrvBuilderRefMethodInfo
    ResolveStrvBuilderMethod "take" o = StrvBuilderTakeMethodInfo
    ResolveStrvBuilderMethod "unref" o = StrvBuilderUnrefMethodInfo
    ResolveStrvBuilderMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveStrvBuilderMethod t StrvBuilder, O.OverloadedMethod info StrvBuilder p) => OL.IsLabel t (StrvBuilder -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveStrvBuilderMethod t StrvBuilder, O.OverloadedMethod info StrvBuilder p, R.HasField t StrvBuilder p) => R.HasField t StrvBuilder p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveStrvBuilderMethod t StrvBuilder, O.OverloadedMethodInfo info StrvBuilder) => OL.IsLabel t (O.MethodProxy info StrvBuilder) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif