{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A GPatternSpec struct is the \'compiled\' form of a pattern. This
-- structure is opaque and its fields cannot be accessed directly.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.GLib.Structs.PatternSpec
    ( 

-- * Exported types
    PatternSpec(..)                         ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [copy]("GI.GLib.Structs.PatternSpec#g:method:copy"), [equal]("GI.GLib.Structs.PatternSpec#g:method:equal"), [free]("GI.GLib.Structs.PatternSpec#g:method:free"), [match]("GI.GLib.Structs.PatternSpec#g:method:match"), [matchString]("GI.GLib.Structs.PatternSpec#g:method:matchString").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolvePatternSpecMethod                ,
#endif

-- ** copy #method:copy#

#if defined(ENABLE_OVERLOADING)
    PatternSpecCopyMethodInfo               ,
#endif
    patternSpecCopy                         ,


-- ** equal #method:equal#

#if defined(ENABLE_OVERLOADING)
    PatternSpecEqualMethodInfo              ,
#endif
    patternSpecEqual                        ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    PatternSpecFreeMethodInfo               ,
#endif
    patternSpecFree                         ,


-- ** match #method:match#

#if defined(ENABLE_OVERLOADING)
    PatternSpecMatchMethodInfo              ,
#endif
    patternSpecMatch                        ,


-- ** matchString #method:matchString#

#if defined(ENABLE_OVERLOADING)
    PatternSpecMatchStringMethodInfo        ,
#endif
    patternSpecMatchString                  ,


-- ** new #method:new#

    patternSpecNew                          ,




    ) 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.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.Text as T
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


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

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

foreign import ccall "g_pattern_spec_get_type" c_g_pattern_spec_get_type :: 
    IO GType

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

instance B.Types.TypedObject PatternSpec where
    glibType :: IO GType
glibType = IO GType
c_g_pattern_spec_get_type

instance B.Types.GBoxed PatternSpec

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


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

-- method PatternSpec::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "pattern"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a zero-terminated UTF-8 encoded string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GLib" , name = "PatternSpec" })
-- throws : False
-- Skip return : False

foreign import ccall "g_pattern_spec_new" g_pattern_spec_new :: 
    CString ->                              -- pattern : TBasicType TUTF8
    IO (Ptr PatternSpec)

-- | Compiles a pattern to a t'GI.GLib.Structs.PatternSpec.PatternSpec'.
patternSpecNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@pattern@/: a zero-terminated UTF-8 encoded string
    -> m PatternSpec
    -- ^ __Returns:__ a newly-allocated t'GI.GLib.Structs.PatternSpec.PatternSpec'
patternSpecNew :: Text -> m PatternSpec
patternSpecNew Text
pattern = IO PatternSpec -> m PatternSpec
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PatternSpec -> m PatternSpec)
-> IO PatternSpec -> m PatternSpec
forall a b. (a -> b) -> a -> b
$ do
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    Ptr PatternSpec
result <- CString -> IO (Ptr PatternSpec)
g_pattern_spec_new CString
pattern'
    Text -> Ptr PatternSpec -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"patternSpecNew" Ptr PatternSpec
result
    PatternSpec
result' <- ((ManagedPtr PatternSpec -> PatternSpec)
-> Ptr PatternSpec -> IO PatternSpec
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr PatternSpec -> PatternSpec
PatternSpec) Ptr PatternSpec
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
    PatternSpec -> IO PatternSpec
forall (m :: * -> *) a. Monad m => a -> m a
return PatternSpec
result'

#if defined(ENABLE_OVERLOADING)
#endif

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

foreign import ccall "g_pattern_spec_copy" g_pattern_spec_copy :: 
    Ptr PatternSpec ->                      -- pspec : TInterface (Name {namespace = "GLib", name = "PatternSpec"})
    IO (Ptr PatternSpec)

-- | /No description available in the introspection data./
patternSpecCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PatternSpec
    -> m PatternSpec
patternSpecCopy :: PatternSpec -> m PatternSpec
patternSpecCopy PatternSpec
pspec = IO PatternSpec -> m PatternSpec
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PatternSpec -> m PatternSpec)
-> IO PatternSpec -> m PatternSpec
forall a b. (a -> b) -> a -> b
$ do
    Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
    Ptr PatternSpec
result <- Ptr PatternSpec -> IO (Ptr PatternSpec)
g_pattern_spec_copy Ptr PatternSpec
pspec'
    Text -> Ptr PatternSpec -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"patternSpecCopy" Ptr PatternSpec
result
    PatternSpec
result' <- ((ManagedPtr PatternSpec -> PatternSpec)
-> Ptr PatternSpec -> IO PatternSpec
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr PatternSpec -> PatternSpec
PatternSpec) Ptr PatternSpec
result
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
    PatternSpec -> IO PatternSpec
forall (m :: * -> *) a. Monad m => a -> m a
return PatternSpec
result'

#if defined(ENABLE_OVERLOADING)
data PatternSpecCopyMethodInfo
instance (signature ~ (m PatternSpec), MonadIO m) => O.OverloadedMethod PatternSpecCopyMethodInfo PatternSpec signature where
    overloadedMethod = patternSpecCopy

instance O.OverloadedMethodInfo PatternSpecCopyMethodInfo PatternSpec where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.GLib.Structs.PatternSpec.patternSpecCopy",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-glib-2.0.25/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecCopy"
        }


#endif

-- method PatternSpec::equal
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "pspec1"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PatternSpec" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GPatternSpec" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pspec2"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PatternSpec" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "another #GPatternSpec"
--                 , 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_pattern_spec_equal" g_pattern_spec_equal :: 
    Ptr PatternSpec ->                      -- pspec1 : TInterface (Name {namespace = "GLib", name = "PatternSpec"})
    Ptr PatternSpec ->                      -- pspec2 : TInterface (Name {namespace = "GLib", name = "PatternSpec"})
    IO CInt

-- | Compares two compiled pattern specs and returns whether they will
-- match the same set of strings.
patternSpecEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PatternSpec
    -- ^ /@pspec1@/: a t'GI.GLib.Structs.PatternSpec.PatternSpec'
    -> PatternSpec
    -- ^ /@pspec2@/: another t'GI.GLib.Structs.PatternSpec.PatternSpec'
    -> m Bool
    -- ^ __Returns:__ Whether the compiled patterns are equal
patternSpecEqual :: PatternSpec -> PatternSpec -> m Bool
patternSpecEqual PatternSpec
pspec1 PatternSpec
pspec2 = IO Bool -> m Bool
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
    Ptr PatternSpec
pspec1' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec1
    Ptr PatternSpec
pspec2' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec2
    CInt
result <- Ptr PatternSpec -> Ptr PatternSpec -> IO CInt
g_pattern_spec_equal Ptr PatternSpec
pspec1' Ptr PatternSpec
pspec2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec1
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec2
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PatternSpecEqualMethodInfo
instance (signature ~ (PatternSpec -> m Bool), MonadIO m) => O.OverloadedMethod PatternSpecEqualMethodInfo PatternSpec signature where
    overloadedMethod = patternSpecEqual

instance O.OverloadedMethodInfo PatternSpecEqualMethodInfo PatternSpec where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.GLib.Structs.PatternSpec.patternSpecEqual",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-glib-2.0.25/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecEqual"
        }


#endif

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

foreign import ccall "g_pattern_spec_free" g_pattern_spec_free :: 
    Ptr PatternSpec ->                      -- pspec : TInterface (Name {namespace = "GLib", name = "PatternSpec"})
    IO ()

-- | Frees the memory allocated for the t'GI.GLib.Structs.PatternSpec.PatternSpec'.
patternSpecFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PatternSpec
    -- ^ /@pspec@/: a t'GI.GLib.Structs.PatternSpec.PatternSpec'
    -> m ()
patternSpecFree :: PatternSpec -> m ()
patternSpecFree PatternSpec
pspec = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
    Ptr PatternSpec -> IO ()
g_pattern_spec_free Ptr PatternSpec
pspec'
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data PatternSpecFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod PatternSpecFreeMethodInfo PatternSpec signature where
    overloadedMethod = patternSpecFree

instance O.OverloadedMethodInfo PatternSpecFreeMethodInfo PatternSpec where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.GLib.Structs.PatternSpec.patternSpecFree",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-glib-2.0.25/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecFree"
        }


#endif

-- method PatternSpec::match
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "pspec"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PatternSpec" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_length"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_reversed"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , 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_pattern_spec_match" g_pattern_spec_match :: 
    Ptr PatternSpec ->                      -- pspec : TInterface (Name {namespace = "GLib", name = "PatternSpec"})
    Word32 ->                               -- string_length : TBasicType TUInt32
    CString ->                              -- string : TBasicType TUTF8
    CString ->                              -- string_reversed : TBasicType TUTF8
    IO CInt

-- | /No description available in the introspection data./
patternSpecMatch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PatternSpec
    -> Word32
    -> T.Text
    -> T.Text
    -> m Bool
patternSpecMatch :: PatternSpec -> Word32 -> Text -> Text -> m Bool
patternSpecMatch PatternSpec
pspec Word32
stringLength Text
string Text
stringReversed = IO Bool -> m Bool
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
    Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
stringReversed' <- Text -> IO CString
textToCString Text
stringReversed
    CInt
result <- Ptr PatternSpec -> Word32 -> CString -> CString -> IO CInt
g_pattern_spec_match Ptr PatternSpec
pspec' Word32
stringLength CString
string' CString
stringReversed'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stringReversed'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PatternSpecMatchMethodInfo
instance (signature ~ (Word32 -> T.Text -> T.Text -> m Bool), MonadIO m) => O.OverloadedMethod PatternSpecMatchMethodInfo PatternSpec signature where
    overloadedMethod = patternSpecMatch

instance O.OverloadedMethodInfo PatternSpecMatchMethodInfo PatternSpec where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.GLib.Structs.PatternSpec.patternSpecMatch",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-glib-2.0.25/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecMatch"
        }


#endif

-- method PatternSpec::match_string
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "pspec"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PatternSpec" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , 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_pattern_spec_match_string" g_pattern_spec_match_string :: 
    Ptr PatternSpec ->                      -- pspec : TInterface (Name {namespace = "GLib", name = "PatternSpec"})
    CString ->                              -- string : TBasicType TUTF8
    IO CInt

-- | /No description available in the introspection data./
patternSpecMatchString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PatternSpec
    -> T.Text
    -> m Bool
patternSpecMatchString :: PatternSpec -> Text -> m Bool
patternSpecMatchString PatternSpec
pspec Text
string = IO Bool -> m Bool
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
    Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
    CString
string' <- Text -> IO CString
textToCString Text
string
    CInt
result <- Ptr PatternSpec -> CString -> IO CInt
g_pattern_spec_match_string Ptr PatternSpec
pspec' CString
string'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PatternSpecMatchStringMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.OverloadedMethod PatternSpecMatchStringMethodInfo PatternSpec signature where
    overloadedMethod = patternSpecMatchString

instance O.OverloadedMethodInfo PatternSpecMatchStringMethodInfo PatternSpec where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.GLib.Structs.PatternSpec.patternSpecMatchString",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-glib-2.0.25/docs/GI-GLib-Structs-PatternSpec.html#v:patternSpecMatchString"
        }


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolvePatternSpecMethod (t :: Symbol) (o :: *) :: * where
    ResolvePatternSpecMethod "copy" o = PatternSpecCopyMethodInfo
    ResolvePatternSpecMethod "equal" o = PatternSpecEqualMethodInfo
    ResolvePatternSpecMethod "free" o = PatternSpecFreeMethodInfo
    ResolvePatternSpecMethod "match" o = PatternSpecMatchMethodInfo
    ResolvePatternSpecMethod "matchString" o = PatternSpecMatchStringMethodInfo
    ResolvePatternSpecMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif