{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) A GMatchInfo is an opaque struct used to return information about matches. -} module GI.GLib.Structs.MatchInfo ( -- * Exported types MatchInfo(..) , noMatchInfo , -- * Methods -- ** matchInfoExpandReferences matchInfoExpandReferences , -- ** matchInfoFetch matchInfoFetch , -- ** matchInfoFetchAll matchInfoFetchAll , -- ** matchInfoFetchNamed matchInfoFetchNamed , -- ** matchInfoFetchNamedPos matchInfoFetchNamedPos , -- ** matchInfoFetchPos matchInfoFetchPos , -- ** matchInfoFree matchInfoFree , -- ** matchInfoGetMatchCount matchInfoGetMatchCount , -- ** matchInfoGetRegex matchInfoGetRegex , -- ** matchInfoGetString matchInfoGetString , -- ** matchInfoIsPartialMatch matchInfoIsPartialMatch , -- ** matchInfoMatches matchInfoMatches , -- ** matchInfoNext matchInfoNext , -- ** matchInfoRef matchInfoRef , -- ** matchInfoUnref matchInfoUnref , ) 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 MatchInfo = MatchInfo (ForeignPtr MatchInfo) foreign import ccall "g_match_info_get_type" c_g_match_info_get_type :: IO GType instance BoxedObject MatchInfo where boxedType _ = c_g_match_info_get_type noMatchInfo :: Maybe MatchInfo noMatchInfo = Nothing -- method MatchInfo::expand_references -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_to_expand", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_to_expand", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : True -- Skip return : False foreign import ccall "g_match_info_expand_references" g_match_info_expand_references :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" CString -> -- string_to_expand : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO CString matchInfoExpandReferences :: (MonadIO m) => MatchInfo -> -- _obj T.Text -> -- string_to_expand m T.Text matchInfoExpandReferences _obj string_to_expand = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj string_to_expand' <- textToCString string_to_expand onException (do result <- propagateGError $ g_match_info_expand_references _obj' string_to_expand' checkUnexpectedReturnNULL "g_match_info_expand_references" result result' <- cstringToText result freeMem result touchManagedPtr _obj freeMem string_to_expand' return result' ) (do freeMem string_to_expand' ) -- method MatchInfo::fetch -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_num", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_num", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "g_match_info_fetch" g_match_info_fetch :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" Int32 -> -- match_num : TBasicType TInt32 IO CString matchInfoFetch :: (MonadIO m) => MatchInfo -> -- _obj Int32 -> -- match_num m T.Text matchInfoFetch _obj match_num = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_fetch _obj' match_num checkUnexpectedReturnNULL "g_match_info_fetch" result result' <- cstringToText result freeMem result touchManagedPtr _obj return result' -- method MatchInfo::fetch_all -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", 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_match_info_fetch_all" g_match_info_fetch_all :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO (Ptr CString) matchInfoFetchAll :: (MonadIO m) => MatchInfo -> -- _obj m [T.Text] matchInfoFetchAll _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_fetch_all _obj' checkUnexpectedReturnNULL "g_match_info_fetch_all" result result' <- unpackZeroTerminatedUTF8CArray result mapZeroTerminatedCArray freeMem result freeMem result touchManagedPtr _obj return result' -- method MatchInfo::fetch_named -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", 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" "MatchInfo", 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 TUTF8 -- throws : False -- Skip return : False foreign import ccall "g_match_info_fetch_named" g_match_info_fetch_named :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" CString -> -- name : TBasicType TUTF8 IO CString matchInfoFetchNamed :: (MonadIO m) => MatchInfo -> -- _obj T.Text -> -- name m T.Text matchInfoFetchNamed _obj name = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj name' <- textToCString name result <- g_match_info_fetch_named _obj' name' checkUnexpectedReturnNULL "g_match_info_fetch_named" result result' <- cstringToText result freeMem result touchManagedPtr _obj freeMem name' return result' -- method MatchInfo::fetch_named_pos -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", 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},Arg {argName = "start_pos", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "end_pos", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", 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 TBoolean -- throws : False -- Skip return : False foreign import ccall "g_match_info_fetch_named_pos" g_match_info_fetch_named_pos :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" CString -> -- name : TBasicType TUTF8 Ptr Int32 -> -- start_pos : TBasicType TInt32 Ptr Int32 -> -- end_pos : TBasicType TInt32 IO CInt matchInfoFetchNamedPos :: (MonadIO m) => MatchInfo -> -- _obj T.Text -> -- name m (Bool,Int32,Int32) matchInfoFetchNamedPos _obj name = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj name' <- textToCString name start_pos <- allocMem :: IO (Ptr Int32) end_pos <- allocMem :: IO (Ptr Int32) result <- g_match_info_fetch_named_pos _obj' name' start_pos end_pos let result' = (/= 0) result start_pos' <- peek start_pos end_pos' <- peek end_pos touchManagedPtr _obj freeMem name' freeMem start_pos freeMem end_pos return (result', start_pos', end_pos') -- method MatchInfo::fetch_pos -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_num", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_pos", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "end_pos", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "match_num", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_match_info_fetch_pos" g_match_info_fetch_pos :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" Int32 -> -- match_num : TBasicType TInt32 Ptr Int32 -> -- start_pos : TBasicType TInt32 Ptr Int32 -> -- end_pos : TBasicType TInt32 IO CInt matchInfoFetchPos :: (MonadIO m) => MatchInfo -> -- _obj Int32 -> -- match_num m (Bool,Int32,Int32) matchInfoFetchPos _obj match_num = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj start_pos <- allocMem :: IO (Ptr Int32) end_pos <- allocMem :: IO (Ptr Int32) result <- g_match_info_fetch_pos _obj' match_num start_pos end_pos let result' = (/= 0) result start_pos' <- peek start_pos end_pos' <- peek end_pos touchManagedPtr _obj freeMem start_pos freeMem end_pos return (result', start_pos', end_pos') -- method MatchInfo::free -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_match_info_free" g_match_info_free :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO () matchInfoFree :: (MonadIO m) => MatchInfo -> -- _obj m () matchInfoFree _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_match_info_free _obj' touchManagedPtr _obj return () -- method MatchInfo::get_match_count -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TInt32 -- throws : False -- Skip return : False foreign import ccall "g_match_info_get_match_count" g_match_info_get_match_count :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO Int32 matchInfoGetMatchCount :: (MonadIO m) => MatchInfo -> -- _obj m Int32 matchInfoGetMatchCount _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_get_match_count _obj' touchManagedPtr _obj return result -- method MatchInfo::get_regex -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", 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_match_info_get_regex" g_match_info_get_regex :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO (Ptr Regex) matchInfoGetRegex :: (MonadIO m) => MatchInfo -> -- _obj m Regex matchInfoGetRegex _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_get_regex _obj' checkUnexpectedReturnNULL "g_match_info_get_regex" result result' <- (wrapBoxed Regex) result touchManagedPtr _obj return result' -- method MatchInfo::get_string -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "g_match_info_get_string" g_match_info_get_string :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO CString matchInfoGetString :: (MonadIO m) => MatchInfo -> -- _obj m T.Text matchInfoGetString _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_get_string _obj' checkUnexpectedReturnNULL "g_match_info_get_string" result result' <- cstringToText result touchManagedPtr _obj return result' -- method MatchInfo::is_partial_match -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_match_info_is_partial_match" g_match_info_is_partial_match :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO CInt matchInfoIsPartialMatch :: (MonadIO m) => MatchInfo -> -- _obj m Bool matchInfoIsPartialMatch _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_is_partial_match _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method MatchInfo::matches -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_match_info_matches" g_match_info_matches :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO CInt matchInfoMatches :: (MonadIO m) => MatchInfo -> -- _obj m Bool matchInfoMatches _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_matches _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method MatchInfo::next -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "g_match_info_next" g_match_info_next :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" Ptr (Ptr GError) -> -- error IO CInt matchInfoNext :: (MonadIO m) => MatchInfo -> -- _obj m () matchInfoNext _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj onException (do _ <- propagateGError $ g_match_info_next _obj' touchManagedPtr _obj return () ) (do return () ) -- method MatchInfo::ref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "GLib" "MatchInfo" -- throws : False -- Skip return : False foreign import ccall "g_match_info_ref" g_match_info_ref :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO (Ptr MatchInfo) matchInfoRef :: (MonadIO m) => MatchInfo -> -- _obj m MatchInfo matchInfoRef _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_match_info_ref _obj' checkUnexpectedReturnNULL "g_match_info_ref" result result' <- (wrapBoxed MatchInfo) result touchManagedPtr _obj return result' -- method MatchInfo::unref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "MatchInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_match_info_unref" g_match_info_unref :: Ptr MatchInfo -> -- _obj : TInterface "GLib" "MatchInfo" IO () matchInfoUnref :: (MonadIO m) => MatchInfo -> -- _obj m () matchInfoUnref _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_match_info_unref _obj' touchManagedPtr _obj return ()