{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) The g_regex_*() functions implement regular expression pattern matching using syntax and semantics similar to Perl regular expression. Some functions accept a @start_position 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 @start_position 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 %G_REGEX_JAVASCRIPT_COMPAT 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 #GRegex structure from different threads is not a problem as #GRegex does not modify its internal state between creation and destruction, on the other hand #GMatchInfo is not threadsafe. The regular expressions low-level functionalities are obtained through the excellent [PCRE](http://www.pcre.org/) library written by Philip Hazel. -} module GI.GLib.Structs.Regex ( -- * Exported types Regex(..) , noRegex , -- * Methods -- ** regexGetCaptureCount regexGetCaptureCount , -- ** regexGetCompileFlags regexGetCompileFlags , -- ** regexGetHasCrOrLf regexGetHasCrOrLf , -- ** regexGetMatchFlags regexGetMatchFlags , -- ** regexGetMaxBackref regexGetMaxBackref , -- ** regexGetMaxLookbehind regexGetMaxLookbehind , -- ** regexGetPattern regexGetPattern , -- ** regexGetStringNumber regexGetStringNumber , -- ** regexMatch regexMatch , -- ** regexMatchAll regexMatchAll , -- ** regexMatchAllFull regexMatchAllFull , -- ** regexMatchFull regexMatchFull , -- ** regexNew regexNew , -- ** regexRef regexRef , -- ** regexReplace regexReplace , -- ** regexReplaceLiteral regexReplaceLiteral , -- ** regexSplit regexSplit , -- ** regexSplitFull regexSplitFull , -- ** regexUnref regexUnref , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.GLib.Types import GI.GLib.Callbacks newtype Regex = Regex (ForeignPtr Regex) foreign import ccall "g_regex_get_type" c_g_regex_get_type :: IO GType instance BoxedObject Regex where boxedType _ = c_g_regex_get_type noRegex :: Maybe Regex noRegex = Nothing -- method Regex::new -- method type : Constructor -- Args : [Arg {argName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "compile_options", argType = TInterface "GLib" "RegexCompileFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "compile_options", argType = TInterface "GLib" "RegexCompileFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "GLib" "Regex" -- throws : True -- Skip return : False foreign import ccall "g_regex_new" g_regex_new :: CString -> -- pattern : TBasicType TUTF8 CUInt -> -- compile_options : TInterface "GLib" "RegexCompileFlags" CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr GError) -> -- error IO (Ptr Regex) regexNew :: (MonadIO m) => T.Text -> -- pattern [RegexCompileFlags] -> -- compile_options [RegexMatchFlags] -> -- match_options m Regex regexNew pattern compile_options match_options = liftIO $ do pattern' <- textToCString pattern let compile_options' = gflagsToWord compile_options let match_options' = gflagsToWord match_options onException (do result <- propagateGError $ g_regex_new pattern' compile_options' match_options' checkUnexpectedReturnNULL "g_regex_new" result result' <- (wrapBoxed Regex) result freeMem pattern' return result' ) (do freeMem pattern' ) -- method Regex::get_capture_count -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TInt32 -- throws : False -- Skip return : False foreign import ccall "g_regex_get_capture_count" g_regex_get_capture_count :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO Int32 regexGetCaptureCount :: (MonadIO m) => Regex -> -- _obj m Int32 regexGetCaptureCount _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_capture_count _obj' touchManagedPtr _obj return result -- method Regex::get_compile_flags -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "GLib" "RegexCompileFlags" -- throws : False -- Skip return : False foreign import ccall "g_regex_get_compile_flags" g_regex_get_compile_flags :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO CUInt regexGetCompileFlags :: (MonadIO m) => Regex -> -- _obj m [RegexCompileFlags] regexGetCompileFlags _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_compile_flags _obj' let result' = wordToGFlags result touchManagedPtr _obj return result' -- method Regex::get_has_cr_or_lf -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : 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 -> -- _obj : TInterface "GLib" "Regex" IO CInt regexGetHasCrOrLf :: (MonadIO m) => Regex -> -- _obj m Bool regexGetHasCrOrLf _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_has_cr_or_lf _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method Regex::get_match_flags -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "GLib" "RegexMatchFlags" -- throws : False -- Skip return : False foreign import ccall "g_regex_get_match_flags" g_regex_get_match_flags :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO CUInt regexGetMatchFlags :: (MonadIO m) => Regex -> -- _obj m [RegexMatchFlags] regexGetMatchFlags _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_match_flags _obj' let result' = wordToGFlags result touchManagedPtr _obj return result' -- method Regex::get_max_backref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TInt32 -- throws : False -- Skip return : False foreign import ccall "g_regex_get_max_backref" g_regex_get_max_backref :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO Int32 regexGetMaxBackref :: (MonadIO m) => Regex -> -- _obj m Int32 regexGetMaxBackref _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_max_backref _obj' touchManagedPtr _obj return result -- method Regex::get_max_lookbehind -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TInt32 -- throws : False -- Skip return : False foreign import ccall "g_regex_get_max_lookbehind" g_regex_get_max_lookbehind :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO Int32 regexGetMaxLookbehind :: (MonadIO m) => Regex -> -- _obj m Int32 regexGetMaxLookbehind _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_max_lookbehind _obj' touchManagedPtr _obj return result -- method Regex::get_pattern -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "g_regex_get_pattern" g_regex_get_pattern :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO CString regexGetPattern :: (MonadIO m) => Regex -> -- _obj m T.Text regexGetPattern _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_get_pattern _obj' checkUnexpectedReturnNULL "g_regex_get_pattern" result result' <- cstringToText result touchManagedPtr _obj return result' -- method Regex::get_string_number -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TInt32 -- throws : False -- Skip return : False foreign import ccall "g_regex_get_string_number" g_regex_get_string_number :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" CString -> -- name : TBasicType TUTF8 IO Int32 regexGetStringNumber :: (MonadIO m) => Regex -> -- _obj T.Text -> -- name m Int32 regexGetStringNumber _obj name = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj name' <- textToCString name result <- g_regex_get_string_number _obj' name' touchManagedPtr _obj freeMem name' return result -- method Regex::match -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_info", argType = TInterface "GLib" "MatchInfo", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_regex_match" g_regex_match :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" CString -> -- string : TBasicType TUTF8 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr MatchInfo) -> -- match_info : TInterface "GLib" "MatchInfo" IO CInt regexMatch :: (MonadIO m) => Regex -> -- _obj T.Text -> -- string [RegexMatchFlags] -> -- match_options m (Bool,MatchInfo) regexMatch _obj string match_options = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj string' <- textToCString string let match_options' = gflagsToWord match_options match_info <- allocMem :: IO (Ptr (Ptr MatchInfo)) result <- g_regex_match _obj' string' match_options' match_info let result' = (/= 0) result match_info' <- peek match_info match_info'' <- (wrapBoxed MatchInfo) match_info' touchManagedPtr _obj freeMem string' freeMem match_info return (result', match_info'') -- method Regex::match_all -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_info", argType = TInterface "GLib" "MatchInfo", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_regex_match_all" g_regex_match_all :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" CString -> -- string : TBasicType TUTF8 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr MatchInfo) -> -- match_info : TInterface "GLib" "MatchInfo" IO CInt regexMatchAll :: (MonadIO m) => Regex -> -- _obj T.Text -> -- string [RegexMatchFlags] -> -- match_options m (Bool,MatchInfo) regexMatchAll _obj string match_options = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj string' <- textToCString string let match_options' = gflagsToWord match_options match_info <- allocMem :: IO (Ptr (Ptr MatchInfo)) result <- g_regex_match_all _obj' string' match_options' match_info let result' = (/= 0) result match_info' <- peek match_info match_info'' <- (wrapBoxed MatchInfo) match_info' touchManagedPtr _obj freeMem string' freeMem match_info return (result', match_info'') -- method Regex::match_all_full -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_info", argType = TInterface "GLib" "MatchInfo", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "g_regex_match_all_full" g_regex_match_all_full :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" Ptr CString -> -- string : TCArray False (-1) 2 (TBasicType TUTF8) Int64 -> -- string_len : TBasicType TInt64 Int32 -> -- start_position : TBasicType TInt32 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr MatchInfo) -> -- match_info : TInterface "GLib" "MatchInfo" Ptr (Ptr GError) -> -- error IO CInt regexMatchAllFull :: (MonadIO m) => Regex -> -- _obj [T.Text] -> -- string Int32 -> -- start_position [RegexMatchFlags] -> -- match_options m (MatchInfo) regexMatchAllFull _obj string start_position match_options = liftIO $ do let string_len = fromIntegral $ length string let _obj' = unsafeManagedPtrGetPtr _obj string' <- packUTF8CArray string let match_options' = gflagsToWord match_options match_info <- allocMem :: IO (Ptr (Ptr MatchInfo)) onException (do _ <- propagateGError $ g_regex_match_all_full _obj' string' string_len start_position match_options' match_info match_info' <- peek match_info match_info'' <- (wrapBoxed MatchInfo) match_info' touchManagedPtr _obj (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem match_info return match_info'' ) (do (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem match_info ) -- method Regex::match_full -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_info", argType = TInterface "GLib" "MatchInfo", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "g_regex_match_full" g_regex_match_full :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" Ptr CString -> -- string : TCArray False (-1) 2 (TBasicType TUTF8) Int64 -> -- string_len : TBasicType TInt64 Int32 -> -- start_position : TBasicType TInt32 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr MatchInfo) -> -- match_info : TInterface "GLib" "MatchInfo" Ptr (Ptr GError) -> -- error IO CInt regexMatchFull :: (MonadIO m) => Regex -> -- _obj [T.Text] -> -- string Int32 -> -- start_position [RegexMatchFlags] -> -- match_options m (MatchInfo) regexMatchFull _obj string start_position match_options = liftIO $ do let string_len = fromIntegral $ length string let _obj' = unsafeManagedPtrGetPtr _obj string' <- packUTF8CArray string let match_options' = gflagsToWord match_options match_info <- allocMem :: IO (Ptr (Ptr MatchInfo)) onException (do _ <- propagateGError $ g_regex_match_full _obj' string' string_len start_position match_options' match_info match_info' <- peek match_info match_info'' <- (wrapBoxed MatchInfo) match_info' touchManagedPtr _obj (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem match_info return match_info'' ) (do (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem match_info ) -- method Regex::ref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "GLib" "Regex" -- throws : False -- Skip return : False foreign import ccall "g_regex_ref" g_regex_ref :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO (Ptr Regex) regexRef :: (MonadIO m) => Regex -> -- _obj m Regex regexRef _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_regex_ref _obj' checkUnexpectedReturnNULL "g_regex_ref" result result' <- (wrapBoxed Regex) result touchManagedPtr _obj return result' -- method Regex::replace -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "replacement", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "replacement", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : True -- Skip return : False foreign import ccall "g_regex_replace" g_regex_replace :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" Ptr CString -> -- string : TCArray False (-1) 2 (TBasicType TUTF8) Int64 -> -- string_len : TBasicType TInt64 Int32 -> -- start_position : TBasicType TInt32 CString -> -- replacement : TBasicType TUTF8 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr GError) -> -- error IO CString regexReplace :: (MonadIO m) => Regex -> -- _obj [T.Text] -> -- string Int32 -> -- start_position T.Text -> -- replacement [RegexMatchFlags] -> -- match_options m T.Text regexReplace _obj string start_position replacement match_options = liftIO $ do let string_len = fromIntegral $ length string let _obj' = unsafeManagedPtrGetPtr _obj string' <- packUTF8CArray string replacement' <- textToCString replacement let match_options' = gflagsToWord match_options onException (do result <- propagateGError $ g_regex_replace _obj' string' string_len start_position replacement' match_options' checkUnexpectedReturnNULL "g_regex_replace" result result' <- cstringToText result freeMem result touchManagedPtr _obj (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem replacement' return result' ) (do (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem replacement' ) -- method Regex::replace_literal -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "replacement", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "replacement", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : True -- Skip return : False foreign import ccall "g_regex_replace_literal" g_regex_replace_literal :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" Ptr CString -> -- string : TCArray False (-1) 2 (TBasicType TUTF8) Int64 -> -- string_len : TBasicType TInt64 Int32 -> -- start_position : TBasicType TInt32 CString -> -- replacement : TBasicType TUTF8 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Ptr (Ptr GError) -> -- error IO CString regexReplaceLiteral :: (MonadIO m) => Regex -> -- _obj [T.Text] -> -- string Int32 -> -- start_position T.Text -> -- replacement [RegexMatchFlags] -> -- match_options m T.Text regexReplaceLiteral _obj string start_position replacement match_options = liftIO $ do let string_len = fromIntegral $ length string let _obj' = unsafeManagedPtrGetPtr _obj string' <- packUTF8CArray string replacement' <- textToCString replacement let match_options' = gflagsToWord match_options onException (do result <- propagateGError $ g_regex_replace_literal _obj' string' string_len start_position replacement' match_options' checkUnexpectedReturnNULL "g_regex_replace_literal" result result' <- cstringToText result freeMem result touchManagedPtr _obj (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem replacement' return result' ) (do (mapCArrayWithLength string_len) freeMem string' freeMem string' freeMem replacement' ) -- method Regex::split -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TCArray True (-1) (-1) (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_regex_split" g_regex_split :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" CString -> -- string : TBasicType TUTF8 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" IO (Ptr CString) regexSplit :: (MonadIO m) => Regex -> -- _obj T.Text -> -- string [RegexMatchFlags] -> -- match_options m [T.Text] regexSplit _obj string match_options = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj string' <- textToCString string let match_options' = gflagsToWord match_options result <- g_regex_split _obj' string' match_options' checkUnexpectedReturnNULL "g_regex_split" result result' <- unpackZeroTerminatedUTF8CArray result mapZeroTerminatedCArray freeMem result freeMem result touchManagedPtr _obj freeMem string' return result' -- method Regex::split_full -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "max_tokens", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [Arg {argName = "string_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_position", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_options", argType = TInterface "GLib" "RegexMatchFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "max_tokens", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TCArray True (-1) (-1) (TBasicType TUTF8) -- throws : True -- Skip return : False foreign import ccall "g_regex_split_full" g_regex_split_full :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" Ptr CString -> -- string : TCArray False (-1) 2 (TBasicType TUTF8) Int64 -> -- string_len : TBasicType TInt64 Int32 -> -- start_position : TBasicType TInt32 CUInt -> -- match_options : TInterface "GLib" "RegexMatchFlags" Int32 -> -- max_tokens : TBasicType TInt32 Ptr (Ptr GError) -> -- error IO (Ptr CString) regexSplitFull :: (MonadIO m) => Regex -> -- _obj [T.Text] -> -- string Int32 -> -- start_position [RegexMatchFlags] -> -- match_options Int32 -> -- max_tokens m [T.Text] regexSplitFull _obj string start_position match_options max_tokens = liftIO $ do let string_len = fromIntegral $ length string let _obj' = unsafeManagedPtrGetPtr _obj string' <- packUTF8CArray string let match_options' = gflagsToWord match_options onException (do result <- propagateGError $ g_regex_split_full _obj' string' string_len start_position match_options' max_tokens checkUnexpectedReturnNULL "g_regex_split_full" result result' <- unpackZeroTerminatedUTF8CArray result mapZeroTerminatedCArray freeMem result freeMem result touchManagedPtr _obj (mapCArrayWithLength string_len) freeMem string' freeMem string' return result' ) (do (mapCArrayWithLength string_len) freeMem string' freeMem string' ) -- method Regex::unref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Regex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_regex_unref" g_regex_unref :: Ptr Regex -> -- _obj : TInterface "GLib" "Regex" IO () regexUnref :: (MonadIO m) => Regex -> -- _obj m () regexUnref _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_regex_unref _obj' touchManagedPtr _obj return ()