{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.Wp.Structs.PropertiesItem
    ( 

-- * Exported types
    PropertiesItem(..)                      ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [ref]("GI.Wp.Structs.PropertiesItem#g:method:ref"), [unref]("GI.Wp.Structs.PropertiesItem#g:method:unref").
-- 
-- ==== Getters
-- [getKey]("GI.Wp.Structs.PropertiesItem#g:method:getKey"), [getValue]("GI.Wp.Structs.PropertiesItem#g:method:getValue").
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolvePropertiesItemMethod             ,
#endif

-- ** getKey #method:getKey#

#if defined(ENABLE_OVERLOADING)
    PropertiesItemGetKeyMethodInfo          ,
#endif
    propertiesItemGetKey                    ,


-- ** getValue #method:getValue#

#if defined(ENABLE_OVERLOADING)
    PropertiesItemGetValueMethodInfo        ,
#endif
    propertiesItemGetValue                  ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    PropertiesItemRefMethodInfo             ,
#endif
    propertiesItemRef                       ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    PropertiesItemUnrefMethodInfo           ,
#endif
    propertiesItemUnref                     ,




    ) 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.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)

#else

#endif

-- | Memory-managed wrapper type.
newtype PropertiesItem = PropertiesItem (SP.ManagedPtr PropertiesItem)
    deriving (Eq)

instance SP.ManagedPtrNewtype PropertiesItem where
    toManagedPtr (PropertiesItem p) = p

foreign import ccall "wp_properties_item_get_type" c_wp_properties_item_get_type :: 
    IO GType

type instance O.ParentTypes PropertiesItem = '[]
instance O.HasParentTypes PropertiesItem

instance B.Types.TypedObject PropertiesItem where
    glibType = c_wp_properties_item_get_type

instance B.Types.GBoxed PropertiesItem

-- | Convert t'PropertiesItem' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe PropertiesItem) where
    gvalueGType_ = c_wp_properties_item_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_boxed gv (FP.nullPtr :: FP.Ptr PropertiesItem)
    gvalueSet_ gv (P.Just obj) = B.ManagedPtr.withManagedPtr obj (B.GValue.set_boxed gv)
    gvalueGet_ gv = do
        ptr <- B.GValue.get_boxed gv :: IO (Ptr PropertiesItem)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newBoxed PropertiesItem ptr
        else return P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList PropertiesItem
type instance O.AttributeList PropertiesItem = PropertiesItemAttributeList
type PropertiesItemAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method PropertiesItem::get_key
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "PropertiesItem" }
--           , argCType = Just "WpPropertiesItem*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the item held by the GValue that was returned from the WpIterator of wp_properties_new_iterator()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_properties_item_get_key" wp_properties_item_get_key :: 
    Ptr PropertiesItem ->                   -- self : TInterface (Name {namespace = "Wp", name = "PropertiesItem"})
    IO CString

-- | Gets the key from a properties item.
-- 
-- /Since: 0.4.2/
propertiesItemGetKey ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PropertiesItem
    -- ^ /@self@/: the item held by the GValue that was returned from the WpIterator of 'GI.Wp.Structs.Properties.propertiesNewIterator'
    -> m T.Text
    -- ^ __Returns:__ the property key of the /@item@/
propertiesItemGetKey self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_properties_item_get_key self'
    checkUnexpectedReturnNULL "propertiesItemGetKey" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data PropertiesItemGetKeyMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.OverloadedMethod PropertiesItemGetKeyMethodInfo PropertiesItem signature where
    overloadedMethod = propertiesItemGetKey

instance O.OverloadedMethodInfo PropertiesItemGetKeyMethodInfo PropertiesItem where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.PropertiesItem.propertiesItemGetKey",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-PropertiesItem.html#v:propertiesItemGetKey"
        })


#endif

-- method PropertiesItem::get_value
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "PropertiesItem" }
--           , argCType = Just "WpPropertiesItem*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the item held by the GValue that was returned from the WpIterator of wp_properties_new_iterator()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_properties_item_get_value" wp_properties_item_get_value :: 
    Ptr PropertiesItem ->                   -- self : TInterface (Name {namespace = "Wp", name = "PropertiesItem"})
    IO CString

-- | Gets the value from a properties item.
-- 
-- /Since: 0.4.2/
propertiesItemGetValue ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PropertiesItem
    -- ^ /@self@/: the item held by the GValue that was returned from the WpIterator of 'GI.Wp.Structs.Properties.propertiesNewIterator'
    -> m T.Text
    -- ^ __Returns:__ the property value of the /@item@/
propertiesItemGetValue self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_properties_item_get_value self'
    checkUnexpectedReturnNULL "propertiesItemGetValue" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data PropertiesItemGetValueMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.OverloadedMethod PropertiesItemGetValueMethodInfo PropertiesItem signature where
    overloadedMethod = propertiesItemGetValue

instance O.OverloadedMethodInfo PropertiesItemGetValueMethodInfo PropertiesItem where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.PropertiesItem.propertiesItemGetValue",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-PropertiesItem.html#v:propertiesItemGetValue"
        })


#endif

-- method PropertiesItem::ref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "PropertiesItem" }
--           , argCType = Just "WpPropertiesItem*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a properties item object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Wp" , name = "PropertiesItem" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_properties_item_ref" wp_properties_item_ref :: 
    Ptr PropertiesItem ->                   -- self : TInterface (Name {namespace = "Wp", name = "PropertiesItem"})
    IO (Ptr PropertiesItem)

-- | Increases the reference count of a properties item object.
-- 
-- /Since: 0.4.2/
propertiesItemRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PropertiesItem
    -- ^ /@self@/: a properties item object
    -> m PropertiesItem
    -- ^ __Returns:__ /@self@/ with an additional reference count on it
propertiesItemRef self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_properties_item_ref self'
    checkUnexpectedReturnNULL "propertiesItemRef" result
    result' <- (wrapBoxed PropertiesItem) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data PropertiesItemRefMethodInfo
instance (signature ~ (m PropertiesItem), MonadIO m) => O.OverloadedMethod PropertiesItemRefMethodInfo PropertiesItem signature where
    overloadedMethod = propertiesItemRef

instance O.OverloadedMethodInfo PropertiesItemRefMethodInfo PropertiesItem where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.PropertiesItem.propertiesItemRef",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-PropertiesItem.html#v:propertiesItemRef"
        })


#endif

-- method PropertiesItem::unref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "PropertiesItem" }
--           , argCType = Just "WpPropertiesItem*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a properties item object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_properties_item_unref" wp_properties_item_unref :: 
    Ptr PropertiesItem ->                   -- self : TInterface (Name {namespace = "Wp", name = "PropertiesItem"})
    IO ()

-- | Decreases the reference count on /@self@/ and frees it when the ref count reaches zero.
-- 
-- /Since: 0.4.2/
propertiesItemUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PropertiesItem
    -- ^ /@self@/: a properties item object
    -> m ()
propertiesItemUnref self = liftIO $ do
    self' <- B.ManagedPtr.disownBoxed self
    wp_properties_item_unref self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data PropertiesItemUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod PropertiesItemUnrefMethodInfo PropertiesItem signature where
    overloadedMethod = propertiesItemUnref

instance O.OverloadedMethodInfo PropertiesItemUnrefMethodInfo PropertiesItem where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.PropertiesItem.propertiesItemUnref",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Structs-PropertiesItem.html#v:propertiesItemUnref"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolvePropertiesItemMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolvePropertiesItemMethod "ref" o = PropertiesItemRefMethodInfo
    ResolvePropertiesItemMethod "unref" o = PropertiesItemUnrefMethodInfo
    ResolvePropertiesItemMethod "getKey" o = PropertiesItemGetKeyMethodInfo
    ResolvePropertiesItemMethod "getValue" o = PropertiesItemGetValueMethodInfo
    ResolvePropertiesItemMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolvePropertiesItemMethod t PropertiesItem, O.OverloadedMethod info PropertiesItem p, R.HasField t PropertiesItem p) => R.HasField t PropertiesItem p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolvePropertiesItemMethod t PropertiesItem, O.OverloadedMethodInfo info PropertiesItem) => OL.IsLabel t (O.MethodProxy info PropertiesItem) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif


