    {- |
    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.GLib.Structs.VariantDict.VariantDict' is a mutable interface to 'GVariant' dictionaries.

    It can be used for doing a sequence of dictionary lookups in an
    efficient way on an existing 'GVariant' dictionary or it can be used
    to construct new dictionaries with a hashtable-like interface.  It
    can also be used for taking existing dictionaries and modifying them
    in order to create new ones.

    'GI.GLib.Structs.VariantDict.VariantDict' can only be used with @/G_VARIANT_TYPE_VARDICT/@
    dictionaries.

    It is possible to use 'GI.GLib.Structs.VariantDict.VariantDict' allocated on the stack or on the
    heap.  When using a stack-allocated 'GI.GLib.Structs.VariantDict.VariantDict', you begin with a
    call to @/g_variant_dict_init()/@ and free the resources with a call to
    'GI.GLib.Structs.VariantDict.variantDictClear'.

    Heap-allocated 'GI.GLib.Structs.VariantDict.VariantDict' follows normal refcounting rules: you
    allocate it with 'GI.GLib.Structs.VariantDict.variantDictNew' and use 'GI.GLib.Structs.VariantDict.variantDictRef'
    and 'GI.GLib.Structs.VariantDict.variantDictUnref'.

    'GI.GLib.Structs.VariantDict.variantDictEnd' is used to convert the 'GI.GLib.Structs.VariantDict.VariantDict' back into a
    dictionary-type 'GVariant'.  When used with stack-allocated instances,
    this also implicitly frees all associated memory, but for
    heap-allocated instances, you must still call 'GI.GLib.Structs.VariantDict.variantDictUnref'
    afterwards.

    You will typically want to use a heap-allocated 'GI.GLib.Structs.VariantDict.VariantDict' when
    you expose it as part of an API.  For most other uses, the
    stack-allocated form will be more convenient.

    Consider the following two examples that do the same thing in each
    style: take an existing dictionary and look up the \"count\" uint32
    key, adding 1 to it if it is found, or returning an error if the
    key is not found.  Each returns the new dictionary as a floating
    'GVariant'.

    == Using a stack-allocated GVariantDict

    === /C code/
    >
    >  GVariant *
    >  add_to_count (GVariant  *orig,
    >                GError   **error)
    >  {
    >    GVariantDict dict;
    >    guint32 count;
    >
    >    g_variant_dict_init (&dict, orig);
    >    if (!g_variant_dict_lookup (&dict, "count", "u", &count))
    >      {
    >        g_set_error (...);
    >        g_variant_dict_clear (&dict);
    >        return NULL;
    >      }
    >
    >    g_variant_dict_insert (&dict, "count", "u", count + 1);
    >
    >    return g_variant_dict_end (&dict);
    >  }

    == Using heap-allocated GVariantDict

    === /C code/
    >
    >  GVariant *
    >  add_to_count (GVariant  *orig,
    >                GError   **error)
    >  {
    >    GVariantDict *dict;
    >    GVariant *result;
    >    guint32 count;
    >
    >    dict = g_variant_dict_new (orig);
    >
    >    if (g_variant_dict_lookup (dict, "count", "u", &count))
    >      {
    >        g_variant_dict_insert (dict, "count", "u", count + 1);
    >        result = g_variant_dict_end (dict);
    >      }
    >    else
    >      {
    >        g_set_error (...);
    >        result = NULL;
    >      }
    >
    >    g_variant_dict_unref (dict);
    >
    >    return result;
    >  }

    /Since: 2.40/
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.GLib.Structs.VariantDict
        (

    -- * Exported types
        VariantDict(..)                         ,
        noVariantDict                           ,

     -- * Methods
    -- ** clear #method:clear#

    #if ENABLE_OVERLOADING
        VariantDictClearMethodInfo              ,
    #endif
        variantDictClear                        ,

    -- ** contains #method:contains#

    #if ENABLE_OVERLOADING
        VariantDictContainsMethodInfo           ,
    #endif
        variantDictContains                     ,

    -- ** end #method:end#

    #if ENABLE_OVERLOADING
        VariantDictEndMethodInfo                ,
    #endif
        variantDictEnd                          ,

    -- ** insertValue #method:insertValue#

    #if ENABLE_OVERLOADING
        VariantDictInsertValueMethodInfo        ,
    #endif
        variantDictInsertValue                  ,

    -- ** lookupValue #method:lookupValue#

    #if ENABLE_OVERLOADING
        VariantDictLookupValueMethodInfo        ,
    #endif
        variantDictLookupValue                  ,

    -- ** new #method:new#

        variantDictNew                          ,

    -- ** ref #method:ref#

    #if ENABLE_OVERLOADING
        VariantDictRefMethodInfo                ,
    #endif
        variantDictRef                          ,

    -- ** remove #method:remove#

    #if ENABLE_OVERLOADING
        VariantDictRemoveMethodInfo             ,
    #endif
        variantDictRemove                       ,

    -- ** unref #method:unref#

    #if ENABLE_OVERLOADING
        VariantDictUnrefMethodInfo              ,
    #endif
        variantDictUnref                        ,

        ) 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 {-# SOURCE #-} qualified GI.GLib.Structs.VariantType as GLib.VariantType

    -- | Memory-managed wrapper type.
    newtype VariantDict = VariantDict (ManagedPtr VariantDict)
    foreign import ccall "g_variant_dict_get_type" c_g_variant_dict_get_type ::
        IO GType

    instance BoxedObject VariantDict where
        boxedType _ = c_g_variant_dict_get_type

    -- | A convenience alias for `Nothing` :: `Maybe` `VariantDict`.
    noVariantDict :: Maybe VariantDict
    noVariantDict = Nothing

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList VariantDict
    type instance O.AttributeList VariantDict = VariantDictAttributeList
    type VariantDictAttributeList = ('[ ] :: [(Symbol, *)])
    #endif

    -- method VariantDict::new
    -- method type : Constructor
    -- Args : [Arg {argCName = "from_asv", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GVariant with which to initialise the\n  dictionary", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TInterface (Name {namespace = "GLib", name = "VariantDict"}))
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_variant_dict_new" g_variant_dict_new ::
        Ptr GVariant ->                         -- from_asv : TVariant
        IO (Ptr VariantDict)

    {- |
    Allocates and initialises a new 'GI.GLib.Structs.VariantDict.VariantDict'.

    You should call 'GI.GLib.Structs.VariantDict.variantDictUnref' on the return value when it
    is no longer needed.  The memory will not be automatically freed by
    any other call.

    In some cases it may be easier to place a 'GI.GLib.Structs.VariantDict.VariantDict' directly on
    the stack of the calling function and initialise it with
    @/g_variant_dict_init()/@.  This is particularly useful when you are
    using 'GI.GLib.Structs.VariantDict.VariantDict' to construct a 'GVariant'.

    /Since: 2.40/
    -}
    variantDictNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Maybe (GVariant)
        {- ^ /@fromAsv@/: the 'GVariant' with which to initialise the
      dictionary -}
        -> m VariantDict
        {- ^ __Returns:__ a 'GI.GLib.Structs.VariantDict.VariantDict' -}
    variantDictNew fromAsv = liftIO $ do
        maybeFromAsv <- case fromAsv of
            Nothing -> return nullPtr
            Just jFromAsv -> do
                jFromAsv' <- unsafeManagedPtrGetPtr jFromAsv
                return jFromAsv'
        result <- g_variant_dict_new maybeFromAsv
        checkUnexpectedReturnNULL "variantDictNew" result
        result' <- (wrapBoxed VariantDict) result
        whenJust fromAsv touchManagedPtr
        return result'

    #if ENABLE_OVERLOADING
    #endif

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

    foreign import ccall "g_variant_dict_clear" g_variant_dict_clear ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        IO ()

    {- |
    Releases all memory associated with a 'GI.GLib.Structs.VariantDict.VariantDict' without freeing
    the 'GI.GLib.Structs.VariantDict.VariantDict' structure itself.

    It typically only makes sense to do this on a stack-allocated
    'GI.GLib.Structs.VariantDict.VariantDict' if you want to abort building the value part-way
    through.  This function need not be called if you call
    'GI.GLib.Structs.VariantDict.variantDictEnd' and it also doesn\'t need to be called on dicts
    allocated with g_variant_dict_new (see 'GI.GLib.Structs.VariantDict.variantDictUnref' for
    that).

    It is valid to call this function on either an initialised
    'GI.GLib.Structs.VariantDict.VariantDict' or one that was previously cleared by an earlier call
    to 'GI.GLib.Structs.VariantDict.variantDictClear' but it is not valid to call this function
    on uninitialised memory.

    /Since: 2.40/
    -}
    variantDictClear ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> m ()
    variantDictClear dict = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        g_variant_dict_clear dict'
        touchManagedPtr dict
        return ()

    #if ENABLE_OVERLOADING
    data VariantDictClearMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.MethodInfo VariantDictClearMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictClear

    #endif

    -- method VariantDict::contains
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "dict", argType = TInterface (Name {namespace = "GLib", name = "VariantDict"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVariantDict", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to lookup in the dictionary", 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_variant_dict_contains" g_variant_dict_contains ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        CString ->                              -- key : TBasicType TUTF8
        IO CInt

    {- |
    Checks if /@key@/ exists in /@dict@/.

    /Since: 2.40/
    -}
    variantDictContains ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> T.Text
        {- ^ /@key@/: the key to lookup in the dictionary -}
        -> m Bool
        {- ^ __Returns:__ 'True' if /@key@/ is in /@dict@/ -}
    variantDictContains dict key = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        key' <- textToCString key
        result <- g_variant_dict_contains dict' key'
        let result' = (/= 0) result
        touchManagedPtr dict
        freeMem key'
        return result'

    #if ENABLE_OVERLOADING
    data VariantDictContainsMethodInfo
    instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.MethodInfo VariantDictContainsMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictContains

    #endif

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

    foreign import ccall "g_variant_dict_end" g_variant_dict_end ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        IO (Ptr GVariant)

    {- |
    Returns the current value of /@dict@/ as a 'GVariant' of type
    @/G_VARIANT_TYPE_VARDICT/@, clearing it in the process.

    It is not permissible to use /@dict@/ in any way after this call except
    for reference counting operations (in the case of a heap-allocated
    'GI.GLib.Structs.VariantDict.VariantDict') or by reinitialising it with @/g_variant_dict_init()/@ (in
    the case of stack-allocated).

    /Since: 2.40/
    -}
    variantDictEnd ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> m GVariant
        {- ^ __Returns:__ a new, floating, 'GVariant' -}
    variantDictEnd dict = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        result <- g_variant_dict_end dict'
        checkUnexpectedReturnNULL "variantDictEnd" result
        result' <- B.GVariant.newGVariantFromPtr result
        touchManagedPtr dict
        return result'

    #if ENABLE_OVERLOADING
    data VariantDictEndMethodInfo
    instance (signature ~ (m GVariant), MonadIO m) => O.MethodInfo VariantDictEndMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictEnd

    #endif

    -- method VariantDict::insert_value
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "dict", argType = TInterface (Name {namespace = "GLib", name = "VariantDict"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVariantDict", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to insert a value for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to insert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_variant_dict_insert_value" g_variant_dict_insert_value ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        CString ->                              -- key : TBasicType TUTF8
        Ptr GVariant ->                         -- value : TVariant
        IO ()

    {- |
    Inserts (or replaces) a key in a 'GI.GLib.Structs.VariantDict.VariantDict'.

    /@value@/ is consumed if it is floating.

    /Since: 2.40/
    -}
    variantDictInsertValue ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> T.Text
        {- ^ /@key@/: the key to insert a value for -}
        -> GVariant
        {- ^ /@value@/: the value to insert -}
        -> m ()
    variantDictInsertValue dict key value = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        key' <- textToCString key
        value' <- unsafeManagedPtrGetPtr value
        g_variant_dict_insert_value dict' key' value'
        touchManagedPtr dict
        touchManagedPtr value
        freeMem key'
        return ()

    #if ENABLE_OVERLOADING
    data VariantDictInsertValueMethodInfo
    instance (signature ~ (T.Text -> GVariant -> m ()), MonadIO m) => O.MethodInfo VariantDictInsertValueMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictInsertValue

    #endif

    -- method VariantDict::lookup_value
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "dict", argType = TInterface (Name {namespace = "GLib", name = "VariantDict"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVariantDict", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to lookup in the dictionary", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "expected_type", argType = TInterface (Name {namespace = "GLib", name = "VariantType"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GVariantType, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just TVariant
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_variant_dict_lookup_value" g_variant_dict_lookup_value ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        CString ->                              -- key : TBasicType TUTF8
        Ptr GLib.VariantType.VariantType ->     -- expected_type : TInterface (Name {namespace = "GLib", name = "VariantType"})
        IO (Ptr GVariant)

    {- |
    Looks up a value in a 'GI.GLib.Structs.VariantDict.VariantDict'.

    If /@key@/ is not found in /@dictionary@/, 'Nothing' is returned.

    The /@expectedType@/ string specifies what type of value is expected.
    If the value associated with /@key@/ has a different type then 'Nothing' is
    returned.

    If the key is found and the value has the correct type, it is
    returned.  If /@expectedType@/ was specified then any non-'Nothing' return
    value will have this type.

    /Since: 2.40/
    -}
    variantDictLookupValue ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> T.Text
        {- ^ /@key@/: the key to lookup in the dictionary -}
        -> Maybe (GLib.VariantType.VariantType)
        {- ^ /@expectedType@/: a 'GI.GLib.Structs.VariantType.VariantType', or 'Nothing' -}
        -> m GVariant
        {- ^ __Returns:__ the value of the dictionary key, or 'Nothing' -}
    variantDictLookupValue dict key expectedType = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        key' <- textToCString key
        maybeExpectedType <- case expectedType of
            Nothing -> return nullPtr
            Just jExpectedType -> do
                jExpectedType' <- unsafeManagedPtrGetPtr jExpectedType
                return jExpectedType'
        result <- g_variant_dict_lookup_value dict' key' maybeExpectedType
        checkUnexpectedReturnNULL "variantDictLookupValue" result
        result' <- B.GVariant.wrapGVariantPtr result
        touchManagedPtr dict
        whenJust expectedType touchManagedPtr
        freeMem key'
        return result'

    #if ENABLE_OVERLOADING
    data VariantDictLookupValueMethodInfo
    instance (signature ~ (T.Text -> Maybe (GLib.VariantType.VariantType) -> m GVariant), MonadIO m) => O.MethodInfo VariantDictLookupValueMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictLookupValue

    #endif

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

    foreign import ccall "g_variant_dict_ref" g_variant_dict_ref ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        IO (Ptr VariantDict)

    {- |
    Increases the reference count on /@dict@/.

    Don\'t call this on stack-allocated 'GI.GLib.Structs.VariantDict.VariantDict' instances or bad
    things will happen.

    /Since: 2.40/
    -}
    variantDictRef ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a heap-allocated 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> m VariantDict
        {- ^ __Returns:__ a new reference to /@dict@/ -}
    variantDictRef dict = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        result <- g_variant_dict_ref dict'
        checkUnexpectedReturnNULL "variantDictRef" result
        result' <- (wrapBoxed VariantDict) result
        touchManagedPtr dict
        return result'

    #if ENABLE_OVERLOADING
    data VariantDictRefMethodInfo
    instance (signature ~ (m VariantDict), MonadIO m) => O.MethodInfo VariantDictRefMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictRef

    #endif

    -- method VariantDict::remove
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "dict", argType = TInterface (Name {namespace = "GLib", name = "VariantDict"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVariantDict", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to remove", 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_variant_dict_remove" g_variant_dict_remove ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        CString ->                              -- key : TBasicType TUTF8
        IO CInt

    {- |
    Removes a key and its associated value from a 'GI.GLib.Structs.VariantDict.VariantDict'.

    /Since: 2.40/
    -}
    variantDictRemove ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> T.Text
        {- ^ /@key@/: the key to remove -}
        -> m Bool
        {- ^ __Returns:__ 'True' if the key was found and removed -}
    variantDictRemove dict key = liftIO $ do
        dict' <- unsafeManagedPtrGetPtr dict
        key' <- textToCString key
        result <- g_variant_dict_remove dict' key'
        let result' = (/= 0) result
        touchManagedPtr dict
        freeMem key'
        return result'

    #if ENABLE_OVERLOADING
    data VariantDictRemoveMethodInfo
    instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.MethodInfo VariantDictRemoveMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictRemove

    #endif

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

    foreign import ccall "g_variant_dict_unref" g_variant_dict_unref ::
        Ptr VariantDict ->                      -- dict : TInterface (Name {namespace = "GLib", name = "VariantDict"})
        IO ()

    {- |
    Decreases the reference count on /@dict@/.

    In the event that there are no more references, releases all memory
    associated with the 'GI.GLib.Structs.VariantDict.VariantDict'.

    Don\'t call this on stack-allocated 'GI.GLib.Structs.VariantDict.VariantDict' instances or bad
    things will happen.

    /Since: 2.40/
    -}
    variantDictUnref ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        VariantDict
        {- ^ /@dict@/: a heap-allocated 'GI.GLib.Structs.VariantDict.VariantDict' -}
        -> m ()
    variantDictUnref dict = liftIO $ do
        dict' <- B.ManagedPtr.disownBoxed dict
        g_variant_dict_unref dict'
        touchManagedPtr dict
        return ()

    #if ENABLE_OVERLOADING
    data VariantDictUnrefMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.MethodInfo VariantDictUnrefMethodInfo VariantDict signature where
        overloadedMethod _ = variantDictUnref

    #endif

    #if ENABLE_OVERLOADING
    type family ResolveVariantDictMethod (t :: Symbol) (o :: *) :: * where
        ResolveVariantDictMethod "clear" o = VariantDictClearMethodInfo
        ResolveVariantDictMethod "contains" o = VariantDictContainsMethodInfo
        ResolveVariantDictMethod "end" o = VariantDictEndMethodInfo
        ResolveVariantDictMethod "insertValue" o = VariantDictInsertValueMethodInfo
        ResolveVariantDictMethod "lookupValue" o = VariantDictLookupValueMethodInfo
        ResolveVariantDictMethod "ref" o = VariantDictRefMethodInfo
        ResolveVariantDictMethod "remove" o = VariantDictRemoveMethodInfo
        ResolveVariantDictMethod "unref" o = VariantDictUnrefMethodInfo
        ResolveVariantDictMethod l o = O.MethodResolutionFailed l o

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

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveVariantDictMethod t VariantDict, O.MethodInfo info VariantDict p) => O.IsLabel t (VariantDict -> 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