{- |
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 branch enumerator.
-}

module GI.Ggit.Structs.BranchEnumerator
    ( 

-- * Exported types
    BranchEnumerator(..)                    ,
    noBranchEnumerator                      ,


 -- * Methods
-- ** get #method:get#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BranchEnumeratorGetMethodInfo           ,
#endif
    branchEnumeratorGet                     ,


-- ** iterator #method:iterator#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BranchEnumeratorIteratorMethodInfo      ,
#endif
    branchEnumeratorIterator                ,


-- ** next #method:next#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BranchEnumeratorNextMethodInfo          ,
#endif
    branchEnumeratorNext                    ,


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


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




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

newtype BranchEnumerator = BranchEnumerator (ManagedPtr BranchEnumerator)
foreign import ccall "ggit_branch_enumerator_get_type" c_ggit_branch_enumerator_get_type :: 
    IO GType

instance BoxedObject BranchEnumerator where
    boxedType _ = c_ggit_branch_enumerator_get_type

noBranchEnumerator :: Maybe BranchEnumerator
noBranchEnumerator = Nothing


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

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

foreign import ccall "ggit_branch_enumerator_get" ggit_branch_enumerator_get :: 
    Ptr BranchEnumerator ->                 -- enumerator : TInterface (Name {namespace = "Ggit", name = "BranchEnumerator"})
    IO (Ptr Ggit.Ref.Ref)

{- |
Returns the currently being enumerated branch, or 'Nothing'. Note that the
returned GgitRef will be of type GgitBranch if the ref represents a local
branch.
-}
branchEnumeratorGet ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BranchEnumerator
    {- ^ /@enumerator@/: a 'GI.Ggit.Structs.BranchEnumerator.BranchEnumerator'. -}
    -> m Ggit.Ref.Ref
    {- ^ __Returns:__ the branch ref. -}
branchEnumeratorGet enumerator = liftIO $ do
    enumerator' <- unsafeManagedPtrGetPtr enumerator
    result <- ggit_branch_enumerator_get enumerator'
    checkUnexpectedReturnNULL "branchEnumeratorGet" result
    result' <- (wrapObject Ggit.Ref.Ref) result
    touchManagedPtr enumerator
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BranchEnumeratorGetMethodInfo
instance (signature ~ (m Ggit.Ref.Ref), MonadIO m) => O.MethodInfo BranchEnumeratorGetMethodInfo BranchEnumerator signature where
    overloadedMethod _ = branchEnumeratorGet

#endif

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

foreign import ccall "ggit_branch_enumerator_iterator" ggit_branch_enumerator_iterator :: 
    Ptr BranchEnumerator ->                 -- enumerator : TInterface (Name {namespace = "Ggit", name = "BranchEnumerator"})
    IO (Ptr BranchEnumerator)

{- |
Get an iterator for the enumerator.
-}
branchEnumeratorIterator ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BranchEnumerator
    {- ^ /@enumerator@/: a 'GI.Ggit.Structs.BranchEnumerator.BranchEnumerator'. -}
    -> m BranchEnumerator
    {- ^ __Returns:__ a 'GI.Ggit.Structs.BranchEnumerator.BranchEnumerator'. -}
branchEnumeratorIterator enumerator = liftIO $ do
    enumerator' <- unsafeManagedPtrGetPtr enumerator
    result <- ggit_branch_enumerator_iterator enumerator'
    checkUnexpectedReturnNULL "branchEnumeratorIterator" result
    result' <- (newBoxed BranchEnumerator) result
    touchManagedPtr enumerator
    return result'

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

#endif

-- method BranchEnumerator::next
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "enumerator", argType = TInterface (Name {namespace = "Ggit", name = "BranchEnumerator"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitBranchEnumerator.", 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 "ggit_branch_enumerator_next" ggit_branch_enumerator_next :: 
    Ptr BranchEnumerator ->                 -- enumerator : TInterface (Name {namespace = "Ggit", name = "BranchEnumerator"})
    IO CInt

{- |
Move the enumerator to the next branch.
-}
branchEnumeratorNext ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BranchEnumerator
    {- ^ /@enumerator@/: a 'GI.Ggit.Structs.BranchEnumerator.BranchEnumerator'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if there is a next branch, 'False' otherwise. -}
branchEnumeratorNext enumerator = liftIO $ do
    enumerator' <- unsafeManagedPtrGetPtr enumerator
    result <- ggit_branch_enumerator_next enumerator'
    let result' = (/= 0) result
    touchManagedPtr enumerator
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BranchEnumeratorNextMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo BranchEnumeratorNextMethodInfo BranchEnumerator signature where
    overloadedMethod _ = branchEnumeratorNext

#endif

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

foreign import ccall "ggit_branch_enumerator_ref" ggit_branch_enumerator_ref :: 
    Ptr BranchEnumerator ->                 -- enumerator : TInterface (Name {namespace = "Ggit", name = "BranchEnumerator"})
    IO (Ptr BranchEnumerator)

{- |
/No description available in the introspection data./
-}
branchEnumeratorRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BranchEnumerator
    {- ^ /@enumerator@/: a 'GI.Ggit.Structs.BranchEnumerator.BranchEnumerator'. -}
    -> m BranchEnumerator
    {- ^ __Returns:__ /@enumerator@/ -}
branchEnumeratorRef enumerator = liftIO $ do
    enumerator' <- unsafeManagedPtrGetPtr enumerator
    result <- ggit_branch_enumerator_ref enumerator'
    checkUnexpectedReturnNULL "branchEnumeratorRef" result
    result' <- (wrapBoxed BranchEnumerator) result
    touchManagedPtr enumerator
    return result'

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

#endif

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

foreign import ccall "ggit_branch_enumerator_unref" ggit_branch_enumerator_unref :: 
    Ptr BranchEnumerator ->                 -- enumerator : TInterface (Name {namespace = "Ggit", name = "BranchEnumerator"})
    IO ()

{- |
/No description available in the introspection data./
-}
branchEnumeratorUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BranchEnumerator
    {- ^ /@enumerator@/: a 'GI.Ggit.Structs.BranchEnumerator.BranchEnumerator'. -}
    -> m ()
branchEnumeratorUnref enumerator = liftIO $ do
    enumerator' <- unsafeManagedPtrGetPtr enumerator
    ggit_branch_enumerator_unref enumerator'
    touchManagedPtr enumerator
    return ()

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

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveBranchEnumeratorMethod (t :: Symbol) (o :: *) :: * where
    ResolveBranchEnumeratorMethod "get" o = BranchEnumeratorGetMethodInfo
    ResolveBranchEnumeratorMethod "iterator" o = BranchEnumeratorIteratorMethodInfo
    ResolveBranchEnumeratorMethod "next" o = BranchEnumeratorNextMethodInfo
    ResolveBranchEnumeratorMethod "ref" o = BranchEnumeratorRefMethodInfo
    ResolveBranchEnumeratorMethod "unref" o = BranchEnumeratorUnrefMethodInfo
    ResolveBranchEnumeratorMethod l o = O.MethodResolutionFailed l o

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

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