{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The g_regex_*() functions implement regular
-- expression pattern matching using syntax and semantics similar to
-- Perl regular expression.
-- 
-- Some functions accept a /@startPosition@/ argument, setting it differs
-- from just passing over a shortened string and setting @/G_REGEX_MATCH_NOTBOL/@
-- in the case of a pattern that begins with any kind of lookbehind assertion.
-- For example, consider the pattern \"\\Biss\\B\" which finds occurrences of \"iss\"
-- in the middle of words. (\"\\B\" matches only if the current position in the
-- subject is not a word boundary.) When applied to the string \"Mississipi\"
-- from the fourth byte, namely \"issipi\", it does not match, because \"\\B\" is
-- always false at the start of the subject, which is deemed to be a word
-- boundary. However, if the entire string is passed , but with
-- /@startPosition@/ set to 4, it finds the second occurrence of \"iss\" because
-- it is able to look behind the starting point to discover that it is
-- preceded by a letter.
-- 
-- Note that, unless you set the @/G_REGEX_RAW/@ flag, all the strings passed
-- to these functions must be encoded in UTF-8. The lengths and the positions
-- inside the strings are in bytes and not in characters, so, for instance,
-- \"\\xc3\\xa0\" (i.e. \"à\") is two bytes long but it is treated as a
-- single character. If you set @/G_REGEX_RAW/@ the strings can be non-valid
-- UTF-8 strings and a byte is treated as a character, so \"\\xc3\\xa0\" is two
-- bytes and two characters long.
-- 
-- When matching a pattern, \"\\n\" matches only against a \"\\n\" character in
-- the string, and \"\\r\" matches only a \"\\r\" character. To match any newline
-- sequence use \"\\R\". This particular group matches either the two-character
-- sequence CR + LF (\"\\r\\n\"), or one of the single characters LF (linefeed,
-- U+000A, \"\\n\"), VT vertical tab, U+000B, \"\\v\"), FF (formfeed, U+000C, \"\\f\"),
-- CR (carriage return, U+000D, \"\\r\"), NEL (next line, U+0085), LS (line
-- separator, U+2028), or PS (paragraph separator, U+2029).
-- 
-- The behaviour of the dot, circumflex, and dollar metacharacters are
-- affected by newline characters, the default is to recognize any newline
-- character (the same characters recognized by \"\\R\"). This can be changed
-- with @/G_REGEX_NEWLINE_CR/@, @/G_REGEX_NEWLINE_LF/@ and @/G_REGEX_NEWLINE_CRLF/@
-- compile options, and with @/G_REGEX_MATCH_NEWLINE_ANY/@,
-- @/G_REGEX_MATCH_NEWLINE_CR/@, @/G_REGEX_MATCH_NEWLINE_LF/@ and
-- @/G_REGEX_MATCH_NEWLINE_CRLF/@ match options. These settings are also
-- relevant when compiling a pattern if @/G_REGEX_EXTENDED/@ is set, and an
-- unescaped \"#\" outside a character class is encountered. This indicates
-- a comment that lasts until after the next newline.
-- 
-- When setting the 'GI.GLib.Flags.RegexCompileFlagsJavascriptCompat' flag, pattern syntax and pattern
-- matching is changed to be compatible with the way that regular expressions
-- work in JavaScript. More precisely, a lonely \']\' character in the pattern
-- is a syntax error; the \'\\x\' escape only allows 0 to 2 hexadecimal digits, and
-- you must use the \'\\u\' escape sequence with 4 hex digits to specify a unicode
-- codepoint instead of \'\\x\' or \'x{....}\'. If \'\\x\' or \'\\u\' are not followed by
-- the specified number of hex digits, they match \'x\' and \'u\' literally; also
-- \'\\U\' always matches \'U\' instead of being an error in the pattern. Finally,
-- pattern matching is modified so that back references to an unset subpattern
-- group produces a match with the empty string instead of an error. See
-- pcreapi(3) for more information.
-- 
-- Creating and manipulating the same t'GI.GLib.Structs.Regex.Regex' structure from different
-- threads is not a problem as t'GI.GLib.Structs.Regex.Regex' does not modify its internal
-- state between creation and destruction, on the other hand t'GI.GLib.Structs.MatchInfo.MatchInfo'
-- is not threadsafe.
-- 
-- The regular expressions low-level functionalities are obtained through
-- the excellent
-- <http://www.pcre.org/ PCRE>
-- library written by Philip Hazel.
-- 
-- /Since: 2.14/

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

module GI.GLib.Structs.Regex
    ( 

-- * Exported types
    Regex(..)                               ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveRegexMethod                      ,
#endif


-- ** checkReplacement #method:checkReplacement#

    regexCheckReplacement                   ,


-- ** errorQuark #method:errorQuark#

    regexErrorQuark                         ,


-- ** escapeNul #method:escapeNul#

    regexEscapeNul                          ,


-- ** escapeString #method:escapeString#

    regexEscapeString                       ,


-- ** getCaptureCount #method:getCaptureCount#

#if defined(ENABLE_OVERLOADING)
    RegexGetCaptureCountMethodInfo          ,
#endif
    regexGetCaptureCount                    ,


-- ** getCompileFlags #method:getCompileFlags#

#if defined(ENABLE_OVERLOADING)
    RegexGetCompileFlagsMethodInfo          ,
#endif
    regexGetCompileFlags                    ,


-- ** getHasCrOrLf #method:getHasCrOrLf#

#if defined(ENABLE_OVERLOADING)
    RegexGetHasCrOrLfMethodInfo             ,
#endif
    regexGetHasCrOrLf                       ,


-- ** getMatchFlags #method:getMatchFlags#

#if defined(ENABLE_OVERLOADING)
    RegexGetMatchFlagsMethodInfo            ,
#endif
    regexGetMatchFlags                      ,


-- ** getMaxBackref #method:getMaxBackref#

#if defined(ENABLE_OVERLOADING)
    RegexGetMaxBackrefMethodInfo            ,
#endif
    regexGetMaxBackref                      ,


-- ** getMaxLookbehind #method:getMaxLookbehind#

#if defined(ENABLE_OVERLOADING)
    RegexGetMaxLookbehindMethodInfo         ,
#endif
    regexGetMaxLookbehind                   ,


-- ** getPattern #method:getPattern#

#if defined(ENABLE_OVERLOADING)
    RegexGetPatternMethodInfo               ,
#endif
    regexGetPattern                         ,


-- ** getStringNumber #method:getStringNumber#

#if defined(ENABLE_OVERLOADING)
    RegexGetStringNumberMethodInfo          ,
#endif
    regexGetStringNumber                    ,


-- ** match #method:match#

#if defined(ENABLE_OVERLOADING)
    RegexMatchMethodInfo                    ,
#endif
    regexMatch                              ,


-- ** matchAll #method:matchAll#

#if defined(ENABLE_OVERLOADING)
    RegexMatchAllMethodInfo                 ,
#endif
    regexMatchAll                           ,


-- ** matchAllFull #method:matchAllFull#

#if defined(ENABLE_OVERLOADING)
    RegexMatchAllFullMethodInfo             ,
#endif
    regexMatchAllFull                       ,


-- ** matchFull #method:matchFull#

#if defined(ENABLE_OVERLOADING)
    RegexMatchFullMethodInfo                ,
#endif
    regexMatchFull                          ,


-- ** matchSimple #method:matchSimple#

    regexMatchSimple                        ,


-- ** new #method:new#

    regexNew                                ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    RegexRefMethodInfo                      ,
#endif
    regexRef                                ,


-- ** replace #method:replace#

#if defined(ENABLE_OVERLOADING)
    RegexReplaceMethodInfo                  ,
#endif
    regexReplace                            ,


-- ** replaceLiteral #method:replaceLiteral#

#if defined(ENABLE_OVERLOADING)
    RegexReplaceLiteralMethodInfo           ,
#endif
    regexReplaceLiteral                     ,


-- ** split #method:split#

#if defined(ENABLE_OVERLOADING)
    RegexSplitMethodInfo                    ,
#endif
    regexSplit                              ,


-- ** splitFull #method:splitFull#

#if defined(ENABLE_OVERLOADING)
    RegexSplitFullMethodInfo                ,
#endif
    regexSplitFull                          ,


-- ** splitSimple #method:splitSimple#

    regexSplitSimple                        ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    RegexUnrefMethodInfo                    ,
#endif
    regexUnref                              ,




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

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

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

foreign import ccall "g_regex_get_type" c_g_regex_get_type :: 
    IO GType

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

instance B.Types.TypedObject Regex where
    glibType :: IO GType
glibType = IO GType
c_g_regex_get_type

instance B.Types.GBoxed Regex

-- | Convert 'Regex' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Regex where
    toGValue :: Regex -> IO GValue
toGValue Regex
o = do
        GType
gtype <- IO GType
c_g_regex_get_type
        Regex -> (Ptr Regex -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Regex
o (GType -> (GValue -> Ptr Regex -> IO ()) -> Ptr Regex -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Regex -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
        
    fromGValue :: GValue -> IO Regex
fromGValue GValue
gv = do
        Ptr Regex
ptr <- GValue -> IO (Ptr Regex)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Regex)
        (ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Regex -> Regex
Regex Ptr Regex
ptr
        
    


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

-- method Regex::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "pattern"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the regular expression"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "compile_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexCompileFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "compile options for the regular expression, or 0"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "match options for the regular expression, or 0"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "Regex" })
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_new" g_regex_new :: 
    CString ->                              -- pattern : TBasicType TUTF8
    CUInt ->                                -- compile_options : TInterface (Name {namespace = "GLib", name = "RegexCompileFlags"})
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Regex)

-- | Compiles the regular expression to an internal form, and does
-- the initial setup of the t'GI.GLib.Structs.Regex.Regex' structure.
-- 
-- /Since: 2.14/
regexNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@pattern@/: the regular expression
    -> [GLib.Flags.RegexCompileFlags]
    -- ^ /@compileOptions@/: compile options for the regular expression, or 0
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options for the regular expression, or 0
    -> m (Maybe Regex)
    -- ^ __Returns:__ a t'GI.GLib.Structs.Regex.Regex' structure or 'P.Nothing' if an error occured. Call
    --   'GI.GLib.Structs.Regex.regexUnref' when you are done with it /(Can throw 'Data.GI.Base.GError.GError')/
regexNew :: Text -> [RegexCompileFlags] -> [RegexMatchFlags] -> m (Maybe Regex)
regexNew Text
pattern [RegexCompileFlags]
compileOptions [RegexMatchFlags]
matchOptions = IO (Maybe Regex) -> m (Maybe Regex)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Regex) -> m (Maybe Regex))
-> IO (Maybe Regex) -> m (Maybe Regex)
forall a b. (a -> b) -> a -> b
$ do
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    let compileOptions' :: CUInt
compileOptions' = [RegexCompileFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexCompileFlags]
compileOptions
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    IO (Maybe Regex) -> IO () -> IO (Maybe Regex)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Regex
result <- (Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex))
-> (Ptr (Ptr GError) -> IO (Ptr Regex)) -> IO (Ptr Regex)
forall a b. (a -> b) -> a -> b
$ CString -> CUInt -> CUInt -> Ptr (Ptr GError) -> IO (Ptr Regex)
g_regex_new CString
pattern' CUInt
compileOptions' CUInt
matchOptions'
        Maybe Regex
maybeResult <- Ptr Regex -> (Ptr Regex -> IO Regex) -> IO (Maybe Regex)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Regex
result ((Ptr Regex -> IO Regex) -> IO (Maybe Regex))
-> (Ptr Regex -> IO Regex) -> IO (Maybe Regex)
forall a b. (a -> b) -> a -> b
$ \Ptr Regex
result' -> do
            Regex
result'' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
Regex) Ptr Regex
result'
            Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
        Maybe Regex -> IO (Maybe Regex)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Regex
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- method Regex::get_capture_count
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex" , 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_regex_get_capture_count" g_regex_get_capture_count :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO Int32

-- | Returns the number of capturing subpatterns in the pattern.
-- 
-- /Since: 2.14/
regexGetCaptureCount ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex'
    -> m Int32
    -- ^ __Returns:__ the number of capturing subpatterns
regexGetCaptureCount :: Regex -> m Int32
regexGetCaptureCount Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Int32
result <- Ptr Regex -> IO Int32
g_regex_get_capture_count Ptr Regex
regex'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data RegexGetCaptureCountMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo RegexGetCaptureCountMethodInfo Regex signature where
    overloadedMethod = regexGetCaptureCount

#endif

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

foreign import ccall "g_regex_get_compile_flags" g_regex_get_compile_flags :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO CUInt

-- | Returns the compile options that /@regex@/ was created with.
-- 
-- Depending on the version of PCRE that is used, this may or may not
-- include flags set by option expressions such as @(?i)@ found at the
-- top-level within the compiled pattern.
-- 
-- /Since: 2.26/
regexGetCompileFlags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex'
    -> m [GLib.Flags.RegexCompileFlags]
    -- ^ __Returns:__ flags from t'GI.GLib.Flags.RegexCompileFlags'
regexGetCompileFlags :: Regex -> m [RegexCompileFlags]
regexGetCompileFlags Regex
regex = IO [RegexCompileFlags] -> m [RegexCompileFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [RegexCompileFlags] -> m [RegexCompileFlags])
-> IO [RegexCompileFlags] -> m [RegexCompileFlags]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CUInt
result <- Ptr Regex -> IO CUInt
g_regex_get_compile_flags Ptr Regex
regex'
    let result' :: [RegexCompileFlags]
result' = CUInt -> [RegexCompileFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
result
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    [RegexCompileFlags] -> IO [RegexCompileFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [RegexCompileFlags]
result'

#if defined(ENABLE_OVERLOADING)
data RegexGetCompileFlagsMethodInfo
instance (signature ~ (m [GLib.Flags.RegexCompileFlags]), MonadIO m) => O.MethodInfo RegexGetCompileFlagsMethodInfo Regex signature where
    overloadedMethod = regexGetCompileFlags

#endif

-- method Regex::get_has_cr_or_lf
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex 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_regex_get_has_cr_or_lf" g_regex_get_has_cr_or_lf :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO CInt

-- | Checks whether the pattern contains explicit CR or LF references.
-- 
-- /Since: 2.34/
regexGetHasCrOrLf ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the pattern contains explicit CR or LF references
regexGetHasCrOrLf :: Regex -> m Bool
regexGetHasCrOrLf Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CInt
result <- Ptr Regex -> IO CInt
g_regex_get_has_cr_or_lf Ptr Regex
regex'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data RegexGetHasCrOrLfMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RegexGetHasCrOrLfMethodInfo Regex signature where
    overloadedMethod = regexGetHasCrOrLf

#endif

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

foreign import ccall "g_regex_get_match_flags" g_regex_get_match_flags :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO CUInt

-- | Returns the match options that /@regex@/ was created with.
-- 
-- /Since: 2.26/
regexGetMatchFlags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex'
    -> m [GLib.Flags.RegexMatchFlags]
    -- ^ __Returns:__ flags from t'GI.GLib.Flags.RegexMatchFlags'
regexGetMatchFlags :: Regex -> m [RegexMatchFlags]
regexGetMatchFlags Regex
regex = IO [RegexMatchFlags] -> m [RegexMatchFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [RegexMatchFlags] -> m [RegexMatchFlags])
-> IO [RegexMatchFlags] -> m [RegexMatchFlags]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CUInt
result <- Ptr Regex -> IO CUInt
g_regex_get_match_flags Ptr Regex
regex'
    let result' :: [RegexMatchFlags]
result' = CUInt -> [RegexMatchFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
result
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    [RegexMatchFlags] -> IO [RegexMatchFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [RegexMatchFlags]
result'

#if defined(ENABLE_OVERLOADING)
data RegexGetMatchFlagsMethodInfo
instance (signature ~ (m [GLib.Flags.RegexMatchFlags]), MonadIO m) => O.MethodInfo RegexGetMatchFlagsMethodInfo Regex signature where
    overloadedMethod = regexGetMatchFlags

#endif

-- method Regex::get_max_backref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex" , 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_regex_get_max_backref" g_regex_get_max_backref :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO Int32

-- | Returns the number of the highest back reference
-- in the pattern, or 0 if the pattern does not contain
-- back references.
-- 
-- /Since: 2.14/
regexGetMaxBackref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex'
    -> m Int32
    -- ^ __Returns:__ the number of the highest back reference
regexGetMaxBackref :: Regex -> m Int32
regexGetMaxBackref Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Int32
result <- Ptr Regex -> IO Int32
g_regex_get_max_backref Ptr Regex
regex'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data RegexGetMaxBackrefMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo RegexGetMaxBackrefMethodInfo Regex signature where
    overloadedMethod = regexGetMaxBackref

#endif

-- method Regex::get_max_lookbehind
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex 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_regex_get_max_lookbehind" g_regex_get_max_lookbehind :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO Int32

-- | Gets the number of characters in the longest lookbehind assertion in the
-- pattern. This information is useful when doing multi-segment matching using
-- the partial matching facilities.
-- 
-- /Since: 2.38/
regexGetMaxLookbehind ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> m Int32
    -- ^ __Returns:__ the number of characters in the longest lookbehind assertion.
regexGetMaxLookbehind :: Regex -> m Int32
regexGetMaxLookbehind Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Int32
result <- Ptr Regex -> IO Int32
g_regex_get_max_lookbehind Ptr Regex
regex'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data RegexGetMaxLookbehindMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo RegexGetMaxLookbehindMethodInfo Regex signature where
    overloadedMethod = regexGetMaxLookbehind

#endif

-- method Regex::get_pattern
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure"
--                 , 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_regex_get_pattern" g_regex_get_pattern :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO CString

-- | Gets the pattern string associated with /@regex@/, i.e. a copy of
-- the string passed to 'GI.GLib.Structs.Regex.regexNew'.
-- 
-- /Since: 2.14/
regexGetPattern ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> m T.Text
    -- ^ __Returns:__ the pattern of /@regex@/
regexGetPattern :: Regex -> m Text
regexGetPattern Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CString
result <- Ptr Regex -> IO CString
g_regex_get_pattern Ptr Regex
regex'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexGetPattern" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data RegexGetPatternMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RegexGetPatternMethodInfo Regex signature where
    overloadedMethod = regexGetPattern

#endif

-- method Regex::get_string_number
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GRegex 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 TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_regex_get_string_number" g_regex_get_string_number :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    CString ->                              -- name : TBasicType TUTF8
    IO Int32

-- | Retrieves the number of the subexpression named /@name@/.
-- 
-- /Since: 2.14/
regexGetStringNumber ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: t'GI.GLib.Structs.Regex.Regex' structure
    -> T.Text
    -- ^ /@name@/: name of the subexpression
    -> m Int32
    -- ^ __Returns:__ The number of the subexpression or -1 if /@name@/
    --   does not exists
regexGetStringNumber :: Regex -> Text -> m Int32
regexGetStringNumber Regex
regex Text
name = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CString
name' <- Text -> IO CString
textToCString Text
name
    Int32
result <- Ptr Regex -> CString -> IO Int32
g_regex_get_string_number Ptr Regex
regex' CString
name'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data RegexGetStringNumberMethodInfo
instance (signature ~ (T.Text -> m Int32), MonadIO m) => O.MethodInfo RegexGetStringNumberMethodInfo Regex signature where
    overloadedMethod = regexGetStringNumber

#endif

-- method Regex::match
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure from g_regex_new()"
--                 , 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 = Just "the string to scan for matches"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match options" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_info"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "MatchInfo" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "pointer to location where to store\n    the #GMatchInfo, or %NULL if you do not need it"
--                 , 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_regex_match" g_regex_match :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    CString ->                              -- string : TBasicType TUTF8
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GLib.MatchInfo.MatchInfo) ->   -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO CInt

-- | Scans for a match in /@string@/ for the pattern in /@regex@/.
-- The /@matchOptions@/ are combined with the match options specified
-- when the /@regex@/ structure was created, letting you have more
-- flexibility in reusing t'GI.GLib.Structs.Regex.Regex' structures.
-- 
-- Unless 'GI.GLib.Flags.RegexCompileFlagsRaw' is specified in the options, /@string@/ must be valid UTF-8.
-- 
-- A t'GI.GLib.Structs.MatchInfo.MatchInfo' structure, used to get information on the match,
-- is stored in /@matchInfo@/ if not 'P.Nothing'. Note that if /@matchInfo@/
-- is not 'P.Nothing' then it is created even if the function returns 'P.False',
-- i.e. you must free it regardless if regular expression actually matched.
-- 
-- To retrieve all the non-overlapping matches of the pattern in
-- string you can use 'GI.GLib.Structs.MatchInfo.matchInfoNext'.
-- 
-- 
-- === /C code/
-- >
-- >static void
-- >print_uppercase_words (const gchar *string)
-- >{
-- >  // Print all uppercase-only words.
-- >  GRegex *regex;
-- >  GMatchInfo *match_info;
-- > 
-- >  regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
-- >  g_regex_match (regex, string, 0, &match_info);
-- >  while (g_match_info_matches (match_info))
-- >    {
-- >      gchar *word = g_match_info_fetch (match_info, 0);
-- >      g_print ("Found: %s\n", word);
-- >      g_free (word);
-- >      g_match_info_next (match_info, NULL);
-- >    }
-- >  g_match_info_free (match_info);
-- >  g_regex_unref (regex);
-- >}
-- 
-- 
-- /@string@/ is not copied and is used in t'GI.GLib.Structs.MatchInfo.MatchInfo' internally. If
-- you use any t'GI.GLib.Structs.MatchInfo.MatchInfo' method (except 'GI.GLib.Structs.MatchInfo.matchInfoFree') after
-- freeing or modifying /@string@/ then the behaviour is undefined.
-- 
-- /Since: 2.14/
regexMatch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure from 'GI.GLib.Structs.Regex.regexNew'
    -> T.Text
    -- ^ /@string@/: the string to scan for matches
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options
    -> m ((Bool, GLib.MatchInfo.MatchInfo))
    -- ^ __Returns:__ 'P.True' is the string matched, 'P.False' otherwise
regexMatch :: Regex -> Text -> [RegexMatchFlags] -> m (Bool, MatchInfo)
regexMatch Regex
regex Text
string [RegexMatchFlags]
matchOptions = IO (Bool, MatchInfo) -> m (Bool, MatchInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, MatchInfo) -> m (Bool, MatchInfo))
-> IO (Bool, MatchInfo) -> m (Bool, MatchInfo)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CString
string' <- Text -> IO CString
textToCString Text
string
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    Ptr (Ptr MatchInfo)
matchInfo <- IO (Ptr (Ptr MatchInfo))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr GLib.MatchInfo.MatchInfo))
    CInt
result <- Ptr Regex -> CString -> CUInt -> Ptr (Ptr MatchInfo) -> IO CInt
g_regex_match Ptr Regex
regex' CString
string' CUInt
matchOptions' Ptr (Ptr MatchInfo)
matchInfo
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Ptr MatchInfo
matchInfo' <- Ptr (Ptr MatchInfo) -> IO (Ptr MatchInfo)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr MatchInfo)
matchInfo
    MatchInfo
matchInfo'' <- ((ManagedPtr MatchInfo -> MatchInfo)
-> Ptr MatchInfo -> IO MatchInfo
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MatchInfo -> MatchInfo
GLib.MatchInfo.MatchInfo) Ptr MatchInfo
matchInfo'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Ptr (Ptr MatchInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr MatchInfo)
matchInfo
    (Bool, MatchInfo) -> IO (Bool, MatchInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', MatchInfo
matchInfo'')

#if defined(ENABLE_OVERLOADING)
data RegexMatchMethodInfo
instance (signature ~ (T.Text -> [GLib.Flags.RegexMatchFlags] -> m ((Bool, GLib.MatchInfo.MatchInfo))), MonadIO m) => O.MethodInfo RegexMatchMethodInfo Regex signature where
    overloadedMethod = regexMatch

#endif

-- method Regex::match_all
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure from g_regex_new()"
--                 , 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 = Just "the string to scan for matches"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match options" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_info"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "MatchInfo" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "pointer to location where to store\n    the #GMatchInfo, or %NULL if you do not need it"
--                 , 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_regex_match_all" g_regex_match_all :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    CString ->                              -- string : TBasicType TUTF8
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GLib.MatchInfo.MatchInfo) ->   -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    IO CInt

-- | Using the standard algorithm for regular expression matching only
-- the longest match in the string is retrieved. This function uses
-- a different algorithm so it can retrieve all the possible matches.
-- For more documentation see 'GI.GLib.Structs.Regex.regexMatchAllFull'.
-- 
-- A t'GI.GLib.Structs.MatchInfo.MatchInfo' structure, used to get information on the match, is
-- stored in /@matchInfo@/ if not 'P.Nothing'. Note that if /@matchInfo@/ is
-- not 'P.Nothing' then it is created even if the function returns 'P.False',
-- i.e. you must free it regardless if regular expression actually
-- matched.
-- 
-- /@string@/ is not copied and is used in t'GI.GLib.Structs.MatchInfo.MatchInfo' internally. If
-- you use any t'GI.GLib.Structs.MatchInfo.MatchInfo' method (except 'GI.GLib.Structs.MatchInfo.matchInfoFree') after
-- freeing or modifying /@string@/ then the behaviour is undefined.
-- 
-- /Since: 2.14/
regexMatchAll ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure from 'GI.GLib.Structs.Regex.regexNew'
    -> T.Text
    -- ^ /@string@/: the string to scan for matches
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options
    -> m ((Bool, GLib.MatchInfo.MatchInfo))
    -- ^ __Returns:__ 'P.True' is the string matched, 'P.False' otherwise
regexMatchAll :: Regex -> Text -> [RegexMatchFlags] -> m (Bool, MatchInfo)
regexMatchAll Regex
regex Text
string [RegexMatchFlags]
matchOptions = IO (Bool, MatchInfo) -> m (Bool, MatchInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, MatchInfo) -> m (Bool, MatchInfo))
-> IO (Bool, MatchInfo) -> m (Bool, MatchInfo)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CString
string' <- Text -> IO CString
textToCString Text
string
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    Ptr (Ptr MatchInfo)
matchInfo <- IO (Ptr (Ptr MatchInfo))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr GLib.MatchInfo.MatchInfo))
    CInt
result <- Ptr Regex -> CString -> CUInt -> Ptr (Ptr MatchInfo) -> IO CInt
g_regex_match_all Ptr Regex
regex' CString
string' CUInt
matchOptions' Ptr (Ptr MatchInfo)
matchInfo
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Ptr MatchInfo
matchInfo' <- Ptr (Ptr MatchInfo) -> IO (Ptr MatchInfo)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr MatchInfo)
matchInfo
    MatchInfo
matchInfo'' <- ((ManagedPtr MatchInfo -> MatchInfo)
-> Ptr MatchInfo -> IO MatchInfo
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MatchInfo -> MatchInfo
GLib.MatchInfo.MatchInfo) Ptr MatchInfo
matchInfo'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Ptr (Ptr MatchInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr MatchInfo)
matchInfo
    (Bool, MatchInfo) -> IO (Bool, MatchInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', MatchInfo
matchInfo'')

#if defined(ENABLE_OVERLOADING)
data RegexMatchAllMethodInfo
instance (signature ~ (T.Text -> [GLib.Flags.RegexMatchFlags] -> m ((Bool, GLib.MatchInfo.MatchInfo))), MonadIO m) => O.MethodInfo RegexMatchAllMethodInfo Regex signature where
    overloadedMethod = regexMatchAll

#endif

-- method Regex::match_all_full
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure from g_regex_new()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TCArray False (-1) 2 (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to scan for matches"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_len"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_position"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "starting index of the string to match, in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match options" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_info"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "MatchInfo" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "pointer to location where to store\n    the #GMatchInfo, or %NULL if you do not need it"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "string_len"
--              , argType = TBasicType TInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_match_all_full" g_regex_match_all_full :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    Ptr CString ->                          -- string : TCArray False (-1) 2 (TBasicType TUTF8)
    Int64 ->                                -- string_len : TBasicType TInt64
    Int32 ->                                -- start_position : TBasicType TInt
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GLib.MatchInfo.MatchInfo) ->   -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Using the standard algorithm for regular expression matching only
-- the longest match in the /@string@/ is retrieved, it is not possible
-- to obtain all the available matches. For instance matching
-- \"\<a> \<b> \<c>\" against the pattern \"\<.*>\"
-- you get \"\<a> \<b> \<c>\".
-- 
-- This function uses a different algorithm (called DFA, i.e. deterministic
-- finite automaton), so it can retrieve all the possible matches, all
-- starting at the same point in the string. For instance matching
-- \"\<a> \<b> \<c>\" against the pattern \"\<.*>;\"
-- you would obtain three matches: \"\<a> \<b> \<c>\",
-- \"\<a> \<b>\" and \"\<a>\".
-- 
-- The number of matched strings is retrieved using
-- 'GI.GLib.Structs.MatchInfo.matchInfoGetMatchCount'. To obtain the matched strings and
-- their position you can use, respectively, 'GI.GLib.Structs.MatchInfo.matchInfoFetch' and
-- 'GI.GLib.Structs.MatchInfo.matchInfoFetchPos'. Note that the strings are returned in
-- reverse order of length; that is, the longest matching string is
-- given first.
-- 
-- Note that the DFA algorithm is slower than the standard one and it
-- is not able to capture substrings, so backreferences do not work.
-- 
-- Setting /@startPosition@/ differs from just passing over a shortened
-- string and setting @/G_REGEX_MATCH_NOTBOL/@ in the case of a pattern
-- that begins with any kind of lookbehind assertion, such as \"\\b\".
-- 
-- Unless 'GI.GLib.Flags.RegexCompileFlagsRaw' is specified in the options, /@string@/ must be valid UTF-8.
-- 
-- A t'GI.GLib.Structs.MatchInfo.MatchInfo' structure, used to get information on the match, is
-- stored in /@matchInfo@/ if not 'P.Nothing'. Note that if /@matchInfo@/ is
-- not 'P.Nothing' then it is created even if the function returns 'P.False',
-- i.e. you must free it regardless if regular expression actually
-- matched.
-- 
-- /@string@/ is not copied and is used in t'GI.GLib.Structs.MatchInfo.MatchInfo' internally. If
-- you use any t'GI.GLib.Structs.MatchInfo.MatchInfo' method (except 'GI.GLib.Structs.MatchInfo.matchInfoFree') after
-- freeing or modifying /@string@/ then the behaviour is undefined.
-- 
-- /Since: 2.14/
regexMatchAllFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure from 'GI.GLib.Structs.Regex.regexNew'
    -> [T.Text]
    -- ^ /@string@/: the string to scan for matches
    -> Int32
    -- ^ /@startPosition@/: starting index of the string to match, in bytes
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options
    -> m (GLib.MatchInfo.MatchInfo)
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
regexMatchAllFull :: Regex -> [Text] -> Int32 -> [RegexMatchFlags] -> m MatchInfo
regexMatchAllFull Regex
regex [Text]
string Int32
startPosition [RegexMatchFlags]
matchOptions = 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
    let stringLen :: Int64
stringLen = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
string
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr CString
string' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
string
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    Ptr (Ptr MatchInfo)
matchInfo <- IO (Ptr (Ptr MatchInfo))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr GLib.MatchInfo.MatchInfo))
    IO MatchInfo -> IO () -> IO MatchInfo
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 Regex
-> Ptr CString
-> Int64
-> Int32
-> CUInt
-> Ptr (Ptr MatchInfo)
-> Ptr (Ptr GError)
-> IO CInt
g_regex_match_all_full Ptr Regex
regex' Ptr CString
string' Int64
stringLen Int32
startPosition CUInt
matchOptions' Ptr (Ptr MatchInfo)
matchInfo
        Ptr MatchInfo
matchInfo' <- Ptr (Ptr MatchInfo) -> IO (Ptr MatchInfo)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr MatchInfo)
matchInfo
        MatchInfo
matchInfo'' <- ((ManagedPtr MatchInfo -> MatchInfo)
-> Ptr MatchInfo -> IO MatchInfo
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MatchInfo -> MatchInfo
GLib.MatchInfo.MatchInfo) Ptr MatchInfo
matchInfo'
        Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr (Ptr MatchInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr MatchInfo)
matchInfo
        MatchInfo -> IO MatchInfo
forall (m :: * -> *) a. Monad m => a -> m a
return MatchInfo
matchInfo''
     ) (do
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr (Ptr MatchInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr MatchInfo)
matchInfo
     )

#if defined(ENABLE_OVERLOADING)
data RegexMatchAllFullMethodInfo
instance (signature ~ ([T.Text] -> Int32 -> [GLib.Flags.RegexMatchFlags] -> m (GLib.MatchInfo.MatchInfo)), MonadIO m) => O.MethodInfo RegexMatchAllFullMethodInfo Regex signature where
    overloadedMethod = regexMatchAllFull

#endif

-- method Regex::match_full
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure from g_regex_new()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TCArray False (-1) 2 (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to scan for matches"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_len"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_position"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "starting index of the string to match, in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match options" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_info"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "MatchInfo" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "pointer to location where to store\n    the #GMatchInfo, or %NULL if you do not need it"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "string_len"
--              , argType = TBasicType TInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_match_full" g_regex_match_full :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    Ptr CString ->                          -- string : TCArray False (-1) 2 (TBasicType TUTF8)
    Int64 ->                                -- string_len : TBasicType TInt64
    Int32 ->                                -- start_position : TBasicType TInt
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GLib.MatchInfo.MatchInfo) ->   -- match_info : TInterface (Name {namespace = "GLib", name = "MatchInfo"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Scans for a match in /@string@/ for the pattern in /@regex@/.
-- The /@matchOptions@/ are combined with the match options specified
-- when the /@regex@/ structure was created, letting you have more
-- flexibility in reusing t'GI.GLib.Structs.Regex.Regex' structures.
-- 
-- Setting /@startPosition@/ differs from just passing over a shortened
-- string and setting @/G_REGEX_MATCH_NOTBOL/@ in the case of a pattern
-- that begins with any kind of lookbehind assertion, such as \"\\b\".
-- 
-- Unless 'GI.GLib.Flags.RegexCompileFlagsRaw' is specified in the options, /@string@/ must be valid UTF-8.
-- 
-- A t'GI.GLib.Structs.MatchInfo.MatchInfo' structure, used to get information on the match, is
-- stored in /@matchInfo@/ if not 'P.Nothing'. Note that if /@matchInfo@/ is
-- not 'P.Nothing' then it is created even if the function returns 'P.False',
-- i.e. you must free it regardless if regular expression actually
-- matched.
-- 
-- /@string@/ is not copied and is used in t'GI.GLib.Structs.MatchInfo.MatchInfo' internally. If
-- you use any t'GI.GLib.Structs.MatchInfo.MatchInfo' method (except 'GI.GLib.Structs.MatchInfo.matchInfoFree') after
-- freeing or modifying /@string@/ then the behaviour is undefined.
-- 
-- To retrieve all the non-overlapping matches of the pattern in
-- string you can use 'GI.GLib.Structs.MatchInfo.matchInfoNext'.
-- 
-- 
-- === /C code/
-- >
-- >static void
-- >print_uppercase_words (const gchar *string)
-- >{
-- >  // Print all uppercase-only words.
-- >  GRegex *regex;
-- >  GMatchInfo *match_info;
-- >  GError *error = NULL;
-- >  
-- >  regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
-- >  g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
-- >  while (g_match_info_matches (match_info))
-- >    {
-- >      gchar *word = g_match_info_fetch (match_info, 0);
-- >      g_print ("Found: %s\n", word);
-- >      g_free (word);
-- >      g_match_info_next (match_info, &error);
-- >    }
-- >  g_match_info_free (match_info);
-- >  g_regex_unref (regex);
-- >  if (error != NULL)
-- >    {
-- >      g_printerr ("Error while matching: %s\n", error->message);
-- >      g_error_free (error);
-- >    }
-- >}
-- 
-- 
-- /Since: 2.14/
regexMatchFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure from 'GI.GLib.Structs.Regex.regexNew'
    -> [T.Text]
    -- ^ /@string@/: the string to scan for matches
    -> Int32
    -- ^ /@startPosition@/: starting index of the string to match, in bytes
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options
    -> m (GLib.MatchInfo.MatchInfo)
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
regexMatchFull :: Regex -> [Text] -> Int32 -> [RegexMatchFlags] -> m MatchInfo
regexMatchFull Regex
regex [Text]
string Int32
startPosition [RegexMatchFlags]
matchOptions = 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
    let stringLen :: Int64
stringLen = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
string
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr CString
string' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
string
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    Ptr (Ptr MatchInfo)
matchInfo <- IO (Ptr (Ptr MatchInfo))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr GLib.MatchInfo.MatchInfo))
    IO MatchInfo -> IO () -> IO MatchInfo
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 Regex
-> Ptr CString
-> Int64
-> Int32
-> CUInt
-> Ptr (Ptr MatchInfo)
-> Ptr (Ptr GError)
-> IO CInt
g_regex_match_full Ptr Regex
regex' Ptr CString
string' Int64
stringLen Int32
startPosition CUInt
matchOptions' Ptr (Ptr MatchInfo)
matchInfo
        Ptr MatchInfo
matchInfo' <- Ptr (Ptr MatchInfo) -> IO (Ptr MatchInfo)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr MatchInfo)
matchInfo
        MatchInfo
matchInfo'' <- ((ManagedPtr MatchInfo -> MatchInfo)
-> Ptr MatchInfo -> IO MatchInfo
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr MatchInfo -> MatchInfo
GLib.MatchInfo.MatchInfo) Ptr MatchInfo
matchInfo'
        Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr (Ptr MatchInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr MatchInfo)
matchInfo
        MatchInfo -> IO MatchInfo
forall (m :: * -> *) a. Monad m => a -> m a
return MatchInfo
matchInfo''
     ) (do
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr (Ptr MatchInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr MatchInfo)
matchInfo
     )

#if defined(ENABLE_OVERLOADING)
data RegexMatchFullMethodInfo
instance (signature ~ ([T.Text] -> Int32 -> [GLib.Flags.RegexMatchFlags] -> m (GLib.MatchInfo.MatchInfo)), MonadIO m) => O.MethodInfo RegexMatchFullMethodInfo Regex signature where
    overloadedMethod = regexMatchFull

#endif

-- method Regex::ref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex" , 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_regex_ref" g_regex_ref :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO (Ptr Regex)

-- | Increases reference count of /@regex@/ by 1.
-- 
-- /Since: 2.14/
regexRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex'
    -> m Regex
    -- ^ __Returns:__ /@regex@/
regexRef :: Regex -> m Regex
regexRef Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr Regex
result <- Ptr Regex -> IO (Ptr Regex)
g_regex_ref Ptr Regex
regex'
    Text -> Ptr Regex -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexRef" Ptr Regex
result
    Regex
result' <- ((ManagedPtr Regex -> Regex) -> Ptr Regex -> IO Regex
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Regex -> Regex
Regex) Ptr Regex
result
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    Regex -> IO Regex
forall (m :: * -> *) a. Monad m => a -> m a
return Regex
result'

#if defined(ENABLE_OVERLOADING)
data RegexRefMethodInfo
instance (signature ~ (m Regex), MonadIO m) => O.MethodInfo RegexRefMethodInfo Regex signature where
    overloadedMethod = regexRef

#endif

-- method Regex::replace
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TCArray False (-1) 2 (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to perform matches against"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_len"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_position"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "starting index of the string to match, in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "replacement"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "text to replace each match with"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "options for the match"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "string_len"
--              , argType = TBasicType TInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_replace" g_regex_replace :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    Ptr CString ->                          -- string : TCArray False (-1) 2 (TBasicType TUTF8)
    Int64 ->                                -- string_len : TBasicType TInt64
    Int32 ->                                -- start_position : TBasicType TInt
    CString ->                              -- replacement : TBasicType TUTF8
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Replaces all occurrences of the pattern in /@regex@/ with the
-- replacement text. Backreferences of the form \'\\number\' or
-- \'\\g\<number>\' in the replacement text are interpolated by the
-- number-th captured subexpression of the match, \'\\g\<name>\' refers
-- to the captured subexpression with the given name. \'\\0\' refers
-- to the complete match, but \'\\0\' followed by a number is the octal
-- representation of a character. To include a literal \'\\\' in the
-- replacement, write \'\\\\\'.
-- 
-- There are also escapes that changes the case of the following text:
-- 
-- * \\l: Convert to lower case the next character
-- * \\u: Convert to upper case the next character
-- * \\L: Convert to lower case till \\E
-- * \\U: Convert to upper case till \\E
-- * \\E: End case modification
-- 
-- 
-- If you do not need to use backreferences use 'GI.GLib.Structs.Regex.regexReplaceLiteral'.
-- 
-- The /@replacement@/ string must be UTF-8 encoded even if @/G_REGEX_RAW/@ was
-- passed to 'GI.GLib.Structs.Regex.regexNew'. If you want to use not UTF-8 encoded stings
-- you can use 'GI.GLib.Structs.Regex.regexReplaceLiteral'.
-- 
-- Setting /@startPosition@/ differs from just passing over a shortened
-- string and setting @/G_REGEX_MATCH_NOTBOL/@ in the case of a pattern that
-- begins with any kind of lookbehind assertion, such as \"\\b\".
-- 
-- /Since: 2.14/
regexReplace ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> [T.Text]
    -- ^ /@string@/: the string to perform matches against
    -> Int32
    -- ^ /@startPosition@/: starting index of the string to match, in bytes
    -> T.Text
    -- ^ /@replacement@/: text to replace each match with
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: options for the match
    -> m T.Text
    -- ^ __Returns:__ a newly allocated string containing the replacements /(Can throw 'Data.GI.Base.GError.GError')/
regexReplace :: Regex -> [Text] -> Int32 -> Text -> [RegexMatchFlags] -> m Text
regexReplace Regex
regex [Text]
string Int32
startPosition Text
replacement [RegexMatchFlags]
matchOptions = 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
    let stringLen :: Int64
stringLen = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
string
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr CString
string' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
string
    CString
replacement' <- Text -> IO CString
textToCString Text
replacement
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    IO Text -> IO () -> IO 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 Regex
-> Ptr CString
-> Int64
-> Int32
-> CString
-> CUInt
-> Ptr (Ptr GError)
-> IO CString
g_regex_replace Ptr Regex
regex' Ptr CString
string' Int64
stringLen Int32
startPosition CString
replacement' CUInt
matchOptions'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexReplace" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
     )

#if defined(ENABLE_OVERLOADING)
data RegexReplaceMethodInfo
instance (signature ~ ([T.Text] -> Int32 -> T.Text -> [GLib.Flags.RegexMatchFlags] -> m T.Text), MonadIO m) => O.MethodInfo RegexReplaceMethodInfo Regex signature where
    overloadedMethod = regexReplace

#endif

-- method Regex::replace_literal
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TCArray False (-1) 2 (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to perform matches against"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_len"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_position"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "starting index of the string to match, in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "replacement"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "text to replace each match with"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "options for the match"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "string_len"
--              , argType = TBasicType TInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_replace_literal" g_regex_replace_literal :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    Ptr CString ->                          -- string : TCArray False (-1) 2 (TBasicType TUTF8)
    Int64 ->                                -- string_len : TBasicType TInt64
    Int32 ->                                -- start_position : TBasicType TInt
    CString ->                              -- replacement : TBasicType TUTF8
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Replaces all occurrences of the pattern in /@regex@/ with the
-- replacement text. /@replacement@/ is replaced literally, to
-- include backreferences use 'GI.GLib.Structs.Regex.regexReplace'.
-- 
-- Setting /@startPosition@/ differs from just passing over a
-- shortened string and setting @/G_REGEX_MATCH_NOTBOL/@ in the
-- case of a pattern that begins with any kind of lookbehind
-- assertion, such as \"\\b\".
-- 
-- /Since: 2.14/
regexReplaceLiteral ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> [T.Text]
    -- ^ /@string@/: the string to perform matches against
    -> Int32
    -- ^ /@startPosition@/: starting index of the string to match, in bytes
    -> T.Text
    -- ^ /@replacement@/: text to replace each match with
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: options for the match
    -> m T.Text
    -- ^ __Returns:__ a newly allocated string containing the replacements /(Can throw 'Data.GI.Base.GError.GError')/
regexReplaceLiteral :: Regex -> [Text] -> Int32 -> Text -> [RegexMatchFlags] -> m Text
regexReplaceLiteral Regex
regex [Text]
string Int32
startPosition Text
replacement [RegexMatchFlags]
matchOptions = 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
    let stringLen :: Int64
stringLen = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
string
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr CString
string' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
string
    CString
replacement' <- Text -> IO CString
textToCString Text
replacement
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    IO Text -> IO () -> IO 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 Regex
-> Ptr CString
-> Int64
-> Int32
-> CString
-> CUInt
-> Ptr (Ptr GError)
-> IO CString
g_regex_replace_literal Ptr Regex
regex' Ptr CString
string' Int64
stringLen Int32
startPosition CString
replacement' CUInt
matchOptions'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexReplaceLiteral" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
     )

#if defined(ENABLE_OVERLOADING)
data RegexReplaceLiteralMethodInfo
instance (signature ~ ([T.Text] -> Int32 -> T.Text -> [GLib.Flags.RegexMatchFlags] -> m T.Text), MonadIO m) => O.MethodInfo RegexReplaceLiteralMethodInfo Regex signature where
    overloadedMethod = regexReplaceLiteral

#endif

-- method Regex::split
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure"
--                 , 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 = Just "the string to split with the pattern"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match time option flags"
--                 , 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_regex_split" g_regex_split :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    CString ->                              -- string : TBasicType TUTF8
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    IO (Ptr CString)

-- | Breaks the string on the pattern, and returns an array of the tokens.
-- If the pattern contains capturing parentheses, then the text for each
-- of the substrings will also be returned. If the pattern does not match
-- anywhere in the string, then the whole string is returned as the first
-- token.
-- 
-- As a special case, the result of splitting the empty string \"\" is an
-- empty vector, not a vector containing a single string. The reason for
-- this special case is that being able to represent an empty vector is
-- typically more useful than consistent handling of empty elements. If
-- you do need to represent empty elements, you\'ll need to check for the
-- empty string before calling this function.
-- 
-- A pattern that can match empty strings splits /@string@/ into separate
-- characters wherever it matches the empty string between characters.
-- For example splitting \"ab c\" using as a separator \"\\s*\", you will get
-- \"a\", \"b\" and \"c\".
-- 
-- /Since: 2.14/
regexSplit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> T.Text
    -- ^ /@string@/: the string to split with the pattern
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match time option flags
    -> m [T.Text]
    -- ^ __Returns:__ a 'P.Nothing'-terminated gchar ** array. Free
    -- it using 'GI.GLib.Functions.strfreev'
regexSplit :: Regex -> Text -> [RegexMatchFlags] -> m [Text]
regexSplit Regex
regex Text
string [RegexMatchFlags]
matchOptions = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    CString
string' <- Text -> IO CString
textToCString Text
string
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    Ptr CString
result <- Ptr Regex -> CString -> CUInt -> IO (Ptr CString)
g_regex_split Ptr Regex
regex' CString
string' CUInt
matchOptions'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexSplit" 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
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if defined(ENABLE_OVERLOADING)
data RegexSplitMethodInfo
instance (signature ~ (T.Text -> [GLib.Flags.RegexMatchFlags] -> m [T.Text]), MonadIO m) => O.MethodInfo RegexSplitMethodInfo Regex signature where
    overloadedMethod = regexSplit

#endif

-- method Regex::split_full
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "regex"
--           , argType = TInterface Name { namespace = "GLib" , name = "Regex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GRegex structure"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string"
--           , argType = TCArray False (-1) 2 (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to split with the pattern"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "string_len"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "start_position"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "starting index of the string to match, in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match time option flags"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_tokens"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the maximum number of tokens to split @string into.\n  If this is less than 1, the string is split completely"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "string_len"
--              , argType = TBasicType TInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_split_full" g_regex_split_full :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    Ptr CString ->                          -- string : TCArray False (-1) 2 (TBasicType TUTF8)
    Int64 ->                                -- string_len : TBasicType TInt64
    Int32 ->                                -- start_position : TBasicType TInt
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    Int32 ->                                -- max_tokens : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr CString)

-- | Breaks the string on the pattern, and returns an array of the tokens.
-- If the pattern contains capturing parentheses, then the text for each
-- of the substrings will also be returned. If the pattern does not match
-- anywhere in the string, then the whole string is returned as the first
-- token.
-- 
-- As a special case, the result of splitting the empty string \"\" is an
-- empty vector, not a vector containing a single string. The reason for
-- this special case is that being able to represent an empty vector is
-- typically more useful than consistent handling of empty elements. If
-- you do need to represent empty elements, you\'ll need to check for the
-- empty string before calling this function.
-- 
-- A pattern that can match empty strings splits /@string@/ into separate
-- characters wherever it matches the empty string between characters.
-- For example splitting \"ab c\" using as a separator \"\\s*\", you will get
-- \"a\", \"b\" and \"c\".
-- 
-- Setting /@startPosition@/ differs from just passing over a shortened
-- string and setting @/G_REGEX_MATCH_NOTBOL/@ in the case of a pattern
-- that begins with any kind of lookbehind assertion, such as \"\\b\".
-- 
-- /Since: 2.14/
regexSplitFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex' structure
    -> [T.Text]
    -- ^ /@string@/: the string to split with the pattern
    -> Int32
    -- ^ /@startPosition@/: starting index of the string to match, in bytes
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match time option flags
    -> Int32
    -- ^ /@maxTokens@/: the maximum number of tokens to split /@string@/ into.
    --   If this is less than 1, the string is split completely
    -> m [T.Text]
    -- ^ __Returns:__ a 'P.Nothing'-terminated gchar ** array. Free
    -- it using 'GI.GLib.Functions.strfreev' /(Can throw 'Data.GI.Base.GError.GError')/
regexSplitFull :: Regex -> [Text] -> Int32 -> [RegexMatchFlags] -> Int32 -> m [Text]
regexSplitFull Regex
regex [Text]
string Int32
startPosition [RegexMatchFlags]
matchOptions Int32
maxTokens = 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
    let stringLen :: Int64
stringLen = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
string
    Ptr Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr CString
string' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
string
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    IO [Text] -> IO () -> IO [Text]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr CString
result <- (Ptr (Ptr GError) -> IO (Ptr CString)) -> IO (Ptr CString)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr CString)) -> IO (Ptr CString))
-> (Ptr (Ptr GError) -> IO (Ptr CString)) -> IO (Ptr CString)
forall a b. (a -> b) -> a -> b
$ Ptr Regex
-> Ptr CString
-> Int64
-> Int32
-> CUInt
-> Int32
-> Ptr (Ptr GError)
-> IO (Ptr CString)
g_regex_split_full Ptr Regex
regex' Ptr CString
string' Int64
stringLen Int32
startPosition CUInt
matchOptions' Int32
maxTokens
        Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexSplitFull" 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
        Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'
     ) (do
        (Int64 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int64
stringLen) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
     )

#if defined(ENABLE_OVERLOADING)
data RegexSplitFullMethodInfo
instance (signature ~ ([T.Text] -> Int32 -> [GLib.Flags.RegexMatchFlags] -> Int32 -> m [T.Text]), MonadIO m) => O.MethodInfo RegexSplitFullMethodInfo Regex signature where
    overloadedMethod = regexSplitFull

#endif

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

foreign import ccall "g_regex_unref" g_regex_unref :: 
    Ptr Regex ->                            -- regex : TInterface (Name {namespace = "GLib", name = "Regex"})
    IO ()

-- | Decreases reference count of /@regex@/ by 1. When reference count drops
-- to zero, it frees all the memory associated with the regex structure.
-- 
-- /Since: 2.14/
regexUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Regex
    -- ^ /@regex@/: a t'GI.GLib.Structs.Regex.Regex'
    -> m ()
regexUnref :: Regex -> m ()
regexUnref Regex
regex = 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 Regex
regex' <- Regex -> IO (Ptr Regex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Regex
regex
    Ptr Regex -> IO ()
g_regex_unref Ptr Regex
regex'
    Regex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Regex
regex
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data RegexUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RegexUnrefMethodInfo Regex signature where
    overloadedMethod = regexUnref

#endif

-- method Regex::check_replacement
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "replacement"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replacement string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "has_references"
--           , argType = TBasicType TBoolean
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store information about\n  references in @replacement or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_regex_check_replacement" g_regex_check_replacement :: 
    CString ->                              -- replacement : TBasicType TUTF8
    Ptr CInt ->                             -- has_references : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Checks whether /@replacement@/ is a valid replacement string
-- (see 'GI.GLib.Structs.Regex.regexReplace'), i.e. that all escape sequences in
-- it are valid.
-- 
-- If /@hasReferences@/ is not 'P.Nothing' then /@replacement@/ is checked
-- for pattern references. For instance, replacement text \'foo\\n\'
-- does not contain references and may be evaluated without information
-- about actual match, but \'\\0\\1\' (whole match followed by first
-- subpattern) requires valid t'GI.GLib.Structs.MatchInfo.MatchInfo' object.
-- 
-- /Since: 2.14/
regexCheckReplacement ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@replacement@/: the replacement string
    -> m (Bool)
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
regexCheckReplacement :: Text -> m Bool
regexCheckReplacement Text
replacement = 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
    CString
replacement' <- Text -> IO CString
textToCString Text
replacement
    Ptr CInt
hasReferences <- IO (Ptr CInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CInt)
    IO Bool -> IO () -> IO Bool
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
$ CString -> Ptr CInt -> Ptr (Ptr GError) -> IO CInt
g_regex_check_replacement CString
replacement' Ptr CInt
hasReferences
        CInt
hasReferences' <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
hasReferences
        let hasReferences'' :: Bool
hasReferences'' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
hasReferences'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
        Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
hasReferences
        Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
hasReferences''
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
replacement'
        Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
hasReferences
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- method Regex::error_quark
-- method type : MemberFunction
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_regex_error_quark" g_regex_error_quark :: 
    IO Word32

-- | /No description available in the introspection data./
regexErrorQuark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
regexErrorQuark :: m Word32
regexErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_regex_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(ENABLE_OVERLOADING)
#endif

-- method Regex::escape_nul
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "string"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to escape"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the length of @string"
--                 , 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_regex_escape_nul" g_regex_escape_nul :: 
    CString ->                              -- string : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    IO CString

-- | Escapes the nul characters in /@string@/ to \"\\x00\".  It can be used
-- to compile a regex with embedded nul characters.
-- 
-- For completeness, /@length@/ can be -1 for a nul-terminated string.
-- In this case the output string will be of course equal to /@string@/.
-- 
-- /Since: 2.30/
regexEscapeNul ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@string@/: the string to escape
    -> Int32
    -- ^ /@length@/: the length of /@string@/
    -> m T.Text
    -- ^ __Returns:__ a newly-allocated escaped string
regexEscapeNul :: Text -> Int32 -> m Text
regexEscapeNul Text
string Int32
length_ = 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
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
result <- CString -> Int32 -> IO CString
g_regex_escape_nul CString
string' Int32
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexEscapeNul" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Regex::escape_string
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "string"
--           , argType = TCArray False (-1) 1 (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string to escape"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "length"
--              , argType = TBasicType TInt
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @string, in bytes, or -1 if @string is nul-terminated"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_regex_escape_string" g_regex_escape_string :: 
    Ptr CString ->                          -- string : TCArray False (-1) 1 (TBasicType TUTF8)
    Int32 ->                                -- length : TBasicType TInt
    IO CString

-- | Escapes the special characters used for regular expressions
-- in /@string@/, for instance \"a.b*c\" becomes \"a\\.b\\*c\". This
-- function is useful to dynamically generate regular expressions.
-- 
-- /@string@/ can contain nul characters that are replaced with \"\\0\",
-- in this case remember to specify the correct length of /@string@/
-- in /@length@/.
-- 
-- /Since: 2.14/
regexEscapeString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [T.Text]
    -- ^ /@string@/: the string to escape
    -> m T.Text
    -- ^ __Returns:__ a newly-allocated escaped string
regexEscapeString :: [Text] -> m Text
regexEscapeString [Text]
string = 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
    let length_ :: Int32
length_ = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> Int -> Int32
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
string
    Ptr CString
string' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
string
    CString
result <- Ptr CString -> Int32 -> IO CString
g_regex_escape_string Ptr CString
string' Int32
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexEscapeString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    (Int32 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int32
length_) CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Regex::match_simple
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "pattern"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the regular expression"
--                 , 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 = Just "the string to scan for matches"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "compile_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexCompileFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "compile options for the regular expression, or 0"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match options, or 0"
--                 , 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_regex_match_simple" g_regex_match_simple :: 
    CString ->                              -- pattern : TBasicType TUTF8
    CString ->                              -- string : TBasicType TUTF8
    CUInt ->                                -- compile_options : TInterface (Name {namespace = "GLib", name = "RegexCompileFlags"})
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    IO CInt

-- | Scans for a match in /@string@/ for /@pattern@/.
-- 
-- This function is equivalent to 'GI.GLib.Structs.Regex.regexMatch' but it does not
-- require to compile the pattern with 'GI.GLib.Structs.Regex.regexNew', avoiding some
-- lines of code when you need just to do a match without extracting
-- substrings, capture counts, and so on.
-- 
-- If this function is to be called on the same /@pattern@/ more than
-- once, it\'s more efficient to compile the pattern once with
-- 'GI.GLib.Structs.Regex.regexNew' and then use 'GI.GLib.Structs.Regex.regexMatch'.
-- 
-- /Since: 2.14/
regexMatchSimple ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@pattern@/: the regular expression
    -> T.Text
    -- ^ /@string@/: the string to scan for matches
    -> [GLib.Flags.RegexCompileFlags]
    -- ^ /@compileOptions@/: compile options for the regular expression, or 0
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options, or 0
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the string matched, 'P.False' otherwise
regexMatchSimple :: Text -> Text -> [RegexCompileFlags] -> [RegexMatchFlags] -> m Bool
regexMatchSimple Text
pattern Text
string [RegexCompileFlags]
compileOptions [RegexMatchFlags]
matchOptions = 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
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    CString
string' <- Text -> IO CString
textToCString Text
string
    let compileOptions' :: CUInt
compileOptions' = [RegexCompileFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexCompileFlags]
compileOptions
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    CInt
result <- CString -> CString -> CUInt -> CUInt -> IO CInt
g_regex_match_simple CString
pattern' CString
string' CUInt
compileOptions' CUInt
matchOptions'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
    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)
#endif

-- method Regex::split_simple
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "pattern"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the regular expression"
--                 , 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 = Just "the string to scan for matches"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "compile_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexCompileFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "compile options for the regular expression, or 0"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_options"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RegexMatchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "match options, or 0"
--                 , 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_regex_split_simple" g_regex_split_simple :: 
    CString ->                              -- pattern : TBasicType TUTF8
    CString ->                              -- string : TBasicType TUTF8
    CUInt ->                                -- compile_options : TInterface (Name {namespace = "GLib", name = "RegexCompileFlags"})
    CUInt ->                                -- match_options : TInterface (Name {namespace = "GLib", name = "RegexMatchFlags"})
    IO (Ptr CString)

-- | Breaks the string on the pattern, and returns an array of
-- the tokens. If the pattern contains capturing parentheses,
-- then the text for each of the substrings will also be returned.
-- If the pattern does not match anywhere in the string, then the
-- whole string is returned as the first token.
-- 
-- This function is equivalent to 'GI.GLib.Structs.Regex.regexSplit' but it does
-- not require to compile the pattern with 'GI.GLib.Structs.Regex.regexNew', avoiding
-- some lines of code when you need just to do a split without
-- extracting substrings, capture counts, and so on.
-- 
-- If this function is to be called on the same /@pattern@/ more than
-- once, it\'s more efficient to compile the pattern once with
-- 'GI.GLib.Structs.Regex.regexNew' and then use 'GI.GLib.Structs.Regex.regexSplit'.
-- 
-- As a special case, the result of splitting the empty string \"\"
-- is an empty vector, not a vector containing a single string.
-- The reason for this special case is that being able to represent
-- an empty vector is typically more useful than consistent handling
-- of empty elements. If you do need to represent empty elements,
-- you\'ll need to check for the empty string before calling this
-- function.
-- 
-- A pattern that can match empty strings splits /@string@/ into
-- separate characters wherever it matches the empty string between
-- characters. For example splitting \"ab c\" using as a separator
-- \"\\s*\", you will get \"a\", \"b\" and \"c\".
-- 
-- /Since: 2.14/
regexSplitSimple ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@pattern@/: the regular expression
    -> T.Text
    -- ^ /@string@/: the string to scan for matches
    -> [GLib.Flags.RegexCompileFlags]
    -- ^ /@compileOptions@/: compile options for the regular expression, or 0
    -> [GLib.Flags.RegexMatchFlags]
    -- ^ /@matchOptions@/: match options, or 0
    -> m [T.Text]
    -- ^ __Returns:__ a 'P.Nothing'-terminated array of strings. Free
    -- it using 'GI.GLib.Functions.strfreev'
regexSplitSimple :: Text
-> Text -> [RegexCompileFlags] -> [RegexMatchFlags] -> m [Text]
regexSplitSimple Text
pattern Text
string [RegexCompileFlags]
compileOptions [RegexMatchFlags]
matchOptions = 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
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    CString
string' <- Text -> IO CString
textToCString Text
string
    let compileOptions' :: CUInt
compileOptions' = [RegexCompileFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexCompileFlags]
compileOptions
    let matchOptions' :: CUInt
matchOptions' = [RegexMatchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [RegexMatchFlags]
matchOptions
    Ptr CString
result <- CString -> CString -> CUInt -> CUInt -> IO (Ptr CString)
g_regex_split_simple CString
pattern' CString
string' CUInt
compileOptions' CUInt
matchOptions'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"regexSplitSimple" 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
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveRegexMethod (t :: Symbol) (o :: *) :: * where
    ResolveRegexMethod "match" o = RegexMatchMethodInfo
    ResolveRegexMethod "matchAll" o = RegexMatchAllMethodInfo
    ResolveRegexMethod "matchAllFull" o = RegexMatchAllFullMethodInfo
    ResolveRegexMethod "matchFull" o = RegexMatchFullMethodInfo
    ResolveRegexMethod "ref" o = RegexRefMethodInfo
    ResolveRegexMethod "replace" o = RegexReplaceMethodInfo
    ResolveRegexMethod "replaceLiteral" o = RegexReplaceLiteralMethodInfo
    ResolveRegexMethod "split" o = RegexSplitMethodInfo
    ResolveRegexMethod "splitFull" o = RegexSplitFullMethodInfo
    ResolveRegexMethod "unref" o = RegexUnrefMethodInfo
    ResolveRegexMethod "getCaptureCount" o = RegexGetCaptureCountMethodInfo
    ResolveRegexMethod "getCompileFlags" o = RegexGetCompileFlagsMethodInfo
    ResolveRegexMethod "getHasCrOrLf" o = RegexGetHasCrOrLfMethodInfo
    ResolveRegexMethod "getMatchFlags" o = RegexGetMatchFlagsMethodInfo
    ResolveRegexMethod "getMaxBackref" o = RegexGetMaxBackrefMethodInfo
    ResolveRegexMethod "getMaxLookbehind" o = RegexGetMaxLookbehindMethodInfo
    ResolveRegexMethod "getPattern" o = RegexGetPatternMethodInfo
    ResolveRegexMethod "getStringNumber" o = RegexGetStringNumberMethodInfo
    ResolveRegexMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRegexMethod t Regex, O.MethodInfo info Regex p) => OL.IsLabel t (Regex -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif