{- |
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 file in a 'GI.Ggit.Objects.Diff.Diff'.
-}

module GI.Ggit.Structs.DiffFile
    ( 

-- * Exported types
    DiffFile(..)                            ,
    noDiffFile                              ,


 -- * Methods
-- ** getFlags #method:getFlags#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffFileGetFlagsMethodInfo              ,
#endif
    diffFileGetFlags                        ,


-- ** getMode #method:getMode#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffFileGetModeMethodInfo               ,
#endif
    diffFileGetMode                         ,


-- ** getOid #method:getOid#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffFileGetOidMethodInfo                ,
#endif
    diffFileGetOid                          ,


-- ** getPath #method:getPath#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffFileGetPathMethodInfo               ,
#endif
    diffFileGetPath                         ,


-- ** getSize #method:getSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffFileGetSizeMethodInfo               ,
#endif
    diffFileGetSize                         ,


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


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




    ) 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.Flags as Ggit.Flags
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

newtype DiffFile = DiffFile (ManagedPtr DiffFile)
foreign import ccall "ggit_diff_file_get_type" c_ggit_diff_file_get_type :: 
    IO GType

instance BoxedObject DiffFile where
    boxedType _ = c_ggit_diff_file_get_type

noDiffFile :: Maybe DiffFile
noDiffFile = Nothing


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

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

foreign import ccall "ggit_diff_file_get_flags" ggit_diff_file_get_flags :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO CUInt

{- |
Gets the @/GgitDifflags/@ for /@file@/.
-}
diffFileGetFlags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffFile
    {- ^ /@file@/: a 'GI.Ggit.Structs.DiffFile.DiffFile'. -}
    -> m [Ggit.Flags.DiffFlag]
    {- ^ __Returns:__ the file\'s flags. -}
diffFileGetFlags file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_file_get_flags file'
    let result' = wordToGFlags result
    touchManagedPtr file
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffFileGetFlagsMethodInfo
instance (signature ~ (m [Ggit.Flags.DiffFlag]), MonadIO m) => O.MethodInfo DiffFileGetFlagsMethodInfo DiffFile signature where
    overloadedMethod _ = diffFileGetFlags

#endif

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

foreign import ccall "ggit_diff_file_get_mode" ggit_diff_file_get_mode :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO Word16

{- |
Gets the mode for /@file@/.
-}
diffFileGetMode ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffFile
    {- ^ /@file@/: a 'GI.Ggit.Structs.DiffFile.DiffFile'. -}
    -> m Word16
    {- ^ __Returns:__ the file\'s mode. -}
diffFileGetMode file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_file_get_mode file'
    touchManagedPtr file
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffFileGetModeMethodInfo
instance (signature ~ (m Word16), MonadIO m) => O.MethodInfo DiffFileGetModeMethodInfo DiffFile signature where
    overloadedMethod _ = diffFileGetMode

#endif

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

foreign import ccall "ggit_diff_file_get_oid" ggit_diff_file_get_oid :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO (Ptr Ggit.OId.OId)

{- |
Gets the 'GI.Ggit.Structs.OId.OId' for /@file@/.
-}
diffFileGetOid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffFile
    {- ^ /@file@/: a 'GI.Ggit.Structs.DiffFile.DiffFile'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ the file\'s 'GI.Ggit.Structs.OId.OId'. -}
diffFileGetOid file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_file_get_oid file'
    checkUnexpectedReturnNULL "diffFileGetOid" result
    result' <- (newBoxed Ggit.OId.OId) result
    touchManagedPtr file
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffFileGetOidMethodInfo
instance (signature ~ (m Ggit.OId.OId), MonadIO m) => O.MethodInfo DiffFileGetOidMethodInfo DiffFile signature where
    overloadedMethod _ = diffFileGetOid

#endif

-- method DiffFile::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Ggit", name = "DiffFile"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffFile.", 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_diff_file_get_path" ggit_diff_file_get_path :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO CString

{- |
Gets the path of /@file@/ or 'Nothing' if it is unknown.
-}
diffFileGetPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffFile
    {- ^ /@file@/: a 'GI.Ggit.Structs.DiffFile.DiffFile'. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the file\'s path, or 'Nothing'. -}
diffFileGetPath file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_file_get_path file'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr file
    return maybeResult

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffFileGetPathMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo DiffFileGetPathMethodInfo DiffFile signature where
    overloadedMethod _ = diffFileGetPath

#endif

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

foreign import ccall "ggit_diff_file_get_size" ggit_diff_file_get_size :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO Int64

{- |
Gets the size for /@file@/.
-}
diffFileGetSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffFile
    {- ^ /@file@/: a 'GI.Ggit.Structs.DiffFile.DiffFile'. -}
    -> m Int64
    {- ^ __Returns:__ the file\'s size. -}
diffFileGetSize file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_file_get_size file'
    touchManagedPtr file
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffFileGetSizeMethodInfo
instance (signature ~ (m Int64), MonadIO m) => O.MethodInfo DiffFileGetSizeMethodInfo DiffFile signature where
    overloadedMethod _ = diffFileGetSize

#endif

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

foreign import ccall "ggit_diff_file_ref" ggit_diff_file_ref :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO (Ptr DiffFile)

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

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

#endif

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

foreign import ccall "ggit_diff_file_unref" ggit_diff_file_unref :: 
    Ptr DiffFile ->                         -- file : TInterface (Name {namespace = "Ggit", name = "DiffFile"})
    IO ()

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

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

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveDiffFileMethod (t :: Symbol) (o :: *) :: * where
    ResolveDiffFileMethod "ref" o = DiffFileRefMethodInfo
    ResolveDiffFileMethod "unref" o = DiffFileUnrefMethodInfo
    ResolveDiffFileMethod "getFlags" o = DiffFileGetFlagsMethodInfo
    ResolveDiffFileMethod "getMode" o = DiffFileGetModeMethodInfo
    ResolveDiffFileMethod "getOid" o = DiffFileGetOidMethodInfo
    ResolveDiffFileMethod "getPath" o = DiffFileGetPathMethodInfo
    ResolveDiffFileMethod "getSize" o = DiffFileGetSizeMethodInfo
    ResolveDiffFileMethod l o = O.MethodResolutionFailed l o

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

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