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

A GMatchInfo is an opaque struct used to return information about
matches.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.GLib.Structs.MatchInfo
    ( 

-- * Exported types
    MatchInfo(..)                           ,
    noMatchInfo                             ,


 -- * Methods
-- ** expandReferences #method:expandReferences#

#if ENABLE_OVERLOADING
    MatchInfoExpandReferencesMethodInfo     ,
#endif
    matchInfoExpandReferences               ,


-- ** fetch #method:fetch#

#if ENABLE_OVERLOADING
    MatchInfoFetchMethodInfo                ,
#endif
    matchInfoFetch                          ,


-- ** fetchAll #method:fetchAll#

#if ENABLE_OVERLOADING
    MatchInfoFetchAllMethodInfo             ,
#endif
    matchInfoFetchAll                       ,


-- ** fetchNamed #method:fetchNamed#

#if ENABLE_OVERLOADING
    MatchInfoFetchNamedMethodInfo           ,
#endif
    matchInfoFetchNamed                     ,


-- ** fetchNamedPos #method:fetchNamedPos#

#if ENABLE_OVERLOADING
    MatchInfoFetchNamedPosMethodInfo        ,
#endif
    matchInfoFetchNamedPos                  ,


-- ** fetchPos #method:fetchPos#

#if ENABLE_OVERLOADING
    MatchInfoFetchPosMethodInfo             ,
#endif
    matchInfoFetchPos                       ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    MatchInfoFreeMethodInfo                 ,
#endif
    matchInfoFree                           ,


-- ** getMatchCount #method:getMatchCount#

#if ENABLE_OVERLOADING
    MatchInfoGetMatchCountMethodInfo        ,
#endif
    matchInfoGetMatchCount                  ,


-- ** getRegex #method:getRegex#

#if ENABLE_OVERLOADING
    MatchInfoGetRegexMethodInfo             ,
#endif
    matchInfoGetRegex                       ,


-- ** getString #method:getString#

#if ENABLE_OVERLOADING
    MatchInfoGetStringMethodInfo            ,
#endif
    matchInfoGetString                      ,


-- ** isPartialMatch #method:isPartialMatch#

#if ENABLE_OVERLOADING
    MatchInfoIsPartialMatchMethodInfo       ,
#endif
    matchInfoIsPartialMatch                 ,


-- ** matches #method:matches#

#if ENABLE_OVERLOADING
    MatchInfoMatchesMethodInfo              ,
#endif
    matchInfoMatches                        ,


-- ** next #method:next#

#if ENABLE_OVERLOADING
    MatchInfoNextMethodInfo                 ,
#endif
    matchInfoNext                           ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    MatchInfoRefMethodInfo                  ,
#endif
    matchInfoRef                            ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    MatchInfoUnrefMethodInfo                ,
#endif
    matchInfoUnref                          ,




    ) 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.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.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.GLib.Structs.Regex as GLib.Regex

-- | Memory-managed wrapper type.
newtype MatchInfo = MatchInfo (ManagedPtr MatchInfo)
foreign import ccall "g_match_info_get_type" c_g_match_info_get_type :: 
    IO GType

instance BoxedObject MatchInfo where
    boxedType :: MatchInfo -> IO GType
boxedType _ = IO GType
c_g_match_info_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `MatchInfo`.
noMatchInfo :: Maybe MatchInfo
noMatchInfo :: Maybe MatchInfo
noMatchInfo = Maybe MatchInfo
forall a. Maybe a
Nothing


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

-- method MatchInfo::expand_references
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "string_to_expand", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to expand", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_match_info_expand_references" g_match_info_expand_references :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    CString ->                              -- string_to_expand : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
Returns a new string containing the text in /@stringToExpand@/ with
references and escape sequences expanded. References refer to the last
match done with /@string@/ against /@regex@/ and have the same syntax used by
'GI.GLib.Structs.Regex.regexReplace'.

The /@stringToExpand@/ must be UTF-8 encoded even if @/G_REGEX_RAW/@ was
passed to 'GI.GLib.Structs.Regex.regexNew'.

The backreferences are extracted from the string passed to the match
function, so you cannot call this function after freeing the string.

/@matchInfo@/ may be 'Nothing' in which case /@stringToExpand@/ must not
contain references. For instance \"foo\\n\" does not refer to an actual
pattern and \'\\n\' merely will be replaced with \\n character,
while to expand \"\\0\" (whole match) one needs the result of a match.
Use 'GI.GLib.Functions.regexCheckReplacement' to find out whether /@stringToExpand@/
contains references.

/Since: 2.14/
-}
matchInfoExpandReferences ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' or 'Nothing' -}
    -> T.Text
    {- ^ /@stringToExpand@/: the string to expand -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the expanded string, or 'Nothing' if an error occurred /(Can throw 'Data.GI.Base.GError.GError')/ -}
matchInfoExpandReferences :: MatchInfo -> Text -> m (Maybe Text)
matchInfoExpandReferences matchInfo :: MatchInfo
matchInfo stringToExpand :: Text
stringToExpand = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CString
stringToExpand' <- Text -> IO CString
textToCString Text
stringToExpand
    IO (Maybe Text) -> IO () -> IO (Maybe Text)
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr MatchInfo -> CString -> Ptr (Ptr GError) -> IO CString
g_match_info_expand_references Ptr MatchInfo
matchInfo' CString
stringToExpand'
        Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
            Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
            CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
        MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stringToExpand'
        Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stringToExpand'
     )

#if ENABLE_OVERLOADING
data MatchInfoExpandReferencesMethodInfo
instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo MatchInfoExpandReferencesMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoExpandReferences

#endif

-- method MatchInfo::fetch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_num", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of the sub expression", 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 "g_match_info_fetch" g_match_info_fetch :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    Int32 ->                                -- match_num : TBasicType TInt
    IO CString

{- |
Retrieves the text matching the /@matchNum@/\'th capturing
parentheses. 0 is the full text of the match, 1 is the first paren
set, 2 the second, and so on.

If /@matchNum@/ is a valid sub pattern but it didn\'t match anything
(e.g. sub pattern 1, matching \"b\" against \"(a)?b\") then an empty
string is returned.

If the match was obtained using the DFA algorithm, that is using
'GI.GLib.Structs.Regex.regexMatchAll' or 'GI.GLib.Structs.Regex.regexMatchAllFull', the retrieved
string is not that of a set of parentheses but that of a matched
substring. Substrings are matched in reverse order of length, so
0 is the longest match.

The string is fetched from the string passed to the match function,
so you cannot call this function after freeing the string.

/Since: 2.14/
-}
matchInfoFetch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> Int32
    {- ^ /@matchNum@/: number of the sub expression -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ The matched substring, or 'Nothing' if an error
    occurred. You have to free the string yourself -}
matchInfoFetch :: MatchInfo -> Int32 -> m (Maybe Text)
matchInfoFetch matchInfo :: MatchInfo
matchInfo matchNum :: Int32
matchNum = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CString
result <- Ptr MatchInfo -> Int32 -> IO CString
g_match_info_fetch Ptr MatchInfo
matchInfo' Int32
matchNum
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if ENABLE_OVERLOADING
data MatchInfoFetchMethodInfo
instance (signature ~ (Int32 -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo MatchInfoFetchMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoFetch

#endif

-- method MatchInfo::fetch_all
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_match_info_fetch_all" g_match_info_fetch_all :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO (Ptr CString)

{- |
Bundles up pointers to each of the matching substrings from a match
and stores them in an array of gchar pointers. The first element in
the returned array is the match number 0, i.e. the entire matched
text.

If a sub pattern didn\'t match anything (e.g. sub pattern 1, matching
\"b\" against \"(a)?b\") then an empty string is inserted.

If the last match was obtained using the DFA algorithm, that is using
'GI.GLib.Structs.Regex.regexMatchAll' or 'GI.GLib.Structs.Regex.regexMatchAllFull', the retrieved
strings are not that matched by sets of parentheses but that of the
matched substring. Substrings are matched in reverse order of length,
so the first one is the longest match.

The strings are fetched from the string passed to the match function,
so you cannot call this function after freeing the string.

/Since: 2.14/
-}
matchInfoFetchAll ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> m [T.Text]
    {- ^ __Returns:__ a 'Nothing'-terminated array of gchar *
    pointers.  It must be freed using 'GI.GLib.Functions.strfreev'. If the previous
    match failed 'Nothing' is returned -}
matchInfoFetchAll :: MatchInfo -> m [Text]
matchInfoFetchAll matchInfo :: MatchInfo
matchInfo = IO [Text] -> m [Text]
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
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Ptr CString
result <- Ptr MatchInfo -> IO (Ptr CString)
g_match_info_fetch_all Ptr MatchInfo
matchInfo'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "matchInfoFetchAll" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if ENABLE_OVERLOADING
data MatchInfoFetchAllMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m) => O.MethodInfo MatchInfoFetchAllMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoFetchAll

#endif

-- method MatchInfo::fetch_named
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of the subexpression", 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 "g_match_info_fetch_named" g_match_info_fetch_named :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    CString ->                              -- name : TBasicType TUTF8
    IO CString

{- |
Retrieves the text matching the capturing parentheses named /@name@/.

If /@name@/ is a valid sub pattern name but it didn\'t match anything
(e.g. sub pattern \"X\", matching \"b\" against \"(?P\<X>a)?b\")
then an empty string is returned.

The string is fetched from the string passed to the match function,
so you cannot call this function after freeing the string.

/Since: 2.14/
-}
matchInfoFetchNamed ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> T.Text
    {- ^ /@name@/: name of the subexpression -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ The matched substring, or 'Nothing' if an error
    occurred. You have to free the string yourself -}
matchInfoFetchNamed :: MatchInfo -> Text -> m (Maybe Text)
matchInfoFetchNamed matchInfo :: MatchInfo
matchInfo name :: Text
name = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
result <- Ptr MatchInfo -> CString -> IO CString
g_match_info_fetch_named Ptr MatchInfo
matchInfo' CString
name'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if ENABLE_OVERLOADING
data MatchInfoFetchNamedMethodInfo
instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo MatchInfoFetchNamedMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoFetchNamed

#endif

-- method MatchInfo::fetch_named_pos
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of the subexpression", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_pos", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to location where to store\n    the start position, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "end_pos", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to location where to store\n    the end position, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_match_info_fetch_named_pos" g_match_info_fetch_named_pos :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    CString ->                              -- name : TBasicType TUTF8
    Ptr Int32 ->                            -- start_pos : TBasicType TInt
    Ptr Int32 ->                            -- end_pos : TBasicType TInt
    IO CInt

{- |
Retrieves the position in bytes of the capturing parentheses named /@name@/.

If /@name@/ is a valid sub pattern name but it didn\'t match anything
(e.g. sub pattern \"X\", matching \"b\" against \"(?P\<X>a)?b\")
then /@startPos@/ and /@endPos@/ are set to -1 and 'True' is returned.

/Since: 2.14/
-}
matchInfoFetchNamedPos ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> T.Text
    {- ^ /@name@/: name of the subexpression -}
    -> m ((Bool, Int32, Int32))
    {- ^ __Returns:__ 'True' if the position was fetched, 'False' otherwise.
    If the position cannot be fetched, /@startPos@/ and /@endPos@/
    are left unchanged. -}
matchInfoFetchNamedPos :: MatchInfo -> Text -> m (Bool, Int32, Int32)
matchInfoFetchNamedPos matchInfo :: MatchInfo
matchInfo name :: Text
name = IO (Bool, Int32, Int32) -> m (Bool, Int32, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Int32, Int32) -> m (Bool, Int32, Int32))
-> IO (Bool, Int32, Int32) -> m (Bool, Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CString
name' <- Text -> IO CString
textToCString Text
name
    Ptr Int32
startPos <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
endPos <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    CInt
result <- Ptr MatchInfo -> CString -> Ptr Int32 -> Ptr Int32 -> IO CInt
g_match_info_fetch_named_pos Ptr MatchInfo
matchInfo' CString
name' Ptr Int32
startPos Ptr Int32
endPos
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Int32
startPos' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
startPos
    Int32
endPos' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
endPos
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
startPos
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
endPos
    (Bool, Int32, Int32) -> IO (Bool, Int32, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Int32
startPos', Int32
endPos')

#if ENABLE_OVERLOADING
data MatchInfoFetchNamedPosMethodInfo
instance (signature ~ (T.Text -> m ((Bool, Int32, Int32))), MonadIO m) => O.MethodInfo MatchInfoFetchNamedPosMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoFetchNamedPos

#endif

-- method MatchInfo::fetch_pos
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_num", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of the sub expression", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_pos", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to location where to store\n    the start position, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "end_pos", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to location where to store\n    the end position, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_match_info_fetch_pos" g_match_info_fetch_pos :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    Int32 ->                                -- match_num : TBasicType TInt
    Ptr Int32 ->                            -- start_pos : TBasicType TInt
    Ptr Int32 ->                            -- end_pos : TBasicType TInt
    IO CInt

{- |
Retrieves the position in bytes of the /@matchNum@/\'th capturing
parentheses. 0 is the full text of the match, 1 is the first
paren set, 2 the second, and so on.

If /@matchNum@/ is a valid sub pattern but it didn\'t match anything
(e.g. sub pattern 1, matching \"b\" against \"(a)?b\") then /@startPos@/
and /@endPos@/ are set to -1 and 'True' is returned.

If the match was obtained using the DFA algorithm, that is using
'GI.GLib.Structs.Regex.regexMatchAll' or 'GI.GLib.Structs.Regex.regexMatchAllFull', the retrieved
position is not that of a set of parentheses but that of a matched
substring. Substrings are matched in reverse order of length, so
0 is the longest match.

/Since: 2.14/
-}
matchInfoFetchPos ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> Int32
    {- ^ /@matchNum@/: number of the sub expression -}
    -> m ((Bool, Int32, Int32))
    {- ^ __Returns:__ 'True' if the position was fetched, 'False' otherwise. If
  the position cannot be fetched, /@startPos@/ and /@endPos@/ are left
  unchanged -}
matchInfoFetchPos :: MatchInfo -> Int32 -> m (Bool, Int32, Int32)
matchInfoFetchPos matchInfo :: MatchInfo
matchInfo matchNum :: Int32
matchNum = IO (Bool, Int32, Int32) -> m (Bool, Int32, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Int32, Int32) -> m (Bool, Int32, Int32))
-> IO (Bool, Int32, Int32) -> m (Bool, Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Ptr Int32
startPos <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
endPos <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    CInt
result <- Ptr MatchInfo -> Int32 -> Ptr Int32 -> Ptr Int32 -> IO CInt
g_match_info_fetch_pos Ptr MatchInfo
matchInfo' Int32
matchNum Ptr Int32
startPos Ptr Int32
endPos
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Int32
startPos' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
startPos
    Int32
endPos' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
endPos
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
startPos
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
endPos
    (Bool, Int32, Int32) -> IO (Bool, Int32, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Int32
startPos', Int32
endPos')

#if ENABLE_OVERLOADING
data MatchInfoFetchPosMethodInfo
instance (signature ~ (Int32 -> m ((Bool, Int32, Int32))), MonadIO m) => O.MethodInfo MatchInfoFetchPosMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoFetchPos

#endif

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

foreign import ccall "g_match_info_free" g_match_info_free :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO ()

{- |
If /@matchInfo@/ is not 'Nothing', calls 'GI.GLib.Structs.MatchInfo.matchInfoUnref'; otherwise does
nothing.

/Since: 2.14/
-}
matchInfoFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo', or 'Nothing' -}
    -> m ()
matchInfoFree :: MatchInfo -> m ()
matchInfoFree matchInfo :: MatchInfo
matchInfo = 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 MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Ptr MatchInfo -> IO ()
g_match_info_free Ptr MatchInfo
matchInfo'
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data MatchInfoFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MatchInfoFreeMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoFree

#endif

-- method MatchInfo::get_match_count
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_match_info_get_match_count" g_match_info_get_match_count :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO Int32

{- |
Retrieves the number of matched substrings (including substring 0,
that is the whole matched text), so 1 is returned if the pattern
has no substrings in it and 0 is returned if the match failed.

If the last match was obtained using the DFA algorithm, that is
using 'GI.GLib.Structs.Regex.regexMatchAll' or 'GI.GLib.Structs.Regex.regexMatchAllFull', the retrieved
count is not that of the number of capturing parentheses but that of
the number of matched substrings.

/Since: 2.14/
-}
matchInfoGetMatchCount ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> m Int32
    {- ^ __Returns:__ Number of matched substrings, or -1 if an error occurred -}
matchInfoGetMatchCount :: MatchInfo -> m Int32
matchInfoGetMatchCount matchInfo :: MatchInfo
matchInfo = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Int32
result <- Ptr MatchInfo -> IO Int32
g_match_info_get_match_count Ptr MatchInfo
matchInfo'
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data MatchInfoGetMatchCountMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo MatchInfoGetMatchCountMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoGetMatchCount

#endif

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

foreign import ccall "g_match_info_get_regex" g_match_info_get_regex :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO (Ptr GLib.Regex.Regex)

{- |
Returns 'GI.GLib.Structs.Regex.Regex' object used in /@matchInfo@/. It belongs to Glib
and must not be freed. Use 'GI.GLib.Structs.Regex.regexRef' if you need to keep it
after you free /@matchInfo@/ object.

/Since: 2.14/
-}
matchInfoGetRegex ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' -}
    -> m GLib.Regex.Regex
    {- ^ __Returns:__ 'GI.GLib.Structs.Regex.Regex' object used in /@matchInfo@/ -}
matchInfoGetRegex :: MatchInfo -> m Regex
matchInfoGetRegex matchInfo :: MatchInfo
matchInfo = IO Regex -> m Regex
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Regex -> m Regex) -> IO Regex -> m Regex
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Ptr Regex
result <- Ptr MatchInfo -> IO (Ptr Regex)
g_match_info_get_regex Ptr MatchInfo
matchInfo'
    Text -> Ptr Regex -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "matchInfoGetRegex" Ptr Regex
result
    Regex
result' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
GLib.Regex.Regex) Ptr Regex
result
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result'

#if ENABLE_OVERLOADING
data MatchInfoGetRegexMethodInfo
instance (signature ~ (m GLib.Regex.Regex), MonadIO m) => O.MethodInfo MatchInfoGetRegexMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoGetRegex

#endif

-- method MatchInfo::get_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo", 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 "g_match_info_get_string" g_match_info_get_string :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO CString

{- |
Returns the string searched with /@matchInfo@/. This is the
string passed to 'GI.GLib.Structs.Regex.regexMatch' or 'GI.GLib.Structs.Regex.regexReplace' so
you may not free it before calling this function.

/Since: 2.14/
-}
matchInfoGetString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' -}
    -> m T.Text
    {- ^ __Returns:__ the string searched with /@matchInfo@/ -}
matchInfoGetString :: MatchInfo -> m Text
matchInfoGetString matchInfo :: MatchInfo
matchInfo = IO Text -> m Text
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
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CString
result <- Ptr MatchInfo -> IO CString
g_match_info_get_string Ptr MatchInfo
matchInfo'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "matchInfoGetString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data MatchInfoGetStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo MatchInfoGetStringMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoGetString

#endif

-- method MatchInfo::is_partial_match
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo structure", 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_match_info_is_partial_match" g_match_info_is_partial_match :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO CInt

{- |
Usually if the string passed to g_regex_match*() matches as far as
it goes, but is too short to match the entire pattern, 'False' is
returned. There are circumstances where it might be helpful to
distinguish this case from other cases in which there is no match.

Consider, for example, an application where a human is required to
type in data for a field with specific formatting requirements. An
example might be a date in the form ddmmmyy, defined by the pattern
\"^\\d?\\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\d\\d$\".
If the application sees the user’s keystrokes one by one, and can
check that what has been typed so far is potentially valid, it is
able to raise an error as soon as a mistake is made.

GRegex supports the concept of partial matching by means of the
@/G_REGEX_MATCH_PARTIAL_SOFT/@ and @/G_REGEX_MATCH_PARTIAL_HARD/@ flags.
When they are used, the return code for
'GI.GLib.Structs.Regex.regexMatch' or 'GI.GLib.Structs.Regex.regexMatchFull' is, as usual, 'True'
for a complete match, 'False' otherwise. But, when these functions
return 'False', you can check if the match was partial calling
'GI.GLib.Structs.MatchInfo.matchInfoIsPartialMatch'.

The difference between @/G_REGEX_MATCH_PARTIAL_SOFT/@ and
@/G_REGEX_MATCH_PARTIAL_HARD/@ is that when a partial match is encountered
with @/G_REGEX_MATCH_PARTIAL_SOFT/@, matching continues to search for a
possible complete match, while with @/G_REGEX_MATCH_PARTIAL_HARD/@ matching
stops at the partial match.
When both @/G_REGEX_MATCH_PARTIAL_SOFT/@ and @/G_REGEX_MATCH_PARTIAL_HARD/@
are set, the latter takes precedence.

There were formerly some restrictions on the pattern for partial matching.
The restrictions no longer apply.

See pcrepartial(3) for more information on partial matching.

/Since: 2.14/
-}
matchInfoIsPartialMatch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the match was partial, 'False' otherwise -}
matchInfoIsPartialMatch :: MatchInfo -> m Bool
matchInfoIsPartialMatch matchInfo :: MatchInfo
matchInfo = 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 MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CInt
result <- Ptr MatchInfo -> IO CInt
g_match_info_is_partial_match Ptr MatchInfo
matchInfo'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data MatchInfoIsPartialMatchMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo MatchInfoIsPartialMatchMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoIsPartialMatch

#endif

-- method MatchInfo::matches
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo structure", 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_match_info_matches" g_match_info_matches :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO CInt

{- |
Returns whether the previous match operation succeeded.

/Since: 2.14/
-}
matchInfoMatches ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the previous match operation succeeded,
  'False' otherwise -}
matchInfoMatches :: MatchInfo -> m Bool
matchInfoMatches matchInfo :: MatchInfo
matchInfo = 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 MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    CInt
result <- Ptr MatchInfo -> IO CInt
g_match_info_matches Ptr MatchInfo
matchInfo'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data MatchInfoMatchesMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo MatchInfoMatchesMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoMatches

#endif

-- method MatchInfo::next
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMatchInfo structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_match_info_next" g_match_info_next :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Scans for the next match using the same parameters of the previous
call to 'GI.GLib.Structs.Regex.regexMatchFull' or 'GI.GLib.Structs.Regex.regexMatch' that returned
/@matchInfo@/.

The match is done on the string passed to the match function, so you
cannot free it before calling this function.

/Since: 2.14/
-}
matchInfoNext ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' structure -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
matchInfoNext :: MatchInfo -> m ()
matchInfoNext matchInfo :: MatchInfo
matchInfo = 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 MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr MatchInfo -> Ptr (Ptr GError) -> IO CInt
g_match_info_next Ptr MatchInfo
matchInfo'
        MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if ENABLE_OVERLOADING
data MatchInfoNextMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MatchInfoNextMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoNext

#endif

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

foreign import ccall "g_match_info_ref" g_match_info_ref :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO (Ptr MatchInfo)

{- |
Increases reference count of /@matchInfo@/ by 1.

/Since: 2.30/
-}
matchInfoRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' -}
    -> m MatchInfo
    {- ^ __Returns:__ /@matchInfo@/ -}
matchInfoRef :: MatchInfo -> m MatchInfo
matchInfoRef matchInfo :: MatchInfo
matchInfo = IO MatchInfo -> m MatchInfo
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MatchInfo -> m MatchInfo) -> IO MatchInfo -> m MatchInfo
forall a b. (a -> b) -> a -> b
$ do
    Ptr MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Ptr MatchInfo
result <- Ptr MatchInfo -> IO (Ptr MatchInfo)
g_match_info_ref Ptr MatchInfo
matchInfo'
    Text -> Ptr MatchInfo -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "matchInfoRef" Ptr MatchInfo
result
    MatchInfo
result' <- ((ManagedPtr MatchInfo -> MatchInfo)
-> Ptr MatchInfo -> IO MatchInfo
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MatchInfo -> MatchInfo
MatchInfo) Ptr MatchInfo
result
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    MatchInfo -> IO MatchInfo
forall (m :: * -> *) a. Monad m => a -> m a
return MatchInfo
result'

#if ENABLE_OVERLOADING
data MatchInfoRefMethodInfo
instance (signature ~ (m MatchInfo), MonadIO m) => O.MethodInfo MatchInfoRefMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoRef

#endif

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

foreign import ccall "g_match_info_unref" g_match_info_unref :: 
    Ptr MatchInfo ->                        -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO ()

{- |
Decreases reference count of /@matchInfo@/ by 1. When reference count drops
to zero, it frees all the memory associated with the match_info structure.

/Since: 2.30/
-}
matchInfoUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MatchInfo
    {- ^ /@matchInfo@/: a 'GI.GLib.Structs.MatchInfo.MatchInfo' -}
    -> m ()
matchInfoUnref :: MatchInfo -> m ()
matchInfoUnref matchInfo :: MatchInfo
matchInfo = 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 MatchInfo
matchInfo' <- MatchInfo -> IO (Ptr MatchInfo)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MatchInfo
matchInfo
    Ptr MatchInfo -> IO ()
g_match_info_unref Ptr MatchInfo
matchInfo'
    MatchInfo -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MatchInfo
matchInfo
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data MatchInfoUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MatchInfoUnrefMethodInfo MatchInfo signature where
    overloadedMethod _ = matchInfoUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveMatchInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveMatchInfoMethod "expandReferences" o = MatchInfoExpandReferencesMethodInfo
    ResolveMatchInfoMethod "fetch" o = MatchInfoFetchMethodInfo
    ResolveMatchInfoMethod "fetchAll" o = MatchInfoFetchAllMethodInfo
    ResolveMatchInfoMethod "fetchNamed" o = MatchInfoFetchNamedMethodInfo
    ResolveMatchInfoMethod "fetchNamedPos" o = MatchInfoFetchNamedPosMethodInfo
    ResolveMatchInfoMethod "fetchPos" o = MatchInfoFetchPosMethodInfo
    ResolveMatchInfoMethod "free" o = MatchInfoFreeMethodInfo
    ResolveMatchInfoMethod "isPartialMatch" o = MatchInfoIsPartialMatchMethodInfo
    ResolveMatchInfoMethod "matches" o = MatchInfoMatchesMethodInfo
    ResolveMatchInfoMethod "next" o = MatchInfoNextMethodInfo
    ResolveMatchInfoMethod "ref" o = MatchInfoRefMethodInfo
    ResolveMatchInfoMethod "unref" o = MatchInfoUnrefMethodInfo
    ResolveMatchInfoMethod "getMatchCount" o = MatchInfoGetMatchCountMethodInfo
    ResolveMatchInfoMethod "getRegex" o = MatchInfoGetRegexMethodInfo
    ResolveMatchInfoMethod "getString" o = MatchInfoGetStringMethodInfo
    ResolveMatchInfoMethod l o = O.MethodResolutionFailed l o

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

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