{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An object representing an UUID.
-- 
-- /Since: 0.78/

#if !defined(__HADDOCK_VERSION__)
#define ENABLE_OVERLOADING
#endif

module GI.Vte.Structs.Uuid
    ( 

-- * Exported types
    Uuid(..)                                ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [dup]("GI.Vte.Structs.Uuid#g:method:dup"), [equal]("GI.Vte.Structs.Uuid#g:method:equal"), [free]("GI.Vte.Structs.Uuid#g:method:free"), [freeToString]("GI.Vte.Structs.Uuid#g:method:freeToString"), [newV5]("GI.Vte.Structs.Uuid#g:method:newV5"), [toString]("GI.Vte.Structs.Uuid#g:method:toString").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveUuidMethod                       ,
#endif

-- ** dup #method:dup#

#if defined(ENABLE_OVERLOADING)
    UuidDupMethodInfo                       ,
#endif
    uuidDup                                 ,


-- ** equal #method:equal#

#if defined(ENABLE_OVERLOADING)
    UuidEqualMethodInfo                     ,
#endif
    uuidEqual                               ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    UuidFreeMethodInfo                      ,
#endif
    uuidFree                                ,


-- ** freeToString #method:freeToString#

#if defined(ENABLE_OVERLOADING)
    UuidFreeToStringMethodInfo              ,
#endif
    uuidFreeToString                        ,


-- ** newFromString #method:newFromString#

    uuidNewFromString                       ,


-- ** newV4 #method:newV4#

    uuidNewV4                               ,


-- ** newV5 #method:newV5#

#if defined(ENABLE_OVERLOADING)
    UuidNewV5MethodInfo                     ,
#endif
    uuidNewV5                               ,


-- ** toString #method:toString#

#if defined(ENABLE_OVERLOADING)
    UuidToStringMethodInfo                  ,
#endif
    uuidToString                            ,


-- ** validateString #method:validateString#

    uuidValidateString                      ,




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

#else
import {-# SOURCE #-} qualified GI.Vte.Flags as Vte.Flags

#endif

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

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

foreign import ccall "vte_uuid_get_type" c_vte_uuid_get_type :: 
    IO GType

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

instance B.Types.TypedObject Uuid where
    glibType :: IO GType
glibType = IO GType
c_vte_uuid_get_type

instance B.Types.GBoxed Uuid

-- | Convert t'Uuid' 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 Uuid) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_vte_uuid_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Uuid -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Uuid
P.Nothing = Ptr GValue -> Ptr Uuid -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Uuid
forall a. Ptr a
FP.nullPtr :: FP.Ptr Uuid)
    gvalueSet_ Ptr GValue
gv (P.Just Uuid
obj) = Uuid -> (Ptr Uuid -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Uuid
obj (Ptr GValue -> Ptr Uuid -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Uuid)
gvalueGet_ Ptr GValue
gv = do
        ptr <- Ptr GValue -> IO (Ptr Uuid)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Uuid)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newBoxed Uuid ptr
        else return P.Nothing
        
    


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

-- method Uuid::new_from_string
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const char*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSSize
--           , argCType = Just "gssize"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the length of @str, or -1 is @str is NUL terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "fmt"
--           , argType =
--               TInterface Name { namespace = "Vte" , name = "UuidFormat" }
--           , argCType = Just "VteUuidFormat"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "flags from #VteUuidFormat for which fmt(s) to accept"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Vte" , name = "Uuid" })
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_new_from_string" vte_uuid_new_from_string :: 
    CString ->                              -- str : TBasicType TUTF8
    DI.Int64 ->                             -- len : TBasicType TSSize
    CUInt ->                                -- fmt : TInterface (Name {namespace = "Vte", name = "UuidFormat"})
    IO (Ptr Uuid)

-- | Creates a new UUID from its string representation /@str@/.
-- 
-- /Since: 0.78/
uuidNewFromString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: a string
    -> DI.Int64
    -- ^ /@len@/: the length of /@str@/, or -1 is /@str@/ is NUL terminated
    -> [Vte.Flags.UuidFormat]
    -- ^ /@fmt@/: flags from t'GI.Vte.Flags.UuidFormat' for which fmt(s) to accept
    -> m (Maybe Uuid)
    -- ^ __Returns:__ a new UUID, or 'P.Nothing' is
    --   /@str@/ is not a valid UUID string representation
uuidNewFromString :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int64 -> [UuidFormat] -> m (Maybe Uuid)
uuidNewFromString Text
str Int64
len [UuidFormat]
fmt = IO (Maybe Uuid) -> m (Maybe Uuid)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Uuid) -> m (Maybe Uuid))
-> IO (Maybe Uuid) -> m (Maybe Uuid)
forall a b. (a -> b) -> a -> b
$ do
    str' <- Text -> IO CString
textToCString Text
str
    let fmt' = [UuidFormat] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [UuidFormat]
fmt
    result <- vte_uuid_new_from_string str' len fmt'
    maybeResult <- convertIfNonNull result $ \Ptr Uuid
result' -> do
        result'' <- ((ManagedPtr Uuid -> Uuid) -> Ptr Uuid -> IO Uuid
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Uuid -> Uuid
Uuid) Ptr Uuid
result'
        return result''
    freeMem str'
    return maybeResult

#if defined(ENABLE_OVERLOADING)
#endif

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

foreign import ccall "vte_uuid_new_v4" vte_uuid_new_v4 :: 
    IO (Ptr Uuid)

-- | Creates a new random UUID.
-- 
-- /Since: 0.78/
uuidNewV4 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Uuid
    -- ^ __Returns:__ a new v4 UUID
uuidNewV4 :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Uuid
uuidNewV4  = IO Uuid -> m Uuid
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Uuid -> m Uuid) -> IO Uuid -> m Uuid
forall a b. (a -> b) -> a -> b
$ do
    result <- IO (Ptr Uuid)
vte_uuid_new_v4
    checkUnexpectedReturnNULL "uuidNewV4" result
    result' <- (wrapBoxed Uuid) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Uuid::dup
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "uuid"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "const VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuid" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Vte" , name = "Uuid" })
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_dup" vte_uuid_dup :: 
    Ptr Uuid ->                             -- uuid : TInterface (Name {namespace = "Vte", name = "Uuid"})
    IO (Ptr Uuid)

-- | Creates a copy of /@uuid@/.
-- 
-- /Since: 0.78/
uuidDup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Uuid
    -- ^ /@uuid@/: a t'GI.Vte.Structs.Uuid.Uuid'
    -> m Uuid
    -- ^ __Returns:__ a new copy of \@/@uuid@/
uuidDup :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Uuid -> m Uuid
uuidDup Uuid
uuid = IO Uuid -> m Uuid
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Uuid -> m Uuid) -> IO Uuid -> m Uuid
forall a b. (a -> b) -> a -> b
$ do
    uuid' <- Uuid -> IO (Ptr Uuid)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Uuid
uuid
    result <- vte_uuid_dup uuid'
    checkUnexpectedReturnNULL "uuidDup" result
    result' <- (wrapBoxed Uuid) result
    touchManagedPtr uuid
    return result'

#if defined(ENABLE_OVERLOADING)
data UuidDupMethodInfo
instance (signature ~ (m Uuid), MonadIO m) => O.OverloadedMethod UuidDupMethodInfo Uuid signature where
    overloadedMethod = uuidDup

instance O.OverloadedMethodInfo UuidDupMethodInfo Uuid where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Vte.Structs.Uuid.uuidDup",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.35/docs/GI-Vte-Structs-Uuid.html#v:uuidDup"
        })


#endif

-- method Uuid::equal
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "uuid"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "const VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuid" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "other"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "const VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_equal" vte_uuid_equal :: 
    Ptr Uuid ->                             -- uuid : TInterface (Name {namespace = "Vte", name = "Uuid"})
    Ptr Uuid ->                             -- other : TInterface (Name {namespace = "Vte", name = "Uuid"})
    IO CInt

-- | Compares /@uuid@/ and /@other@/ for equality.
-- 
-- /Since: 0.78/
uuidEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Uuid
    -- ^ /@uuid@/: a t'GI.Vte.Structs.Uuid.Uuid'
    -> Uuid
    -> m Bool
    -- ^ __Returns:__ 'P.True' iff /@uuid@/ and /@other@/ are equal
uuidEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Uuid -> Uuid -> m Bool
uuidEqual Uuid
uuid Uuid
other = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    uuid' <- Uuid -> IO (Ptr Uuid)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Uuid
uuid
    other' <- unsafeManagedPtrGetPtr other
    result <- vte_uuid_equal uuid' other'
    let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    touchManagedPtr uuid
    touchManagedPtr other
    return result'

#if defined(ENABLE_OVERLOADING)
data UuidEqualMethodInfo
instance (signature ~ (Uuid -> m Bool), MonadIO m) => O.OverloadedMethod UuidEqualMethodInfo Uuid signature where
    overloadedMethod = uuidEqual

instance O.OverloadedMethodInfo UuidEqualMethodInfo Uuid where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Vte.Structs.Uuid.uuidEqual",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.35/docs/GI-Vte-Structs-Uuid.html#v:uuidEqual"
        })


#endif

-- method Uuid::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "uuid"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuid" , 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 "vte_uuid_free" vte_uuid_free :: 
    Ptr Uuid ->                             -- uuid : TInterface (Name {namespace = "Vte", name = "Uuid"})
    IO ()

-- | Frees /@uuid@/.
-- 
-- /Since: 0.78/
uuidFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Uuid
    -- ^ /@uuid@/: a t'GI.Vte.Structs.Uuid.Uuid'
    -> m ()
uuidFree :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Uuid -> m ()
uuidFree Uuid
uuid = 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
    uuid' <- Uuid -> IO (Ptr Uuid)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Uuid
uuid
    vte_uuid_free uuid'
    touchManagedPtr uuid
    return ()

#if defined(ENABLE_OVERLOADING)
data UuidFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod UuidFreeMethodInfo Uuid signature where
    overloadedMethod = uuidFree

instance O.OverloadedMethodInfo UuidFreeMethodInfo Uuid where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Vte.Structs.Uuid.uuidFree",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.35/docs/GI-Vte-Structs-Uuid.html#v:uuidFree"
        })


#endif

-- method Uuid::free_to_string
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "uuid"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuid" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "fmt"
--           , argType =
--               TInterface Name { namespace = "Vte" , name = "UuidFormat" }
--           , argCType = Just "VteUuidFormat"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuidFormat" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSize
--           , argCType = Just "gsize*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a location to store the length of the returned string, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_free_to_string" vte_uuid_free_to_string :: 
    Ptr Uuid ->                             -- uuid : TInterface (Name {namespace = "Vte", name = "Uuid"})
    CUInt ->                                -- fmt : TInterface (Name {namespace = "Vte", name = "UuidFormat"})
    FCT.CSize ->                            -- len : TBasicType TSize
    IO CString

-- | Frees /@uuid@/ and returns its string representation, see
-- 'GI.Vte.Structs.Uuid.uuidToString' for more information.
-- 
-- /Since: 0.78/
uuidFreeToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Uuid
    -- ^ /@uuid@/: a t'GI.Vte.Structs.Uuid.Uuid'
    -> [Vte.Flags.UuidFormat]
    -- ^ /@fmt@/: a t'GI.Vte.Flags.UuidFormat'
    -> FCT.CSize
    -- ^ /@len@/: a location to store the length of the returned string, or 'P.Nothing'
    -> m T.Text
    -- ^ __Returns:__ a string representation of /@uuid@/
uuidFreeToString :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Uuid -> [UuidFormat] -> CSize -> m Text
uuidFreeToString Uuid
uuid [UuidFormat]
fmt CSize
len = 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
    uuid' <- Uuid -> IO (Ptr Uuid)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Uuid
uuid
    let fmt' = [UuidFormat] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [UuidFormat]
fmt
    result <- vte_uuid_free_to_string uuid' fmt' len
    checkUnexpectedReturnNULL "uuidFreeToString" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr uuid
    return result'

#if defined(ENABLE_OVERLOADING)
data UuidFreeToStringMethodInfo
instance (signature ~ ([Vte.Flags.UuidFormat] -> FCT.CSize -> m T.Text), MonadIO m) => O.OverloadedMethod UuidFreeToStringMethodInfo Uuid signature where
    overloadedMethod = uuidFreeToString

instance O.OverloadedMethodInfo UuidFreeToStringMethodInfo Uuid where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Vte.Structs.Uuid.uuidFreeToString",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.35/docs/GI-Vte-Structs-Uuid.html#v:uuidFreeToString"
        })


#endif

-- method Uuid::new_v5
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "ns"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "const VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the namespace #VteUuid"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const char*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "string data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSSize
--           , argCType = Just "gssize"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the length of @data, or -1 if @str is NUL terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Vte" , name = "Uuid" })
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_new_v5" vte_uuid_new_v5 :: 
    Ptr Uuid ->                             -- ns : TInterface (Name {namespace = "Vte", name = "Uuid"})
    CString ->                              -- data : TBasicType TUTF8
    DI.Int64 ->                             -- len : TBasicType TSSize
    IO (Ptr Uuid)

-- | Creates a new UUID for /@ns@/ and /@str@/.
-- 
-- /Since: 0.78/
uuidNewV5 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (Uuid)
    -- ^ /@ns@/: the namespace t'GI.Vte.Structs.Uuid.Uuid'
    -> T.Text
    -- ^ /@data@/: string data
    -> DI.Int64
    -- ^ /@len@/: the length of /@data@/, or -1 if /@str@/ is NUL terminated
    -> m Uuid
    -- ^ __Returns:__ a new v5 UUID
uuidNewV5 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Uuid -> Text -> Int64 -> m Uuid
uuidNewV5 Maybe Uuid
ns Text
data_ Int64
len = IO Uuid -> m Uuid
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Uuid -> m Uuid) -> IO Uuid -> m Uuid
forall a b. (a -> b) -> a -> b
$ do
    maybeNs <- case Maybe Uuid
ns of
        Maybe Uuid
Nothing -> Ptr Uuid -> IO (Ptr Uuid)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Uuid
forall a. Ptr a
FP.nullPtr
        Just Uuid
jNs -> do
            jNs' <- Uuid -> IO (Ptr Uuid)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Uuid
jNs
            return jNs'
    data_' <- textToCString data_
    result <- vte_uuid_new_v5 maybeNs data_' len
    checkUnexpectedReturnNULL "uuidNewV5" result
    result' <- (wrapBoxed Uuid) result
    whenJust ns touchManagedPtr
    freeMem data_'
    return result'

#if defined(ENABLE_OVERLOADING)
data UuidNewV5MethodInfo
instance (signature ~ (T.Text -> DI.Int64 -> m Uuid), MonadIO m) => O.OverloadedMethod UuidNewV5MethodInfo Uuid signature where
    overloadedMethod i = uuidNewV5 (Just i)

instance O.OverloadedMethodInfo UuidNewV5MethodInfo Uuid where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Vte.Structs.Uuid.uuidNewV5",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.35/docs/GI-Vte-Structs-Uuid.html#v:uuidNewV5"
        })


#endif

-- method Uuid::to_string
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "uuid"
--           , argType = TInterface Name { namespace = "Vte" , name = "Uuid" }
--           , argCType = Just "const VteUuid*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuid" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "fmt"
--           , argType =
--               TInterface Name { namespace = "Vte" , name = "UuidFormat" }
--           , argCType = Just "VteUuidFormat"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuidFormat" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSize
--           , argCType = Just "gsize*"
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a location to store the length of the returned string, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_to_string" vte_uuid_to_string :: 
    Ptr Uuid ->                             -- uuid : TInterface (Name {namespace = "Vte", name = "Uuid"})
    CUInt ->                                -- fmt : TInterface (Name {namespace = "Vte", name = "UuidFormat"})
    Ptr FCT.CSize ->                        -- len : TBasicType TSize
    IO CString

-- | Returns the string representation of /@uuid@/.
-- 
-- /Since: 0.78/
uuidToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Uuid
    -- ^ /@uuid@/: a t'GI.Vte.Structs.Uuid.Uuid'
    -> [Vte.Flags.UuidFormat]
    -- ^ /@fmt@/: a t'GI.Vte.Flags.UuidFormat'
    -> m ((T.Text, FCT.CSize))
    -- ^ __Returns:__ a string representation of /@uuid@/
uuidToString :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Uuid -> [UuidFormat] -> m (Text, CSize)
uuidToString Uuid
uuid [UuidFormat]
fmt = IO (Text, CSize) -> m (Text, CSize)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Text, CSize) -> m (Text, CSize))
-> IO (Text, CSize) -> m (Text, CSize)
forall a b. (a -> b) -> a -> b
$ do
    uuid' <- Uuid -> IO (Ptr Uuid)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Uuid
uuid
    let fmt' = [UuidFormat] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [UuidFormat]
fmt
    len <- allocMem :: IO (Ptr FCT.CSize)
    result <- vte_uuid_to_string uuid' fmt' len
    checkUnexpectedReturnNULL "uuidToString" result
    result' <- cstringToText result
    freeMem result
    len' <- peek len
    touchManagedPtr uuid
    freeMem len
    return (result', len')

#if defined(ENABLE_OVERLOADING)
data UuidToStringMethodInfo
instance (signature ~ ([Vte.Flags.UuidFormat] -> m ((T.Text, FCT.CSize))), MonadIO m) => O.OverloadedMethod UuidToStringMethodInfo Uuid signature where
    overloadedMethod = uuidToString

instance O.OverloadedMethodInfo UuidToStringMethodInfo Uuid where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Vte.Structs.Uuid.uuidToString",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-vte-2.91.35/docs/GI-Vte-Structs-Uuid.html#v:uuidToString"
        })


#endif

-- method Uuid::validate_string
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const char*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSSize
--           , argCType = Just "gssize"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the length of @str, or -1 is @str is NUL terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "fmt"
--           , argType =
--               TInterface Name { namespace = "Vte" , name = "UuidFormat" }
--           , argCType = Just "VteUuidFormat"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #VteUuidFormat" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "vte_uuid_validate_string" vte_uuid_validate_string :: 
    CString ->                              -- str : TBasicType TUTF8
    DI.Int64 ->                             -- len : TBasicType TSSize
    CUInt ->                                -- fmt : TInterface (Name {namespace = "Vte", name = "UuidFormat"})
    IO CInt

-- | Checks whether /@str@/ is a valid string representation of an UUID.
-- 
-- /Since: 0.78/
uuidValidateString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: a string
    -> DI.Int64
    -- ^ /@len@/: the length of /@str@/, or -1 is /@str@/ is NUL terminated
    -> [Vte.Flags.UuidFormat]
    -- ^ /@fmt@/: a t'GI.Vte.Flags.UuidFormat'
    -> m Bool
    -- ^ __Returns:__ 'P.True' iff /@str@/ is a valid string representation
uuidValidateString :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int64 -> [UuidFormat] -> m Bool
uuidValidateString Text
str Int64
len [UuidFormat]
fmt = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    str' <- Text -> IO CString
textToCString Text
str
    let fmt' = [UuidFormat] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [UuidFormat]
fmt
    result <- vte_uuid_validate_string str' len fmt'
    let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    freeMem str'
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveUuidMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveUuidMethod "dup" o = UuidDupMethodInfo
    ResolveUuidMethod "equal" o = UuidEqualMethodInfo
    ResolveUuidMethod "free" o = UuidFreeMethodInfo
    ResolveUuidMethod "freeToString" o = UuidFreeToStringMethodInfo
    ResolveUuidMethod "newV5" o = UuidNewV5MethodInfo
    ResolveUuidMethod "toString" o = UuidToStringMethodInfo
    ResolveUuidMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveUuidMethod t Uuid, O.OverloadedMethod info Uuid p) => OL.IsLabel t (Uuid -> 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 ~ ResolveUuidMethod t Uuid, O.OverloadedMethod info Uuid p, R.HasField t Uuid p) => R.HasField t Uuid p where
    getField = O.overloadedMethod @info

#endif

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

#endif