{- |
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 GOptionEntry struct defines a single option. To have an effect, they
must be added to a 'GI.GLib.Structs.OptionGroup.OptionGroup' with 'GI.GLib.Structs.OptionContext.optionContextAddMainEntries'
or 'GI.GLib.Structs.OptionGroup.optionGroupAddEntries'.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.GLib.Structs.OptionEntry
    ( 

-- * Exported types
    OptionEntry(..)                         ,
    newZeroOptionEntry                      ,
    noOptionEntry                           ,


 -- * Properties
-- ** arg #attr:arg#
{- | The type of the option, as a 'GI.GLib.Enums.OptionArg'
-}
    getOptionEntryArg                       ,
#if ENABLE_OVERLOADING
    optionEntry_arg                         ,
#endif
    setOptionEntryArg                       ,


-- ** argData #attr:argData#
{- | If the /@arg@/ type is 'GI.GLib.Enums.OptionArgCallback', then /@argData@/
    must point to a 'GI.GLib.Callbacks.OptionArgFunc' callback function, which will be
    called to handle the extra argument. Otherwise, /@argData@/ is a
    pointer to a location to store the value, the required type of
    the location depends on the /@arg@/ type:
    - 'GI.GLib.Enums.OptionArgNone': @/gboolean/@
    - 'GI.GLib.Enums.OptionArgString': @/gchar/@*
    - 'GI.GLib.Enums.OptionArgInt': @/gint/@
    - 'GI.GLib.Enums.OptionArgFilename': @/gchar/@*
    - 'GI.GLib.Enums.OptionArgStringArray': @/gchar/@**
    - 'GI.GLib.Enums.OptionArgFilenameArray': @/gchar/@**
    - 'GI.GLib.Enums.OptionArgDouble': @/gdouble/@
    If /@arg@/ type is 'GI.GLib.Enums.OptionArgString' or 'GI.GLib.Enums.OptionArgFilename',
    the location will contain a newly allocated string if the option
    was given. That string needs to be freed by the callee using 'GI.GLib.Functions.free'.
    Likewise if /@arg@/ type is 'GI.GLib.Enums.OptionArgStringArray' or
    'GI.GLib.Enums.OptionArgFilenameArray', the data should be freed using 'GI.GLib.Functions.strfreev'.
-}
    clearOptionEntryArgData                 ,
    getOptionEntryArgData                   ,
#if ENABLE_OVERLOADING
    optionEntry_argData                     ,
#endif
    setOptionEntryArgData                   ,


-- ** argDescription #attr:argDescription#
{- | The placeholder to use for the extra argument parsed
    by the option in @--help@ output. The /@argDescription@/ is translated
    using the /@translateFunc@/ of the group, see
    'GI.GLib.Structs.OptionGroup.optionGroupSetTranslationDomain'.
-}
    clearOptionEntryArgDescription          ,
    getOptionEntryArgDescription            ,
#if ENABLE_OVERLOADING
    optionEntry_argDescription              ,
#endif
    setOptionEntryArgDescription            ,


-- ** description #attr:description#
{- | the description for the option in @--help@
    output. The /@description@/ is translated using the /@translateFunc@/
    of the group, see 'GI.GLib.Structs.OptionGroup.optionGroupSetTranslationDomain'.
-}
    clearOptionEntryDescription             ,
    getOptionEntryDescription               ,
#if ENABLE_OVERLOADING
    optionEntry_description                 ,
#endif
    setOptionEntryDescription               ,


-- ** flags #attr:flags#
{- | Flags from 'GI.GLib.Flags.OptionFlags'
-}
    getOptionEntryFlags                     ,
#if ENABLE_OVERLOADING
    optionEntry_flags                       ,
#endif
    setOptionEntryFlags                     ,


-- ** longName #attr:longName#
{- | The long name of an option can be used to specify it
    in a commandline as @--long_name@. Every option must have a
    long name. To resolve conflicts if multiple option groups contain
    the same long name, it is also possible to specify the option as
    @--groupname-long_name@.
-}
    clearOptionEntryLongName                ,
    getOptionEntryLongName                  ,
#if ENABLE_OVERLOADING
    optionEntry_longName                    ,
#endif
    setOptionEntryLongName                  ,


-- ** shortName #attr:shortName#
{- | If an option has a short name, it can be specified
    @-short_name@ in a commandline. /@shortName@/ must be  a printable
    ASCII character different from \'-\', or zero if the option has no
    short name.
-}
    getOptionEntryShortName                 ,
#if ENABLE_OVERLOADING
    optionEntry_shortName                   ,
#endif
    setOptionEntryShortName                 ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.GLib.Enums as GLib.Enums

-- | Memory-managed wrapper type.
newtype OptionEntry = OptionEntry (ManagedPtr OptionEntry)
instance WrappedPtr OptionEntry where
    wrappedPtrCalloc :: IO (Ptr OptionEntry)
wrappedPtrCalloc = Int -> IO (Ptr OptionEntry)
forall a. Int -> IO (Ptr a)
callocBytes 48
    wrappedPtrCopy :: OptionEntry -> IO OptionEntry
wrappedPtrCopy = \p :: OptionEntry
p -> OptionEntry
-> (Ptr OptionEntry -> IO OptionEntry) -> IO OptionEntry
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
p (Int -> Ptr OptionEntry -> IO (Ptr OptionEntry)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 48 (Ptr OptionEntry -> IO (Ptr OptionEntry))
-> (Ptr OptionEntry -> IO OptionEntry)
-> Ptr OptionEntry
-> IO OptionEntry
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr OptionEntry -> OptionEntry)
-> Ptr OptionEntry -> IO OptionEntry
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr OptionEntry -> OptionEntry
OptionEntry)
    wrappedPtrFree :: Maybe (FunPtr (Ptr OptionEntry -> IO ()))
wrappedPtrFree = FunPtr (Ptr OptionEntry -> IO ())
-> Maybe (FunPtr (Ptr OptionEntry -> IO ()))
forall a. a -> Maybe a
Just FunPtr (Ptr OptionEntry -> IO ())
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | Construct a `OptionEntry` struct initialized to zero.
newZeroOptionEntry :: MonadIO m => m OptionEntry
newZeroOptionEntry :: m OptionEntry
newZeroOptionEntry = IO OptionEntry -> m OptionEntry
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OptionEntry -> m OptionEntry)
-> IO OptionEntry -> m OptionEntry
forall a b. (a -> b) -> a -> b
$ IO (Ptr OptionEntry)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr OptionEntry)
-> (Ptr OptionEntry -> IO OptionEntry) -> IO OptionEntry
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr OptionEntry -> OptionEntry)
-> Ptr OptionEntry -> IO OptionEntry
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr OptionEntry -> OptionEntry
OptionEntry

instance tag ~ 'AttrSet => Constructible OptionEntry tag where
    new :: (ManagedPtr OptionEntry -> OptionEntry)
-> [AttrOp OptionEntry tag] -> m OptionEntry
new _ attrs :: [AttrOp OptionEntry tag]
attrs = do
        OptionEntry
o <- m OptionEntry
forall (m :: * -> *). MonadIO m => m OptionEntry
newZeroOptionEntry
        OptionEntry -> [AttrOp OptionEntry 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set OptionEntry
o [AttrOp OptionEntry tag]
[AttrOp OptionEntry 'AttrSet]
attrs
        OptionEntry -> m OptionEntry
forall (m :: * -> *) a. Monad m => a -> m a
return OptionEntry
o


-- | A convenience alias for `Nothing` :: `Maybe` `OptionEntry`.
noOptionEntry :: Maybe OptionEntry
noOptionEntry :: Maybe OptionEntry
noOptionEntry = Maybe OptionEntry
forall a. Maybe a
Nothing

{- |
Get the value of the “@long_name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #longName
@
-}
getOptionEntryLongName :: MonadIO m => OptionEntry -> m (Maybe T.Text)
getOptionEntryLongName :: OptionEntry -> m (Maybe Text)
getOptionEntryLongName s :: OptionEntry
s = 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
$ OptionEntry
-> (Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

{- |
Set the value of the “@long_name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #longName 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryLongName :: MonadIO m => OptionEntry -> CString -> m ()
setOptionEntryLongName :: OptionEntry -> CString -> m ()
setOptionEntryLongName s :: OptionEntry
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
val :: CString)

{- |
Set the value of the “@long_name@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #longName
@
-}
clearOptionEntryLongName :: MonadIO m => OptionEntry -> m ()
clearOptionEntryLongName :: OptionEntry -> m ()
clearOptionEntryLongName s :: OptionEntry
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data OptionEntryLongNameFieldInfo
instance AttrInfo OptionEntryLongNameFieldInfo where
    type AttrAllowedOps OptionEntryLongNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint OptionEntryLongNameFieldInfo = (~) CString
    type AttrBaseTypeConstraint OptionEntryLongNameFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryLongNameFieldInfo = Maybe T.Text
    type AttrLabel OptionEntryLongNameFieldInfo = "long_name"
    type AttrOrigin OptionEntryLongNameFieldInfo = OptionEntry
    attrGet _ = getOptionEntryLongName
    attrSet _ = setOptionEntryLongName
    attrConstruct = undefined
    attrClear _ = clearOptionEntryLongName

optionEntry_longName :: AttrLabelProxy "longName"
optionEntry_longName = AttrLabelProxy

#endif


{- |
Get the value of the “@short_name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #shortName
@
-}
getOptionEntryShortName :: MonadIO m => OptionEntry -> m Int8
getOptionEntryShortName :: OptionEntry -> m Int8
getOptionEntryShortName s :: OptionEntry
s = IO Int8 -> m Int8
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int8 -> m Int8) -> IO Int8 -> m Int8
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO Int8) -> IO Int8
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO Int8) -> IO Int8)
-> (Ptr OptionEntry -> IO Int8) -> IO Int8
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Int8
val <- Ptr Int8 -> IO Int8
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr Int8
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) :: IO Int8
    Int8 -> IO Int8
forall (m :: * -> *) a. Monad m => a -> m a
return Int8
val

{- |
Set the value of the “@short_name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #shortName 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryShortName :: MonadIO m => OptionEntry -> Int8 -> m ()
setOptionEntryShortName :: OptionEntry -> Int8 -> m ()
setOptionEntryShortName s :: OptionEntry
s val :: Int8
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr Int8 -> Int8 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr Int8
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (Int8
val :: Int8)

#if ENABLE_OVERLOADING
data OptionEntryShortNameFieldInfo
instance AttrInfo OptionEntryShortNameFieldInfo where
    type AttrAllowedOps OptionEntryShortNameFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint OptionEntryShortNameFieldInfo = (~) Int8
    type AttrBaseTypeConstraint OptionEntryShortNameFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryShortNameFieldInfo = Int8
    type AttrLabel OptionEntryShortNameFieldInfo = "short_name"
    type AttrOrigin OptionEntryShortNameFieldInfo = OptionEntry
    attrGet _ = getOptionEntryShortName
    attrSet _ = setOptionEntryShortName
    attrConstruct = undefined
    attrClear _ = undefined

optionEntry_shortName :: AttrLabelProxy "shortName"
optionEntry_shortName = AttrLabelProxy

#endif


{- |
Get the value of the “@flags@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #flags
@
-}
getOptionEntryFlags :: MonadIO m => OptionEntry -> m Int32
getOptionEntryFlags :: OptionEntry -> m Int32
getOptionEntryFlags s :: OptionEntry
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO Int32) -> IO Int32)
-> (Ptr OptionEntry -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12) :: IO Int32
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

{- |
Set the value of the “@flags@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #flags 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryFlags :: MonadIO m => OptionEntry -> Int32 -> m ()
setOptionEntryFlags :: OptionEntry -> Int32 -> m ()
setOptionEntryFlags s :: OptionEntry
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12) (Int32
val :: Int32)

#if ENABLE_OVERLOADING
data OptionEntryFlagsFieldInfo
instance AttrInfo OptionEntryFlagsFieldInfo where
    type AttrAllowedOps OptionEntryFlagsFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint OptionEntryFlagsFieldInfo = (~) Int32
    type AttrBaseTypeConstraint OptionEntryFlagsFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryFlagsFieldInfo = Int32
    type AttrLabel OptionEntryFlagsFieldInfo = "flags"
    type AttrOrigin OptionEntryFlagsFieldInfo = OptionEntry
    attrGet _ = getOptionEntryFlags
    attrSet _ = setOptionEntryFlags
    attrConstruct = undefined
    attrClear _ = undefined

optionEntry_flags :: AttrLabelProxy "flags"
optionEntry_flags = AttrLabelProxy

#endif


{- |
Get the value of the “@arg@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #arg
@
-}
getOptionEntryArg :: MonadIO m => OptionEntry -> m GLib.Enums.OptionArg
getOptionEntryArg :: OptionEntry -> m OptionArg
getOptionEntryArg s :: OptionEntry
s = IO OptionArg -> m OptionArg
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OptionArg -> m OptionArg) -> IO OptionArg -> m OptionArg
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO OptionArg) -> IO OptionArg
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO OptionArg) -> IO OptionArg)
-> (Ptr OptionEntry -> IO OptionArg) -> IO OptionArg
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    CUInt
val <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CUInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO CUInt
    let val' :: OptionArg
val' = (Int -> OptionArg
forall a. Enum a => Int -> a
toEnum (Int -> OptionArg) -> (CUInt -> Int) -> CUInt -> OptionArg
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
val
    OptionArg -> IO OptionArg
forall (m :: * -> *) a. Monad m => a -> m a
return OptionArg
val'

{- |
Set the value of the “@arg@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #arg 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryArg :: MonadIO m => OptionEntry -> GLib.Enums.OptionArg -> m ()
setOptionEntryArg :: OptionEntry -> OptionArg -> m ()
setOptionEntryArg s :: OptionEntry
s val :: OptionArg
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    let val' :: CUInt
val' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (OptionArg -> Int) -> OptionArg -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OptionArg -> Int
forall a. Enum a => a -> Int
fromEnum) OptionArg
val
    Ptr CUInt -> CUInt -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CUInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (CUInt
val' :: CUInt)

#if ENABLE_OVERLOADING
data OptionEntryArgFieldInfo
instance AttrInfo OptionEntryArgFieldInfo where
    type AttrAllowedOps OptionEntryArgFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint OptionEntryArgFieldInfo = (~) GLib.Enums.OptionArg
    type AttrBaseTypeConstraint OptionEntryArgFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryArgFieldInfo = GLib.Enums.OptionArg
    type AttrLabel OptionEntryArgFieldInfo = "arg"
    type AttrOrigin OptionEntryArgFieldInfo = OptionEntry
    attrGet _ = getOptionEntryArg
    attrSet _ = setOptionEntryArg
    attrConstruct = undefined
    attrClear _ = undefined

optionEntry_arg :: AttrLabelProxy "arg"
optionEntry_arg = AttrLabelProxy

#endif


{- |
Get the value of the “@arg_data@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #argData
@
-}
getOptionEntryArgData :: MonadIO m => OptionEntry -> m (Ptr ())
getOptionEntryArgData :: OptionEntry -> m (Ptr ())
getOptionEntryArgData s :: OptionEntry
s = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO (Ptr ())) -> IO (Ptr ())
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr OptionEntry -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr ()
val <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) :: IO (Ptr ())
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
val

{- |
Set the value of the “@arg_data@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #argData 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryArgData :: MonadIO m => OptionEntry -> Ptr () -> m ()
setOptionEntryArgData :: OptionEntry -> Ptr () -> m ()
setOptionEntryArgData s :: OptionEntry
s val :: Ptr ()
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) (Ptr ()
val :: Ptr ())

{- |
Set the value of the “@arg_data@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #argData
@
-}
clearOptionEntryArgData :: MonadIO m => OptionEntry -> m ()
clearOptionEntryArgData :: OptionEntry -> m ()
clearOptionEntryArgData s :: OptionEntry
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) (Ptr ()
forall a. Ptr a
FP.nullPtr :: Ptr ())

#if ENABLE_OVERLOADING
data OptionEntryArgDataFieldInfo
instance AttrInfo OptionEntryArgDataFieldInfo where
    type AttrAllowedOps OptionEntryArgDataFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint OptionEntryArgDataFieldInfo = (~) (Ptr ())
    type AttrBaseTypeConstraint OptionEntryArgDataFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryArgDataFieldInfo = Ptr ()
    type AttrLabel OptionEntryArgDataFieldInfo = "arg_data"
    type AttrOrigin OptionEntryArgDataFieldInfo = OptionEntry
    attrGet _ = getOptionEntryArgData
    attrSet _ = setOptionEntryArgData
    attrConstruct = undefined
    attrClear _ = clearOptionEntryArgData

optionEntry_argData :: AttrLabelProxy "argData"
optionEntry_argData = AttrLabelProxy

#endif


{- |
Get the value of the “@description@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #description
@
-}
getOptionEntryDescription :: MonadIO m => OptionEntry -> m (Maybe T.Text)
getOptionEntryDescription :: OptionEntry -> m (Maybe Text)
getOptionEntryDescription s :: OptionEntry
s = 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
$ OptionEntry
-> (Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

{- |
Set the value of the “@description@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #description 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryDescription :: MonadIO m => OptionEntry -> CString -> m ()
setOptionEntryDescription :: OptionEntry -> CString -> m ()
setOptionEntryDescription s :: OptionEntry
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32) (CString
val :: CString)

{- |
Set the value of the “@description@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #description
@
-}
clearOptionEntryDescription :: MonadIO m => OptionEntry -> m ()
clearOptionEntryDescription :: OptionEntry -> m ()
clearOptionEntryDescription s :: OptionEntry
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data OptionEntryDescriptionFieldInfo
instance AttrInfo OptionEntryDescriptionFieldInfo where
    type AttrAllowedOps OptionEntryDescriptionFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint OptionEntryDescriptionFieldInfo = (~) CString
    type AttrBaseTypeConstraint OptionEntryDescriptionFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryDescriptionFieldInfo = Maybe T.Text
    type AttrLabel OptionEntryDescriptionFieldInfo = "description"
    type AttrOrigin OptionEntryDescriptionFieldInfo = OptionEntry
    attrGet _ = getOptionEntryDescription
    attrSet _ = setOptionEntryDescription
    attrConstruct = undefined
    attrClear _ = clearOptionEntryDescription

optionEntry_description :: AttrLabelProxy "description"
optionEntry_description = AttrLabelProxy

#endif


{- |
Get the value of the “@arg_description@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' optionEntry #argDescription
@
-}
getOptionEntryArgDescription :: MonadIO m => OptionEntry -> m (Maybe T.Text)
getOptionEntryArgDescription :: OptionEntry -> m (Maybe Text)
getOptionEntryArgDescription s :: OptionEntry
s = 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
$ OptionEntry
-> (Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr OptionEntry -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

{- |
Set the value of the “@arg_description@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' optionEntry [ #argDescription 'Data.GI.Base.Attributes.:=' value ]
@
-}
setOptionEntryArgDescription :: MonadIO m => OptionEntry -> CString -> m ()
setOptionEntryArgDescription :: OptionEntry -> CString -> m ()
setOptionEntryArgDescription s :: OptionEntry
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40) (CString
val :: CString)

{- |
Set the value of the “@arg_description@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #argDescription
@
-}
clearOptionEntryArgDescription :: MonadIO m => OptionEntry -> m ()
clearOptionEntryArgDescription :: OptionEntry -> m ()
clearOptionEntryArgDescription s :: OptionEntry
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ OptionEntry -> (Ptr OptionEntry -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr OptionEntry
s ((Ptr OptionEntry -> IO ()) -> IO ())
-> (Ptr OptionEntry -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr OptionEntry
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr OptionEntry
ptr Ptr OptionEntry -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data OptionEntryArgDescriptionFieldInfo
instance AttrInfo OptionEntryArgDescriptionFieldInfo where
    type AttrAllowedOps OptionEntryArgDescriptionFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint OptionEntryArgDescriptionFieldInfo = (~) CString
    type AttrBaseTypeConstraint OptionEntryArgDescriptionFieldInfo = (~) OptionEntry
    type AttrGetType OptionEntryArgDescriptionFieldInfo = Maybe T.Text
    type AttrLabel OptionEntryArgDescriptionFieldInfo = "arg_description"
    type AttrOrigin OptionEntryArgDescriptionFieldInfo = OptionEntry
    attrGet _ = getOptionEntryArgDescription
    attrSet _ = setOptionEntryArgDescription
    attrConstruct = undefined
    attrClear _ = clearOptionEntryArgDescription

optionEntry_argDescription :: AttrLabelProxy "argDescription"
optionEntry_argDescription = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList OptionEntry
type instance O.AttributeList OptionEntry = OptionEntryAttributeList
type OptionEntryAttributeList = ('[ '("longName", OptionEntryLongNameFieldInfo), '("shortName", OptionEntryShortNameFieldInfo), '("flags", OptionEntryFlagsFieldInfo), '("arg", OptionEntryArgFieldInfo), '("argData", OptionEntryArgDataFieldInfo), '("description", OptionEntryDescriptionFieldInfo), '("argDescription", OptionEntryArgDescriptionFieldInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
type family ResolveOptionEntryMethod (t :: Symbol) (o :: *) :: * where
    ResolveOptionEntryMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveOptionEntryMethod t OptionEntry, O.MethodInfo info OptionEntry p) => O.IsLabel t (OptionEntry -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif