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

Represents a git configuration entry.
-}

module GI.Ggit.Structs.ConfigEntry
    ( 

-- * Exported types
    ConfigEntry(..)                         ,
    noConfigEntry                           ,


 -- * Methods
-- ** getLevel #method:getLevel#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    ConfigEntryGetLevelMethodInfo           ,
#endif
    configEntryGetLevel                     ,


-- ** getName #method:getName#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    ConfigEntryGetNameMethodInfo            ,
#endif
    configEntryGetName                      ,


-- ** getValue #method:getValue#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    ConfigEntryGetValueMethodInfo           ,
#endif
    configEntryGetValue                     ,


-- ** ref #method:ref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    ConfigEntryRefMethodInfo                ,
#endif
    configEntryRef                          ,


-- ** unref #method:unref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    ConfigEntryUnrefMethodInfo              ,
#endif
    configEntryUnref                        ,




    ) 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.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.Ggit.Enums as Ggit.Enums

newtype ConfigEntry = ConfigEntry (ManagedPtr ConfigEntry)
foreign import ccall "ggit_config_entry_get_type" c_ggit_config_entry_get_type :: 
    IO GType

instance BoxedObject ConfigEntry where
    boxedType _ = c_ggit_config_entry_get_type

noConfigEntry :: Maybe ConfigEntry
noConfigEntry = Nothing


#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList ConfigEntry
type instance O.AttributeList ConfigEntry = ConfigEntryAttributeList
type ConfigEntryAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method ConfigEntry::get_level
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "entry", argType = TInterface (Name {namespace = "Ggit", name = "ConfigEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitConfigEntry.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "ConfigLevel"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_config_entry_get_level" ggit_config_entry_get_level :: 
    Ptr ConfigEntry ->                      -- entry : TInterface (Name {namespace = "Ggit", name = "ConfigEntry"})
    IO CUInt

{- |
Gets the 'GI.Ggit.Enums.ConfigLevel' of /@entry@/.
-}
configEntryGetLevel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> m Ggit.Enums.ConfigLevel
    {- ^ __Returns:__ the 'GI.Ggit.Enums.ConfigLevel' of /@entry@/. -}
configEntryGetLevel entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_config_entry_get_level entry'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr entry
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ConfigEntryGetLevelMethodInfo
instance (signature ~ (m Ggit.Enums.ConfigLevel), MonadIO m) => O.MethodInfo ConfigEntryGetLevelMethodInfo ConfigEntry signature where
    overloadedMethod _ = configEntryGetLevel

#endif

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

foreign import ccall "ggit_config_entry_get_name" ggit_config_entry_get_name :: 
    Ptr ConfigEntry ->                      -- entry : TInterface (Name {namespace = "Ggit", name = "ConfigEntry"})
    IO CString

{- |
Gets the name of /@entry@/.
-}
configEntryGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> m T.Text
    {- ^ __Returns:__ the name of /@entry@/: -}
configEntryGetName entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_config_entry_get_name entry'
    checkUnexpectedReturnNULL "configEntryGetName" result
    result' <- cstringToText result
    touchManagedPtr entry
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ConfigEntryGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo ConfigEntryGetNameMethodInfo ConfigEntry signature where
    overloadedMethod _ = configEntryGetName

#endif

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

foreign import ccall "ggit_config_entry_get_value" ggit_config_entry_get_value :: 
    Ptr ConfigEntry ->                      -- entry : TInterface (Name {namespace = "Ggit", name = "ConfigEntry"})
    IO CString

{- |
Gets the value of /@entry@/.
-}
configEntryGetValue ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> m T.Text
    {- ^ __Returns:__ the value of /@entry@/. -}
configEntryGetValue entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_config_entry_get_value entry'
    checkUnexpectedReturnNULL "configEntryGetValue" result
    result' <- cstringToText result
    touchManagedPtr entry
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ConfigEntryGetValueMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo ConfigEntryGetValueMethodInfo ConfigEntry signature where
    overloadedMethod _ = configEntryGetValue

#endif

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

foreign import ccall "ggit_config_entry_ref" ggit_config_entry_ref :: 
    Ptr ConfigEntry ->                      -- entry : TInterface (Name {namespace = "Ggit", name = "ConfigEntry"})
    IO (Ptr ConfigEntry)

{- |
Atomically increments the reference count of /@entry@/ by one.
This function is MT-safe and may be called from any thread.
-}
configEntryRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> m ConfigEntry
    {- ^ __Returns:__ a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
configEntryRef entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_config_entry_ref entry'
    checkUnexpectedReturnNULL "configEntryRef" result
    result' <- (newBoxed ConfigEntry) result
    touchManagedPtr entry
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ConfigEntryRefMethodInfo
instance (signature ~ (m ConfigEntry), MonadIO m) => O.MethodInfo ConfigEntryRefMethodInfo ConfigEntry signature where
    overloadedMethod _ = configEntryRef

#endif

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

foreign import ccall "ggit_config_entry_unref" ggit_config_entry_unref :: 
    Ptr ConfigEntry ->                      -- entry : TInterface (Name {namespace = "Ggit", name = "ConfigEntry"})
    IO ()

{- |
Atomically decrements the reference count of /@entry@/ by one.
If the reference count drops to 0, /@entry@/ is freed.
-}
configEntryUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> m ()
configEntryUnref entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    ggit_config_entry_unref entry'
    touchManagedPtr entry
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ConfigEntryUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ConfigEntryUnrefMethodInfo ConfigEntry signature where
    overloadedMethod _ = configEntryUnref

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveConfigEntryMethod (t :: Symbol) (o :: *) :: * where
    ResolveConfigEntryMethod "ref" o = ConfigEntryRefMethodInfo
    ResolveConfigEntryMethod "unref" o = ConfigEntryUnrefMethodInfo
    ResolveConfigEntryMethod "getLevel" o = ConfigEntryGetLevelMethodInfo
    ResolveConfigEntryMethod "getName" o = ConfigEntryGetNameMethodInfo
    ResolveConfigEntryMethod "getValue" o = ConfigEntryGetValueMethodInfo
    ResolveConfigEntryMethod l o = O.MethodResolutionFailed l o

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

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