{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

The 'GI.Pango.Structs.EngineInfo.EngineInfo' structure contains information about a particular
engine. It contains the following fields:
-}

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

module GI.Pango.Structs.EngineInfo
    (

-- * Exported types
    EngineInfo(..)                          ,
    newZeroEngineInfo                       ,
    noEngineInfo                            ,


 -- * Properties
-- ** engineType #attr:engineType#
{- | a string identifying the engine type.
-}
    clearEngineInfoEngineType               ,
#if ENABLE_OVERLOADING
    engineInfo_engineType                   ,
#endif
    getEngineInfoEngineType                 ,
    setEngineInfoEngineType                 ,


-- ** id #attr:id#
{- | a unique string ID for the engine.
-}
    clearEngineInfoId                       ,
#if ENABLE_OVERLOADING
    engineInfo_id                           ,
#endif
    getEngineInfoId                         ,
    setEngineInfoId                         ,


-- ** nScripts #attr:nScripts#
{- | number of items in /@scripts@/.
-}
#if ENABLE_OVERLOADING
    engineInfo_nScripts                     ,
#endif
    getEngineInfoNScripts                   ,
    setEngineInfoNScripts                   ,


-- ** renderType #attr:renderType#
{- | a string identifying the render type.
-}
    clearEngineInfoRenderType               ,
#if ENABLE_OVERLOADING
    engineInfo_renderType                   ,
#endif
    getEngineInfoRenderType                 ,
    setEngineInfoRenderType                 ,


-- ** scripts #attr:scripts#
{- | array of scripts this engine supports.
-}
    clearEngineInfoScripts                  ,
#if ENABLE_OVERLOADING
    engineInfo_scripts                      ,
#endif
    getEngineInfoScripts                    ,
    setEngineInfoScripts                    ,




    ) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.Pango.Structs.EngineScriptInfo as Pango.EngineScriptInfo

-- | Memory-managed wrapper type.
newtype EngineInfo = EngineInfo (ManagedPtr EngineInfo)
instance WrappedPtr EngineInfo where
    wrappedPtrCalloc = callocBytes 40
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 40 >=> wrapPtr EngineInfo)
    wrappedPtrFree = Just ptr_to_g_free

-- | Construct a `EngineInfo` struct initialized to zero.
newZeroEngineInfo :: MonadIO m => m EngineInfo
newZeroEngineInfo = liftIO $ wrappedPtrCalloc >>= wrapPtr EngineInfo

instance tag ~ 'AttrSet => Constructible EngineInfo tag where
    new _ attrs = do
        o <- newZeroEngineInfo
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `EngineInfo`.
noEngineInfo :: Maybe EngineInfo
noEngineInfo = Nothing

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

@
'Data.GI.Base.Attributes.get' engineInfo #id
@
-}
getEngineInfoId :: MonadIO m => EngineInfo -> m (Maybe T.Text)
getEngineInfoId s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CString
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- cstringToText val'
        return val''
    return result

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

@
'Data.GI.Base.Attributes.set' engineInfo [ #id 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEngineInfoId :: MonadIO m => EngineInfo -> CString -> m ()
setEngineInfoId s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: CString)

{- |
Set the value of the “@id@” 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' #id
@
-}
clearEngineInfoId :: MonadIO m => EngineInfo -> m ()
clearEngineInfoId s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data EngineInfoIdFieldInfo
instance AttrInfo EngineInfoIdFieldInfo where
    type AttrAllowedOps EngineInfoIdFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EngineInfoIdFieldInfo = (~) CString
    type AttrBaseTypeConstraint EngineInfoIdFieldInfo = (~) EngineInfo
    type AttrGetType EngineInfoIdFieldInfo = Maybe T.Text
    type AttrLabel EngineInfoIdFieldInfo = "id"
    type AttrOrigin EngineInfoIdFieldInfo = EngineInfo
    attrGet _ = getEngineInfoId
    attrSet _ = setEngineInfoId
    attrConstruct = undefined
    attrClear _ = clearEngineInfoId

engineInfo_id :: AttrLabelProxy "id"
engineInfo_id = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' engineInfo #engineType
@
-}
getEngineInfoEngineType :: MonadIO m => EngineInfo -> m (Maybe T.Text)
getEngineInfoEngineType s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- cstringToText val'
        return val''
    return result

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

@
'Data.GI.Base.Attributes.set' engineInfo [ #engineType 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEngineInfoEngineType :: MonadIO m => EngineInfo -> CString -> m ()
setEngineInfoEngineType s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: CString)

{- |
Set the value of the “@engine_type@” 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' #engineType
@
-}
clearEngineInfoEngineType :: MonadIO m => EngineInfo -> m ()
clearEngineInfoEngineType s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data EngineInfoEngineTypeFieldInfo
instance AttrInfo EngineInfoEngineTypeFieldInfo where
    type AttrAllowedOps EngineInfoEngineTypeFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EngineInfoEngineTypeFieldInfo = (~) CString
    type AttrBaseTypeConstraint EngineInfoEngineTypeFieldInfo = (~) EngineInfo
    type AttrGetType EngineInfoEngineTypeFieldInfo = Maybe T.Text
    type AttrLabel EngineInfoEngineTypeFieldInfo = "engine_type"
    type AttrOrigin EngineInfoEngineTypeFieldInfo = EngineInfo
    attrGet _ = getEngineInfoEngineType
    attrSet _ = setEngineInfoEngineType
    attrConstruct = undefined
    attrClear _ = clearEngineInfoEngineType

engineInfo_engineType :: AttrLabelProxy "engineType"
engineInfo_engineType = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' engineInfo #renderType
@
-}
getEngineInfoRenderType :: MonadIO m => EngineInfo -> m (Maybe T.Text)
getEngineInfoRenderType s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO CString
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- cstringToText val'
        return val''
    return result

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

@
'Data.GI.Base.Attributes.set' engineInfo [ #renderType 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEngineInfoRenderType :: MonadIO m => EngineInfo -> CString -> m ()
setEngineInfoRenderType s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: CString)

{- |
Set the value of the “@render_type@” 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' #renderType
@
-}
clearEngineInfoRenderType :: MonadIO m => EngineInfo -> m ()
clearEngineInfoRenderType s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data EngineInfoRenderTypeFieldInfo
instance AttrInfo EngineInfoRenderTypeFieldInfo where
    type AttrAllowedOps EngineInfoRenderTypeFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EngineInfoRenderTypeFieldInfo = (~) CString
    type AttrBaseTypeConstraint EngineInfoRenderTypeFieldInfo = (~) EngineInfo
    type AttrGetType EngineInfoRenderTypeFieldInfo = Maybe T.Text
    type AttrLabel EngineInfoRenderTypeFieldInfo = "render_type"
    type AttrOrigin EngineInfoRenderTypeFieldInfo = EngineInfo
    attrGet _ = getEngineInfoRenderType
    attrSet _ = setEngineInfoRenderType
    attrConstruct = undefined
    attrClear _ = clearEngineInfoRenderType

engineInfo_renderType :: AttrLabelProxy "renderType"
engineInfo_renderType = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' engineInfo #scripts
@
-}
getEngineInfoScripts :: MonadIO m => EngineInfo -> m (Maybe Pango.EngineScriptInfo.EngineScriptInfo)
getEngineInfoScripts s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO (Ptr Pango.EngineScriptInfo.EngineScriptInfo)
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- (newPtr Pango.EngineScriptInfo.EngineScriptInfo) val'
        return val''
    return result

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

@
'Data.GI.Base.Attributes.set' engineInfo [ #scripts 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEngineInfoScripts :: MonadIO m => EngineInfo -> Ptr Pango.EngineScriptInfo.EngineScriptInfo -> m ()
setEngineInfoScripts s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 24) (val :: Ptr Pango.EngineScriptInfo.EngineScriptInfo)

{- |
Set the value of the “@scripts@” 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' #scripts
@
-}
clearEngineInfoScripts :: MonadIO m => EngineInfo -> m ()
clearEngineInfoScripts s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 24) (FP.nullPtr :: Ptr Pango.EngineScriptInfo.EngineScriptInfo)

#if ENABLE_OVERLOADING
data EngineInfoScriptsFieldInfo
instance AttrInfo EngineInfoScriptsFieldInfo where
    type AttrAllowedOps EngineInfoScriptsFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EngineInfoScriptsFieldInfo = (~) (Ptr Pango.EngineScriptInfo.EngineScriptInfo)
    type AttrBaseTypeConstraint EngineInfoScriptsFieldInfo = (~) EngineInfo
    type AttrGetType EngineInfoScriptsFieldInfo = Maybe Pango.EngineScriptInfo.EngineScriptInfo
    type AttrLabel EngineInfoScriptsFieldInfo = "scripts"
    type AttrOrigin EngineInfoScriptsFieldInfo = EngineInfo
    attrGet _ = getEngineInfoScripts
    attrSet _ = setEngineInfoScripts
    attrConstruct = undefined
    attrClear _ = clearEngineInfoScripts

engineInfo_scripts :: AttrLabelProxy "scripts"
engineInfo_scripts = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' engineInfo #nScripts
@
-}
getEngineInfoNScripts :: MonadIO m => EngineInfo -> m Int32
getEngineInfoNScripts s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO Int32
    return val

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

@
'Data.GI.Base.Attributes.set' engineInfo [ #nScripts 'Data.GI.Base.Attributes.:=' value ]
@
-}
setEngineInfoNScripts :: MonadIO m => EngineInfo -> Int32 -> m ()
setEngineInfoNScripts s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 32) (val :: Int32)

#if ENABLE_OVERLOADING
data EngineInfoNScriptsFieldInfo
instance AttrInfo EngineInfoNScriptsFieldInfo where
    type AttrAllowedOps EngineInfoNScriptsFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EngineInfoNScriptsFieldInfo = (~) Int32
    type AttrBaseTypeConstraint EngineInfoNScriptsFieldInfo = (~) EngineInfo
    type AttrGetType EngineInfoNScriptsFieldInfo = Int32
    type AttrLabel EngineInfoNScriptsFieldInfo = "n_scripts"
    type AttrOrigin EngineInfoNScriptsFieldInfo = EngineInfo
    attrGet _ = getEngineInfoNScripts
    attrSet _ = setEngineInfoNScripts
    attrConstruct = undefined
    attrClear _ = undefined

engineInfo_nScripts :: AttrLabelProxy "nScripts"
engineInfo_nScripts = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList EngineInfo
type instance O.AttributeList EngineInfo = EngineInfoAttributeList
type EngineInfoAttributeList = ('[ '("id", EngineInfoIdFieldInfo), '("engineType", EngineInfoEngineTypeFieldInfo), '("renderType", EngineInfoRenderTypeFieldInfo), '("scripts", EngineInfoScriptsFieldInfo), '("nScripts", EngineInfoNScriptsFieldInfo)] :: [(Symbol, *)])
#endif

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

instance (info ~ ResolveEngineInfoMethod t EngineInfo, O.MethodInfo info EngineInfo p) => OL.IsLabel t (EngineInfo -> 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