{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A @GOptionContext@ struct defines which options
-- are accepted by the commandline option parser. The struct has only private
-- fields and should not be directly accessed.

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

module GI.GLib.Structs.OptionContext
    ( 

-- * Exported types
    OptionContext(..)                       ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveOptionContextMethod              ,
#endif


-- ** addGroup #method:addGroup#

#if defined(ENABLE_OVERLOADING)
    OptionContextAddGroupMethodInfo         ,
#endif
    optionContextAddGroup                   ,


-- ** addMainEntries #method:addMainEntries#

#if defined(ENABLE_OVERLOADING)
    OptionContextAddMainEntriesMethodInfo   ,
#endif
    optionContextAddMainEntries             ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    OptionContextFreeMethodInfo             ,
#endif
    optionContextFree                       ,


-- ** getDescription #method:getDescription#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetDescriptionMethodInfo   ,
#endif
    optionContextGetDescription             ,


-- ** getHelp #method:getHelp#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetHelpMethodInfo          ,
#endif
    optionContextGetHelp                    ,


-- ** getHelpEnabled #method:getHelpEnabled#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetHelpEnabledMethodInfo   ,
#endif
    optionContextGetHelpEnabled             ,


-- ** getIgnoreUnknownOptions #method:getIgnoreUnknownOptions#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetIgnoreUnknownOptionsMethodInfo,
#endif
    optionContextGetIgnoreUnknownOptions    ,


-- ** getMainGroup #method:getMainGroup#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetMainGroupMethodInfo     ,
#endif
    optionContextGetMainGroup               ,


-- ** getStrictPosix #method:getStrictPosix#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetStrictPosixMethodInfo   ,
#endif
    optionContextGetStrictPosix             ,


-- ** getSummary #method:getSummary#

#if defined(ENABLE_OVERLOADING)
    OptionContextGetSummaryMethodInfo       ,
#endif
    optionContextGetSummary                 ,


-- ** parse #method:parse#

#if defined(ENABLE_OVERLOADING)
    OptionContextParseMethodInfo            ,
#endif
    optionContextParse                      ,


-- ** setDescription #method:setDescription#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetDescriptionMethodInfo   ,
#endif
    optionContextSetDescription             ,


-- ** setHelpEnabled #method:setHelpEnabled#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetHelpEnabledMethodInfo   ,
#endif
    optionContextSetHelpEnabled             ,


-- ** setIgnoreUnknownOptions #method:setIgnoreUnknownOptions#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetIgnoreUnknownOptionsMethodInfo,
#endif
    optionContextSetIgnoreUnknownOptions    ,


-- ** setMainGroup #method:setMainGroup#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetMainGroupMethodInfo     ,
#endif
    optionContextSetMainGroup               ,


-- ** setStrictPosix #method:setStrictPosix#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetStrictPosixMethodInfo   ,
#endif
    optionContextSetStrictPosix             ,


-- ** setSummary #method:setSummary#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetSummaryMethodInfo       ,
#endif
    optionContextSetSummary                 ,


-- ** setTranslateFunc #method:setTranslateFunc#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetTranslateFuncMethodInfo ,
#endif
    optionContextSetTranslateFunc           ,


-- ** setTranslationDomain #method:setTranslationDomain#

#if defined(ENABLE_OVERLOADING)
    OptionContextSetTranslationDomainMethodInfo,
#endif
    optionContextSetTranslationDomain       ,




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

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

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

-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance BoxedPtr OptionContext where
    boxedPtrCopy :: OptionContext -> IO OptionContext
boxedPtrCopy = OptionContext -> IO OptionContext
forall (m :: * -> *) a. Monad m => a -> m a
return
    boxedPtrFree :: OptionContext -> IO ()
boxedPtrFree = \OptionContext
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


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

-- method OptionContext::add_group
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "group"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionGroup" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the group to add" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_add_group" g_option_context_add_group :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    Ptr GLib.OptionGroup.OptionGroup ->     -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    IO ()

-- | Adds a t'GI.GLib.Structs.OptionGroup.OptionGroup' to the /@context@/, so that parsing with /@context@/
-- will recognize the options in the group. Note that this will take
-- ownership of the /@group@/ and thus the /@group@/ should not be freed.
-- 
-- /Since: 2.6/
optionContextAddGroup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> GLib.OptionGroup.OptionGroup
    -- ^ /@group@/: the group to add
    -> m ()
optionContextAddGroup :: OptionContext -> OptionGroup -> m ()
optionContextAddGroup OptionContext
context OptionGroup
group = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed OptionGroup
group
    Ptr OptionContext -> Ptr OptionGroup -> IO ()
g_option_context_add_group Ptr OptionContext
context' Ptr OptionGroup
group'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextAddGroupMethodInfo
instance (signature ~ (GLib.OptionGroup.OptionGroup -> m ()), MonadIO m) => O.MethodInfo OptionContextAddGroupMethodInfo OptionContext signature where
    overloadedMethod = optionContextAddGroup

#endif

-- method OptionContext::add_main_entries
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "entries"
--           , argType =
--               TCArray
--                 True
--                 (-1)
--                 (-1)
--                 (TInterface Name { namespace = "GLib" , name = "OptionEntry" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a %NULL-terminated array of #GOptionEntrys"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "translation_domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a translation domain to use for translating\n   the `--help` output for the options in @entries\n   with gettext(), or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_add_main_entries" g_option_context_add_main_entries :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    Ptr (Ptr GLib.OptionEntry.OptionEntry) -> -- entries : TCArray True (-1) (-1) (TInterface (Name {namespace = "GLib", name = "OptionEntry"}))
    CString ->                              -- translation_domain : TBasicType TUTF8
    IO ()

-- | A convenience function which creates a main group if it doesn\'t
-- exist, adds the /@entries@/ to it and sets the translation domain.
-- 
-- /Since: 2.6/
optionContextAddMainEntries ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> [GLib.OptionEntry.OptionEntry]
    -- ^ /@entries@/: a 'P.Nothing'-terminated array of @/GOptionEntrys/@
    -> Maybe (T.Text)
    -- ^ /@translationDomain@/: a translation domain to use for translating
    --    the @--help@ output for the options in /@entries@/
    --    with @/gettext()/@, or 'P.Nothing'
    -> m ()
optionContextAddMainEntries :: OptionContext -> [OptionEntry] -> Maybe Text -> m ()
optionContextAddMainEntries OptionContext
context [OptionEntry]
entries Maybe Text
translationDomain = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    [Ptr OptionEntry]
entries' <- (OptionEntry -> IO (Ptr OptionEntry))
-> [OptionEntry] -> IO [Ptr OptionEntry]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM OptionEntry -> IO (Ptr OptionEntry)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [OptionEntry]
entries
    Ptr (Ptr OptionEntry)
entries'' <- [Ptr OptionEntry] -> IO (Ptr (Ptr OptionEntry))
forall a. [Ptr a] -> IO (Ptr (Ptr a))
packZeroTerminatedPtrArray [Ptr OptionEntry]
entries'
    Ptr CChar
maybeTranslationDomain <- case Maybe Text
translationDomain of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jTranslationDomain -> do
            Ptr CChar
jTranslationDomain' <- Text -> IO (Ptr CChar)
textToCString Text
jTranslationDomain
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jTranslationDomain'
    Ptr OptionContext -> Ptr (Ptr OptionEntry) -> Ptr CChar -> IO ()
g_option_context_add_main_entries Ptr OptionContext
context' Ptr (Ptr OptionEntry)
entries'' Ptr CChar
maybeTranslationDomain
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    (OptionEntry -> IO ()) -> [OptionEntry] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ OptionEntry -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [OptionEntry]
entries
    Ptr (Ptr OptionEntry) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr OptionEntry)
entries''
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeTranslationDomain
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextAddMainEntriesMethodInfo
instance (signature ~ ([GLib.OptionEntry.OptionEntry] -> Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextAddMainEntriesMethodInfo OptionContext signature where
    overloadedMethod = optionContextAddMainEntries

#endif

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

foreign import ccall "g_option_context_free" g_option_context_free :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO ()

-- | Frees context and all the groups which have been
-- added to it.
-- 
-- Please note that parsed arguments need to be freed separately (see
-- t'GI.GLib.Structs.OptionEntry.OptionEntry').
-- 
-- /Since: 2.6/
optionContextFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m ()
optionContextFree :: OptionContext -> m ()
optionContextFree OptionContext
context = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr OptionContext -> IO ()
g_option_context_free Ptr OptionContext
context'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo OptionContextFreeMethodInfo OptionContext signature where
    overloadedMethod = optionContextFree

#endif

-- method OptionContext::get_description
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , 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_option_context_get_description" g_option_context_get_description :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO CString

-- | Returns the description. See 'GI.GLib.Structs.OptionContext.optionContextSetDescription'.
-- 
-- /Since: 2.12/
optionContextGetDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m T.Text
    -- ^ __Returns:__ the description
optionContextGetDescription :: OptionContext -> m Text
optionContextGetDescription OptionContext
context = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr CChar
result <- Ptr OptionContext -> IO (Ptr CChar)
g_option_context_get_description Ptr OptionContext
context'
    Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"optionContextGetDescription" Ptr CChar
result
    Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo OptionContextGetDescriptionMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetDescription

#endif

-- method OptionContext::get_help
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "main_help"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "if %TRUE, only include the main group"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "group"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionGroup" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the #GOptionGroup to create help for, or %NULL"
--                 , 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_option_context_get_help" g_option_context_get_help :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CInt ->                                 -- main_help : TBasicType TBoolean
    Ptr GLib.OptionGroup.OptionGroup ->     -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    IO CString

-- | Returns a formatted, translated help text for the given context.
-- To obtain the text produced by @--help@, call
-- @g_option_context_get_help (context, TRUE, NULL)@.
-- To obtain the text produced by @--help-all@, call
-- @g_option_context_get_help (context, FALSE, NULL)@.
-- To obtain the help text for an option group, call
-- @g_option_context_get_help (context, FALSE, group)@.
-- 
-- /Since: 2.14/
optionContextGetHelp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Bool
    -- ^ /@mainHelp@/: if 'P.True', only include the main group
    -> Maybe (GLib.OptionGroup.OptionGroup)
    -- ^ /@group@/: the t'GI.GLib.Structs.OptionGroup.OptionGroup' to create help for, or 'P.Nothing'
    -> m T.Text
    -- ^ __Returns:__ A newly allocated string containing the help text
optionContextGetHelp :: OptionContext -> Bool -> Maybe OptionGroup -> m Text
optionContextGetHelp OptionContext
context Bool
mainHelp Maybe OptionGroup
group = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    let mainHelp' :: CInt
mainHelp' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
mainHelp
    Ptr OptionGroup
maybeGroup <- case Maybe OptionGroup
group of
        Maybe OptionGroup
Nothing -> Ptr OptionGroup -> IO (Ptr OptionGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr OptionGroup
forall a. Ptr a
nullPtr
        Just OptionGroup
jGroup -> do
            Ptr OptionGroup
jGroup' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
jGroup
            Ptr OptionGroup -> IO (Ptr OptionGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr OptionGroup
jGroup'
    Ptr CChar
result <- Ptr OptionContext -> CInt -> Ptr OptionGroup -> IO (Ptr CChar)
g_option_context_get_help Ptr OptionContext
context' CInt
mainHelp' Ptr OptionGroup
maybeGroup
    Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"optionContextGetHelp" Ptr CChar
result
    Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Maybe OptionGroup -> (OptionGroup -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe OptionGroup
group OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetHelpMethodInfo
instance (signature ~ (Bool -> Maybe (GLib.OptionGroup.OptionGroup) -> m T.Text), MonadIO m) => O.MethodInfo OptionContextGetHelpMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetHelp

#endif

-- method OptionContext::get_help_enabled
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , 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_option_context_get_help_enabled" g_option_context_get_help_enabled :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO CInt

-- | Returns whether automatic @--help@ generation
-- is turned on for /@context@/. See 'GI.GLib.Structs.OptionContext.optionContextSetHelpEnabled'.
-- 
-- /Since: 2.6/
optionContextGetHelpEnabled ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if automatic help generation is turned on.
optionContextGetHelpEnabled :: OptionContext -> m Bool
optionContextGetHelpEnabled OptionContext
context = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    CInt
result <- Ptr OptionContext -> IO CInt
g_option_context_get_help_enabled Ptr OptionContext
context'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetHelpEnabledMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetHelpEnabledMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetHelpEnabled

#endif

-- method OptionContext::get_ignore_unknown_options
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , 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_option_context_get_ignore_unknown_options" g_option_context_get_ignore_unknown_options :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO CInt

-- | Returns whether unknown options are ignored or not. See
-- 'GI.GLib.Structs.OptionContext.optionContextSetIgnoreUnknownOptions'.
-- 
-- /Since: 2.6/
optionContextGetIgnoreUnknownOptions ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if unknown options are ignored.
optionContextGetIgnoreUnknownOptions :: OptionContext -> m Bool
optionContextGetIgnoreUnknownOptions OptionContext
context = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    CInt
result <- Ptr OptionContext -> IO CInt
g_option_context_get_ignore_unknown_options Ptr OptionContext
context'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetIgnoreUnknownOptionsMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetIgnoreUnknownOptionsMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetIgnoreUnknownOptions

#endif

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

foreign import ccall "g_option_context_get_main_group" g_option_context_get_main_group :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO (Ptr GLib.OptionGroup.OptionGroup)

-- | Returns a pointer to the main group of /@context@/.
-- 
-- /Since: 2.6/
optionContextGetMainGroup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m GLib.OptionGroup.OptionGroup
    -- ^ __Returns:__ the main group of /@context@/, or 'P.Nothing' if
    --  /@context@/ doesn\'t have a main group. Note that group belongs to
    --  /@context@/ and should not be modified or freed.
optionContextGetMainGroup :: OptionContext -> m OptionGroup
optionContextGetMainGroup OptionContext
context = IO OptionGroup -> m OptionGroup
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OptionGroup -> m OptionGroup)
-> IO OptionGroup -> m OptionGroup
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr OptionGroup
result <- Ptr OptionContext -> IO (Ptr OptionGroup)
g_option_context_get_main_group Ptr OptionContext
context'
    Text -> Ptr OptionGroup -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"optionContextGetMainGroup" Ptr OptionGroup
result
    OptionGroup
result' <- ((ManagedPtr OptionGroup -> OptionGroup)
-> Ptr OptionGroup -> IO OptionGroup
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr OptionGroup -> OptionGroup
GLib.OptionGroup.OptionGroup) Ptr OptionGroup
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    OptionGroup -> IO OptionGroup
forall (m :: * -> *) a. Monad m => a -> m a
return OptionGroup
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetMainGroupMethodInfo
instance (signature ~ (m GLib.OptionGroup.OptionGroup), MonadIO m) => O.MethodInfo OptionContextGetMainGroupMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetMainGroup

#endif

-- method OptionContext::get_strict_posix
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , 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_option_context_get_strict_posix" g_option_context_get_strict_posix :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO CInt

-- | Returns whether strict POSIX code is enabled.
-- 
-- See 'GI.GLib.Structs.OptionContext.optionContextSetStrictPosix' for more information.
-- 
-- /Since: 2.44/
optionContextGetStrictPosix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if strict POSIX is enabled, 'P.False' otherwise.
optionContextGetStrictPosix :: OptionContext -> m Bool
optionContextGetStrictPosix OptionContext
context = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    CInt
result <- Ptr OptionContext -> IO CInt
g_option_context_get_strict_posix Ptr OptionContext
context'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetStrictPosixMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetStrictPosixMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetStrictPosix

#endif

-- method OptionContext::get_summary
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , 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_option_context_get_summary" g_option_context_get_summary :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    IO CString

-- | Returns the summary. See 'GI.GLib.Structs.OptionContext.optionContextSetSummary'.
-- 
-- /Since: 2.12/
optionContextGetSummary ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> m T.Text
    -- ^ __Returns:__ the summary
optionContextGetSummary :: OptionContext -> m Text
optionContextGetSummary OptionContext
context = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr CChar
result <- Ptr OptionContext -> IO (Ptr CChar)
g_option_context_get_summary Ptr OptionContext
context'
    Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"optionContextGetSummary" Ptr CChar
result
    Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data OptionContextGetSummaryMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo OptionContextGetSummaryMethodInfo OptionContext signature where
    overloadedMethod = optionContextGetSummary

#endif

-- method OptionContext::parse
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "argc"
--           , argType = TBasicType TInt
--           , direction = DirectionInout
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a pointer to the number of command line arguments"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "argv"
--           , argType = TCArray False (-1) 1 (TBasicType TUTF8)
--           , direction = DirectionInout
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a pointer to the array of command line arguments"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "argc"
--              , argType = TBasicType TInt
--              , direction = DirectionInout
--              , mayBeNull = True
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just "a pointer to the number of command line arguments"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferEverything
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_option_context_parse" g_option_context_parse :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    Ptr Int32 ->                            -- argc : TBasicType TInt
    Ptr (Ptr CString) ->                    -- argv : TCArray False (-1) 1 (TBasicType TUTF8)
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Parses the command line arguments, recognizing options
-- which have been added to /@context@/. A side-effect of
-- calling this function is that 'GI.GLib.Functions.setPrgname' will be
-- called.
-- 
-- If the parsing is successful, any parsed arguments are
-- removed from the array and /@argc@/ and /@argv@/ are updated
-- accordingly. A \'--\' option is stripped from /@argv@/
-- unless there are unparsed options before and after it,
-- or some of the options after it start with \'-\'. In case
-- of an error, /@argc@/ and /@argv@/ are left unmodified.
-- 
-- If automatic @--help@ support is enabled
-- (see 'GI.GLib.Structs.OptionContext.optionContextSetHelpEnabled'), and the
-- /@argv@/ array contains one of the recognized help options,
-- this function will produce help output to stdout and
-- call @exit (0)@.
-- 
-- Note that function depends on the [current locale][setlocale] for
-- automatic character set conversion of string and filename
-- arguments.
-- 
-- /Since: 2.6/
optionContextParse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Maybe ([T.Text])
    -- ^ /@argv@/: a pointer to the array of command line arguments
    -> m ((Maybe [T.Text]))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
optionContextParse :: OptionContext -> Maybe [Text] -> m (Maybe [Text])
optionContextParse OptionContext
context Maybe [Text]
argv = IO (Maybe [Text]) -> m (Maybe [Text])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Text]) -> m (Maybe [Text]))
-> IO (Maybe [Text]) -> m (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ do
    let argc :: Int32
argc = case Maybe [Text]
argv of
            Maybe [Text]
Nothing -> Int32
0
            Just [Text]
jArgv -> 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]
jArgv
    Ptr OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr Int32
argc' <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
argc' Int32
argc
    Ptr (Ptr CChar)
maybeArgv <- case Maybe [Text]
argv of
        Maybe [Text]
Nothing -> Ptr (Ptr CChar) -> IO (Ptr (Ptr CChar))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (Ptr CChar)
forall a. Ptr a
nullPtr
        Just [Text]
jArgv -> do
            Ptr (Ptr CChar)
jArgv' <- [Text] -> IO (Ptr (Ptr CChar))
packUTF8CArray [Text]
jArgv
            Ptr (Ptr CChar) -> IO (Ptr (Ptr CChar))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (Ptr CChar)
jArgv'
    Ptr (Ptr (Ptr CChar))
maybeArgv' <- IO (Ptr (Ptr (Ptr CChar)))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
    Ptr (Ptr (Ptr CChar)) -> Ptr (Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (Ptr (Ptr CChar))
maybeArgv' Ptr (Ptr CChar)
maybeArgv
    IO (Maybe [Text]) -> IO () -> IO (Maybe [Text])
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 OptionContext
-> Ptr Int32
-> Ptr (Ptr (Ptr CChar))
-> Ptr (Ptr GError)
-> IO CInt
g_option_context_parse Ptr OptionContext
context' Ptr Int32
argc' Ptr (Ptr (Ptr CChar))
maybeArgv'
        Int32
argc'' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
argc'
        Ptr (Ptr CChar)
maybeArgv'' <- Ptr (Ptr (Ptr CChar)) -> IO (Ptr (Ptr CChar))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (Ptr CChar))
maybeArgv'
        Maybe [Text]
maybeMaybeArgv'' <- Ptr (Ptr CChar)
-> (Ptr (Ptr CChar) -> IO [Text]) -> IO (Maybe [Text])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr (Ptr CChar)
maybeArgv'' ((Ptr (Ptr CChar) -> IO [Text]) -> IO (Maybe [Text]))
-> (Ptr (Ptr CChar) -> IO [Text]) -> IO (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
maybeArgv''' -> do
            [Text]
maybeArgv'''' <- (Int32 -> Ptr (Ptr CChar) -> IO [Text]
forall a.
(HasCallStack, Integral a) =>
a -> Ptr (Ptr CChar) -> IO [Text]
unpackUTF8CArrayWithLength Int32
argc'') Ptr (Ptr CChar)
maybeArgv'''
            (Int32 -> (Ptr CChar -> IO ()) -> Ptr (Ptr CChar) -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int32
argc'') Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CChar)
maybeArgv'''
            Ptr (Ptr CChar) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CChar)
maybeArgv'''
            [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
maybeArgv''''
        OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc'
        Ptr (Ptr (Ptr CChar)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr CChar))
maybeArgv'
        Maybe [Text] -> IO (Maybe [Text])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Text]
maybeMaybeArgv''
     ) (do
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc'
        Ptr (Ptr (Ptr CChar)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr CChar))
maybeArgv'
     )

#if defined(ENABLE_OVERLOADING)
data OptionContextParseMethodInfo
instance (signature ~ (Maybe ([T.Text]) -> m ((Maybe [T.Text]))), MonadIO m) => O.MethodInfo OptionContextParseMethodInfo OptionContext signature where
    overloadedMethod = optionContextParse

#endif

-- XXX Could not generate method OptionContext::parse_strv
{-  Bad introspection data: `TCArray False (-1) (-1) (TBasicType TUTF8)' is an array type, but contains no length information,
    so it cannot be unpacked.
-}
-- method OptionContext::set_description
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "description"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a string to be shown in `--help` output\n  after the list of options, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_description" g_option_context_set_description :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CString ->                              -- description : TBasicType TUTF8
    IO ()

-- | Adds a string to be displayed in @--help@ output after the list
-- of options. This text often includes a bug reporting address.
-- 
-- Note that the summary is translated (see
-- 'GI.GLib.Structs.OptionContext.optionContextSetTranslateFunc').
-- 
-- /Since: 2.12/
optionContextSetDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Maybe (T.Text)
    -- ^ /@description@/: a string to be shown in @--help@ output
    --   after the list of options, or 'P.Nothing'
    -> m ()
optionContextSetDescription :: OptionContext -> Maybe Text -> m ()
optionContextSetDescription OptionContext
context Maybe Text
description = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr CChar
maybeDescription <- case Maybe Text
description of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jDescription -> do
            Ptr CChar
jDescription' <- Text -> IO (Ptr CChar)
textToCString Text
jDescription
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jDescription'
    Ptr OptionContext -> Ptr CChar -> IO ()
g_option_context_set_description Ptr OptionContext
context' Ptr CChar
maybeDescription
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeDescription
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetDescriptionMethodInfo
instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetDescriptionMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetDescription

#endif

-- method OptionContext::set_help_enabled
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "help_enabled"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "%TRUE to enable `--help`, %FALSE to disable it"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_help_enabled" g_option_context_set_help_enabled :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CInt ->                                 -- help_enabled : TBasicType TBoolean
    IO ()

-- | Enables or disables automatic generation of @--help@ output.
-- By default, 'GI.GLib.Structs.OptionContext.optionContextParse' recognizes @--help@, @-h@,
-- @-?@, @--help-all@ and @--help-groupname@ and creates suitable
-- output to stdout.
-- 
-- /Since: 2.6/
optionContextSetHelpEnabled ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Bool
    -- ^ /@helpEnabled@/: 'P.True' to enable @--help@, 'P.False' to disable it
    -> m ()
optionContextSetHelpEnabled :: OptionContext -> Bool -> m ()
optionContextSetHelpEnabled OptionContext
context Bool
helpEnabled = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    let helpEnabled' :: CInt
helpEnabled' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
helpEnabled
    Ptr OptionContext -> CInt -> IO ()
g_option_context_set_help_enabled Ptr OptionContext
context' CInt
helpEnabled'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetHelpEnabledMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetHelpEnabledMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetHelpEnabled

#endif

-- method OptionContext::set_ignore_unknown_options
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ignore_unknown"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "%TRUE to ignore unknown options, %FALSE to produce\n   an error when unknown options are met"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_ignore_unknown_options" g_option_context_set_ignore_unknown_options :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CInt ->                                 -- ignore_unknown : TBasicType TBoolean
    IO ()

-- | Sets whether to ignore unknown options or not. If an argument is
-- ignored, it is left in the /@argv@/ array after parsing. By default,
-- 'GI.GLib.Structs.OptionContext.optionContextParse' treats unknown options as error.
-- 
-- This setting does not affect non-option arguments (i.e. arguments
-- which don\'t start with a dash). But note that GOption cannot reliably
-- determine whether a non-option belongs to a preceding unknown option.
-- 
-- /Since: 2.6/
optionContextSetIgnoreUnknownOptions ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Bool
    -- ^ /@ignoreUnknown@/: 'P.True' to ignore unknown options, 'P.False' to produce
    --    an error when unknown options are met
    -> m ()
optionContextSetIgnoreUnknownOptions :: OptionContext -> Bool -> m ()
optionContextSetIgnoreUnknownOptions OptionContext
context Bool
ignoreUnknown = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    let ignoreUnknown' :: CInt
ignoreUnknown' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
ignoreUnknown
    Ptr OptionContext -> CInt -> IO ()
g_option_context_set_ignore_unknown_options Ptr OptionContext
context' CInt
ignoreUnknown'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetIgnoreUnknownOptionsMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetIgnoreUnknownOptionsMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetIgnoreUnknownOptions

#endif

-- method OptionContext::set_main_group
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "group"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionGroup" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the group to set as main group"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_main_group" g_option_context_set_main_group :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    Ptr GLib.OptionGroup.OptionGroup ->     -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    IO ()

-- | Sets a t'GI.GLib.Structs.OptionGroup.OptionGroup' as main group of the /@context@/.
-- This has the same effect as calling 'GI.GLib.Structs.OptionContext.optionContextAddGroup',
-- the only difference is that the options in the main group are
-- treated differently when generating @--help@ output.
-- 
-- /Since: 2.6/
optionContextSetMainGroup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> GLib.OptionGroup.OptionGroup
    -- ^ /@group@/: the group to set as main group
    -> m ()
optionContextSetMainGroup :: OptionContext -> OptionGroup -> m ()
optionContextSetMainGroup OptionContext
context OptionGroup
group = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed OptionGroup
group
    Ptr OptionContext -> Ptr OptionGroup -> IO ()
g_option_context_set_main_group Ptr OptionContext
context' Ptr OptionGroup
group'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetMainGroupMethodInfo
instance (signature ~ (GLib.OptionGroup.OptionGroup -> m ()), MonadIO m) => O.MethodInfo OptionContextSetMainGroupMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetMainGroup

#endif

-- method OptionContext::set_strict_posix
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "strict_posix"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the new value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_strict_posix" g_option_context_set_strict_posix :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CInt ->                                 -- strict_posix : TBasicType TBoolean
    IO ()

-- | Sets strict POSIX mode.
-- 
-- By default, this mode is disabled.
-- 
-- In strict POSIX mode, the first non-argument parameter encountered
-- (eg: filename) terminates argument processing.  Remaining arguments
-- are treated as non-options and are not attempted to be parsed.
-- 
-- If strict POSIX mode is disabled then parsing is done in the GNU way
-- where option arguments can be freely mixed with non-options.
-- 
-- As an example, consider \"ls foo -l\".  With GNU style parsing, this
-- will list \"foo\" in long mode.  In strict POSIX style, this will list
-- the files named \"foo\" and \"-l\".
-- 
-- It may be useful to force strict POSIX mode when creating \"verb
-- style\" command line tools.  For example, the \"gsettings\" command line
-- tool supports the global option \"--schemadir\" as well as many
-- subcommands (\"get\", \"set\", etc.) which each have their own set of
-- arguments.  Using strict POSIX mode will allow parsing the global
-- options up to the verb name while leaving the remaining options to be
-- parsed by the relevant subcommand (which can be determined by
-- examining the verb name, which should be present in argv[1] after
-- parsing).
-- 
-- /Since: 2.44/
optionContextSetStrictPosix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Bool
    -- ^ /@strictPosix@/: the new value
    -> m ()
optionContextSetStrictPosix :: OptionContext -> Bool -> m ()
optionContextSetStrictPosix OptionContext
context Bool
strictPosix = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    let strictPosix' :: CInt
strictPosix' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
strictPosix
    Ptr OptionContext -> CInt -> IO ()
g_option_context_set_strict_posix Ptr OptionContext
context' CInt
strictPosix'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetStrictPosixMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetStrictPosixMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetStrictPosix

#endif

-- method OptionContext::set_summary
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "summary"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a string to be shown in `--help` output\n before the list of options, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_summary" g_option_context_set_summary :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CString ->                              -- summary : TBasicType TUTF8
    IO ()

-- | Adds a string to be displayed in @--help@ output before the list
-- of options. This is typically a summary of the program functionality.
-- 
-- Note that the summary is translated (see
-- 'GI.GLib.Structs.OptionContext.optionContextSetTranslateFunc' and
-- 'GI.GLib.Structs.OptionContext.optionContextSetTranslationDomain').
-- 
-- /Since: 2.12/
optionContextSetSummary ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Maybe (T.Text)
    -- ^ /@summary@/: a string to be shown in @--help@ output
    --  before the list of options, or 'P.Nothing'
    -> m ()
optionContextSetSummary :: OptionContext -> Maybe Text -> m ()
optionContextSetSummary OptionContext
context Maybe Text
summary = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr CChar
maybeSummary <- case Maybe Text
summary of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jSummary -> do
            Ptr CChar
jSummary' <- Text -> IO (Ptr CChar)
textToCString Text
jSummary
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jSummary'
    Ptr OptionContext -> Ptr CChar -> IO ()
g_option_context_set_summary Ptr OptionContext
context' Ptr CChar
maybeSummary
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeSummary
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetSummaryMethodInfo
instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetSummaryMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetSummary

#endif

-- method OptionContext::set_translate_func
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "func"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TranslateFunc" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #GTranslateFunc, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 2
--           , argDestroy = 3
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data to pass to @func, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "destroy_notify"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a function which gets called to free @data, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_translate_func" g_option_context_set_translate_func :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    FunPtr GLib.Callbacks.C_TranslateFunc -> -- func : TInterface (Name {namespace = "GLib", name = "TranslateFunc"})
    Ptr () ->                               -- data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

-- | Sets the function which is used to translate the contexts
-- user-visible strings, for @--help@ output. If /@func@/ is 'P.Nothing',
-- strings are not translated.
-- 
-- Note that option groups have their own translation functions,
-- this function only affects the /@parameterString@/ (see @/g_option_context_new()/@),
-- the summary (see 'GI.GLib.Structs.OptionContext.optionContextSetSummary') and the description
-- (see 'GI.GLib.Structs.OptionContext.optionContextSetDescription').
-- 
-- If you are using @/gettext()/@, you only need to set the translation
-- domain, see 'GI.GLib.Structs.OptionContext.optionContextSetTranslationDomain'.
-- 
-- /Since: 2.12/
optionContextSetTranslateFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> Maybe (GLib.Callbacks.TranslateFunc)
    -- ^ /@func@/: the t'GI.GLib.Callbacks.TranslateFunc', or 'P.Nothing'
    -> m ()
optionContextSetTranslateFunc :: OptionContext -> Maybe TranslateFunc -> m ()
optionContextSetTranslateFunc OptionContext
context Maybe TranslateFunc
func = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    FunPtr C_TranslateFunc
maybeFunc <- case Maybe TranslateFunc
func of
        Maybe TranslateFunc
Nothing -> FunPtr C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_TranslateFunc
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just TranslateFunc
jFunc -> do
            FunPtr C_TranslateFunc
jFunc' <- C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
GLib.Callbacks.mk_TranslateFunc (Maybe (Ptr (FunPtr C_TranslateFunc))
-> TranslateFunc -> C_TranslateFunc
GLib.Callbacks.wrap_TranslateFunc Maybe (Ptr (FunPtr C_TranslateFunc))
forall a. Maybe a
Nothing TranslateFunc
jFunc)
            FunPtr C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_TranslateFunc
jFunc'
    let data_ :: Ptr ()
data_ = FunPtr C_TranslateFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TranslateFunc
maybeFunc
    let destroyNotify :: FunPtr (Ptr a -> IO ())
destroyNotify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Ptr OptionContext
-> FunPtr C_TranslateFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO ()
g_option_context_set_translate_func Ptr OptionContext
context' FunPtr C_TranslateFunc
maybeFunc Ptr ()
data_ FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
destroyNotify
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetTranslateFuncMethodInfo
instance (signature ~ (Maybe (GLib.Callbacks.TranslateFunc) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetTranslateFuncMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetTranslateFunc

#endif

-- method OptionContext::set_translation_domain
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "OptionContext" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOptionContext" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the domain to use" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_context_set_translation_domain" g_option_context_set_translation_domain :: 
    Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
    CString ->                              -- domain : TBasicType TUTF8
    IO ()

-- | A convenience function to use @/gettext()/@ for translating
-- user-visible strings.
-- 
-- /Since: 2.12/
optionContextSetTranslationDomain ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionContext
    -- ^ /@context@/: a t'GI.GLib.Structs.OptionContext.OptionContext'
    -> T.Text
    -- ^ /@domain@/: the domain to use
    -> m ()
optionContextSetTranslationDomain :: OptionContext -> Text -> m ()
optionContextSetTranslationDomain OptionContext
context Text
domain = 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 OptionContext
context' <- OptionContext -> IO (Ptr OptionContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionContext
context
    Ptr CChar
domain' <- Text -> IO (Ptr CChar)
textToCString Text
domain
    Ptr OptionContext -> Ptr CChar -> IO ()
g_option_context_set_translation_domain Ptr OptionContext
context' Ptr CChar
domain'
    OptionContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionContext
context
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
domain'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data OptionContextSetTranslationDomainMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo OptionContextSetTranslationDomainMethodInfo OptionContext signature where
    overloadedMethod = optionContextSetTranslationDomain

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveOptionContextMethod (t :: Symbol) (o :: *) :: * where
    ResolveOptionContextMethod "addGroup" o = OptionContextAddGroupMethodInfo
    ResolveOptionContextMethod "addMainEntries" o = OptionContextAddMainEntriesMethodInfo
    ResolveOptionContextMethod "free" o = OptionContextFreeMethodInfo
    ResolveOptionContextMethod "parse" o = OptionContextParseMethodInfo
    ResolveOptionContextMethod "getDescription" o = OptionContextGetDescriptionMethodInfo
    ResolveOptionContextMethod "getHelp" o = OptionContextGetHelpMethodInfo
    ResolveOptionContextMethod "getHelpEnabled" o = OptionContextGetHelpEnabledMethodInfo
    ResolveOptionContextMethod "getIgnoreUnknownOptions" o = OptionContextGetIgnoreUnknownOptionsMethodInfo
    ResolveOptionContextMethod "getMainGroup" o = OptionContextGetMainGroupMethodInfo
    ResolveOptionContextMethod "getStrictPosix" o = OptionContextGetStrictPosixMethodInfo
    ResolveOptionContextMethod "getSummary" o = OptionContextGetSummaryMethodInfo
    ResolveOptionContextMethod "setDescription" o = OptionContextSetDescriptionMethodInfo
    ResolveOptionContextMethod "setHelpEnabled" o = OptionContextSetHelpEnabledMethodInfo
    ResolveOptionContextMethod "setIgnoreUnknownOptions" o = OptionContextSetIgnoreUnknownOptionsMethodInfo
    ResolveOptionContextMethod "setMainGroup" o = OptionContextSetMainGroupMethodInfo
    ResolveOptionContextMethod "setStrictPosix" o = OptionContextSetStrictPosixMethodInfo
    ResolveOptionContextMethod "setSummary" o = OptionContextSetSummaryMethodInfo
    ResolveOptionContextMethod "setTranslateFunc" o = OptionContextSetTranslateFuncMethodInfo
    ResolveOptionContextMethod "setTranslationDomain" o = OptionContextSetTranslationDomainMethodInfo
    ResolveOptionContextMethod l o = O.MethodResolutionFailed l o

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

#endif