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

    Any of the fields in 'GI.GLib.Structs.MarkupParser.MarkupParser' can be 'Nothing', in which case they
    will be ignored. Except for the /@error@/ function, any of these callbacks
    can set an error; in particular the 'GI.GLib.Enums.MarkupErrorUnknownElement',
    'GI.GLib.Enums.MarkupErrorUnknownAttribute', and 'GI.GLib.Enums.MarkupErrorInvalidContent'
    errors are intended to be set from these callbacks. If you set an error
    from a callback, 'GI.GLib.Structs.MarkupParseContext.markupParseContextParse' will report that error
    back to its caller.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.GLib.Structs.MarkupParser
        (

    -- * Exported types
        MarkupParser(..)                        ,
        newZeroMarkupParser                     ,
        noMarkupParser                          ,

     -- * Properties
    -- ** endElement #attr:endElement#
    {- | /No description available in the introspection data./
    -}
        clearMarkupParserEndElement             ,
        getMarkupParserEndElement               ,
    #if ENABLE_OVERLOADING
        markupParser_endElement                 ,
    #endif
        setMarkupParserEndElement               ,

    -- ** error #attr:error#
    {- | /No description available in the introspection data./
    -}
        clearMarkupParserError                  ,
        getMarkupParserError                    ,
    #if ENABLE_OVERLOADING
        markupParser_error                      ,
    #endif
        setMarkupParserError                    ,

    -- ** passthrough #attr:passthrough#
    {- | /No description available in the introspection data./
    -}
        clearMarkupParserPassthrough            ,
        getMarkupParserPassthrough              ,
    #if ENABLE_OVERLOADING
        markupParser_passthrough                ,
    #endif
        setMarkupParserPassthrough              ,

    -- ** startElement #attr:startElement#
    {- | /No description available in the introspection data./
    -}
        clearMarkupParserStartElement           ,
        getMarkupParserStartElement             ,
    #if ENABLE_OVERLOADING
        markupParser_startElement               ,
    #endif
        setMarkupParserStartElement             ,

    -- ** text #attr:text#
    {- | /No description available in the introspection data./
    -}
        clearMarkupParserText                   ,
        getMarkupParserText                     ,
    #if ENABLE_OVERLOADING
        markupParser_text                       ,
    #endif
        setMarkupParserText                     ,

        ) 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 qualified GI.GLib.Callbacks as GLib.Callbacks

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

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

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

    -- | A convenience alias for `Nothing` :: `Maybe` `MarkupParser`.
    noMarkupParser :: Maybe MarkupParser
    noMarkupParser = Nothing

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

    @
    'Data.GI.Base.Attributes.get' markupParser #startElement
    @
    -}
    getMarkupParserStartElement :: MonadIO m => MarkupParser -> m (Maybe GLib.Callbacks.MarkupParserStartElementFieldCallback_WithClosures)
    getMarkupParserStartElement s = liftIO $ withManagedPtr s $ \ptr -> do
        val <- peek (ptr `plusPtr` 0) :: IO (FunPtr GLib.Callbacks.C_MarkupParserStartElementFieldCallback)
        result <- SP.convertFunPtrIfNonNull val $ \val' -> do
            let val'' = GLib.Callbacks.dynamic_MarkupParserStartElementFieldCallback val'
            return val''
        return result

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

    @
    'Data.GI.Base.Attributes.set' markupParser [ #startElement 'Data.GI.Base.Attributes.:=' value ]
    @
    -}
    setMarkupParserStartElement :: MonadIO m => MarkupParser -> FunPtr GLib.Callbacks.C_MarkupParserStartElementFieldCallback -> m ()
    setMarkupParserStartElement s val = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 0) (val :: FunPtr GLib.Callbacks.C_MarkupParserStartElementFieldCallback)

    {- |
    Set the value of the “@start_element@” 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' #startElement
    @
    -}
    clearMarkupParserStartElement :: MonadIO m => MarkupParser -> m ()
    clearMarkupParserStartElement s = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 0) (FP.nullFunPtr :: FunPtr GLib.Callbacks.C_MarkupParserStartElementFieldCallback)

    #if ENABLE_OVERLOADING
    data MarkupParserStartElementFieldInfo
    instance AttrInfo MarkupParserStartElementFieldInfo where
        type AttrAllowedOps MarkupParserStartElementFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint MarkupParserStartElementFieldInfo = (~) (FunPtr GLib.Callbacks.C_MarkupParserStartElementFieldCallback)
        type AttrBaseTypeConstraint MarkupParserStartElementFieldInfo = (~) MarkupParser
        type AttrGetType MarkupParserStartElementFieldInfo = Maybe GLib.Callbacks.MarkupParserStartElementFieldCallback_WithClosures
        type AttrLabel MarkupParserStartElementFieldInfo = "start_element"
        type AttrOrigin MarkupParserStartElementFieldInfo = MarkupParser
        attrGet _ = getMarkupParserStartElement
        attrSet _ = setMarkupParserStartElement
        attrConstruct = undefined
        attrClear _ = clearMarkupParserStartElement

    markupParser_startElement :: AttrLabelProxy "startElement"
    markupParser_startElement = AttrLabelProxy

    #endif

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

    @
    'Data.GI.Base.Attributes.get' markupParser #endElement
    @
    -}
    getMarkupParserEndElement :: MonadIO m => MarkupParser -> m (Maybe GLib.Callbacks.MarkupParserEndElementFieldCallback_WithClosures)
    getMarkupParserEndElement s = liftIO $ withManagedPtr s $ \ptr -> do
        val <- peek (ptr `plusPtr` 8) :: IO (FunPtr GLib.Callbacks.C_MarkupParserEndElementFieldCallback)
        result <- SP.convertFunPtrIfNonNull val $ \val' -> do
            let val'' = GLib.Callbacks.dynamic_MarkupParserEndElementFieldCallback val'
            return val''
        return result

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

    @
    'Data.GI.Base.Attributes.set' markupParser [ #endElement 'Data.GI.Base.Attributes.:=' value ]
    @
    -}
    setMarkupParserEndElement :: MonadIO m => MarkupParser -> FunPtr GLib.Callbacks.C_MarkupParserEndElementFieldCallback -> m ()
    setMarkupParserEndElement s val = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 8) (val :: FunPtr GLib.Callbacks.C_MarkupParserEndElementFieldCallback)

    {- |
    Set the value of the “@end_element@” 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' #endElement
    @
    -}
    clearMarkupParserEndElement :: MonadIO m => MarkupParser -> m ()
    clearMarkupParserEndElement s = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 8) (FP.nullFunPtr :: FunPtr GLib.Callbacks.C_MarkupParserEndElementFieldCallback)

    #if ENABLE_OVERLOADING
    data MarkupParserEndElementFieldInfo
    instance AttrInfo MarkupParserEndElementFieldInfo where
        type AttrAllowedOps MarkupParserEndElementFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint MarkupParserEndElementFieldInfo = (~) (FunPtr GLib.Callbacks.C_MarkupParserEndElementFieldCallback)
        type AttrBaseTypeConstraint MarkupParserEndElementFieldInfo = (~) MarkupParser
        type AttrGetType MarkupParserEndElementFieldInfo = Maybe GLib.Callbacks.MarkupParserEndElementFieldCallback_WithClosures
        type AttrLabel MarkupParserEndElementFieldInfo = "end_element"
        type AttrOrigin MarkupParserEndElementFieldInfo = MarkupParser
        attrGet _ = getMarkupParserEndElement
        attrSet _ = setMarkupParserEndElement
        attrConstruct = undefined
        attrClear _ = clearMarkupParserEndElement

    markupParser_endElement :: AttrLabelProxy "endElement"
    markupParser_endElement = AttrLabelProxy

    #endif

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

    @
    'Data.GI.Base.Attributes.get' markupParser #text
    @
    -}
    getMarkupParserText :: MonadIO m => MarkupParser -> m (Maybe GLib.Callbacks.MarkupParserTextFieldCallback_WithClosures)
    getMarkupParserText s = liftIO $ withManagedPtr s $ \ptr -> do
        val <- peek (ptr `plusPtr` 16) :: IO (FunPtr GLib.Callbacks.C_MarkupParserTextFieldCallback)
        result <- SP.convertFunPtrIfNonNull val $ \val' -> do
            let val'' = GLib.Callbacks.dynamic_MarkupParserTextFieldCallback val'
            return val''
        return result

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

    @
    'Data.GI.Base.Attributes.set' markupParser [ #text 'Data.GI.Base.Attributes.:=' value ]
    @
    -}
    setMarkupParserText :: MonadIO m => MarkupParser -> FunPtr GLib.Callbacks.C_MarkupParserTextFieldCallback -> m ()
    setMarkupParserText s val = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 16) (val :: FunPtr GLib.Callbacks.C_MarkupParserTextFieldCallback)

    {- |
    Set the value of the “@text@” 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' #text
    @
    -}
    clearMarkupParserText :: MonadIO m => MarkupParser -> m ()
    clearMarkupParserText s = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 16) (FP.nullFunPtr :: FunPtr GLib.Callbacks.C_MarkupParserTextFieldCallback)

    #if ENABLE_OVERLOADING
    data MarkupParserTextFieldInfo
    instance AttrInfo MarkupParserTextFieldInfo where
        type AttrAllowedOps MarkupParserTextFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint MarkupParserTextFieldInfo = (~) (FunPtr GLib.Callbacks.C_MarkupParserTextFieldCallback)
        type AttrBaseTypeConstraint MarkupParserTextFieldInfo = (~) MarkupParser
        type AttrGetType MarkupParserTextFieldInfo = Maybe GLib.Callbacks.MarkupParserTextFieldCallback_WithClosures
        type AttrLabel MarkupParserTextFieldInfo = "text"
        type AttrOrigin MarkupParserTextFieldInfo = MarkupParser
        attrGet _ = getMarkupParserText
        attrSet _ = setMarkupParserText
        attrConstruct = undefined
        attrClear _ = clearMarkupParserText

    markupParser_text :: AttrLabelProxy "text"
    markupParser_text = AttrLabelProxy

    #endif

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

    @
    'Data.GI.Base.Attributes.get' markupParser #passthrough
    @
    -}
    getMarkupParserPassthrough :: MonadIO m => MarkupParser -> m (Maybe GLib.Callbacks.MarkupParserPassthroughFieldCallback_WithClosures)
    getMarkupParserPassthrough s = liftIO $ withManagedPtr s $ \ptr -> do
        val <- peek (ptr `plusPtr` 24) :: IO (FunPtr GLib.Callbacks.C_MarkupParserPassthroughFieldCallback)
        result <- SP.convertFunPtrIfNonNull val $ \val' -> do
            let val'' = GLib.Callbacks.dynamic_MarkupParserPassthroughFieldCallback val'
            return val''
        return result

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

    @
    'Data.GI.Base.Attributes.set' markupParser [ #passthrough 'Data.GI.Base.Attributes.:=' value ]
    @
    -}
    setMarkupParserPassthrough :: MonadIO m => MarkupParser -> FunPtr GLib.Callbacks.C_MarkupParserPassthroughFieldCallback -> m ()
    setMarkupParserPassthrough s val = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 24) (val :: FunPtr GLib.Callbacks.C_MarkupParserPassthroughFieldCallback)

    {- |
    Set the value of the “@passthrough@” 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' #passthrough
    @
    -}
    clearMarkupParserPassthrough :: MonadIO m => MarkupParser -> m ()
    clearMarkupParserPassthrough s = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 24) (FP.nullFunPtr :: FunPtr GLib.Callbacks.C_MarkupParserPassthroughFieldCallback)

    #if ENABLE_OVERLOADING
    data MarkupParserPassthroughFieldInfo
    instance AttrInfo MarkupParserPassthroughFieldInfo where
        type AttrAllowedOps MarkupParserPassthroughFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint MarkupParserPassthroughFieldInfo = (~) (FunPtr GLib.Callbacks.C_MarkupParserPassthroughFieldCallback)
        type AttrBaseTypeConstraint MarkupParserPassthroughFieldInfo = (~) MarkupParser
        type AttrGetType MarkupParserPassthroughFieldInfo = Maybe GLib.Callbacks.MarkupParserPassthroughFieldCallback_WithClosures
        type AttrLabel MarkupParserPassthroughFieldInfo = "passthrough"
        type AttrOrigin MarkupParserPassthroughFieldInfo = MarkupParser
        attrGet _ = getMarkupParserPassthrough
        attrSet _ = setMarkupParserPassthrough
        attrConstruct = undefined
        attrClear _ = clearMarkupParserPassthrough

    markupParser_passthrough :: AttrLabelProxy "passthrough"
    markupParser_passthrough = AttrLabelProxy

    #endif

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

    @
    'Data.GI.Base.Attributes.get' markupParser #error
    @
    -}
    getMarkupParserError :: MonadIO m => MarkupParser -> m (Maybe GLib.Callbacks.MarkupParserErrorFieldCallback_WithClosures)
    getMarkupParserError s = liftIO $ withManagedPtr s $ \ptr -> do
        val <- peek (ptr `plusPtr` 32) :: IO (FunPtr GLib.Callbacks.C_MarkupParserErrorFieldCallback)
        result <- SP.convertFunPtrIfNonNull val $ \val' -> do
            let val'' = GLib.Callbacks.dynamic_MarkupParserErrorFieldCallback val'
            return val''
        return result

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

    @
    'Data.GI.Base.Attributes.set' markupParser [ #error 'Data.GI.Base.Attributes.:=' value ]
    @
    -}
    setMarkupParserError :: MonadIO m => MarkupParser -> FunPtr GLib.Callbacks.C_MarkupParserErrorFieldCallback -> m ()
    setMarkupParserError s val = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 32) (val :: FunPtr GLib.Callbacks.C_MarkupParserErrorFieldCallback)

    {- |
    Set the value of the “@error@” 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' #error
    @
    -}
    clearMarkupParserError :: MonadIO m => MarkupParser -> m ()
    clearMarkupParserError s = liftIO $ withManagedPtr s $ \ptr -> do
        poke (ptr `plusPtr` 32) (FP.nullFunPtr :: FunPtr GLib.Callbacks.C_MarkupParserErrorFieldCallback)

    #if ENABLE_OVERLOADING
    data MarkupParserErrorFieldInfo
    instance AttrInfo MarkupParserErrorFieldInfo where
        type AttrAllowedOps MarkupParserErrorFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint MarkupParserErrorFieldInfo = (~) (FunPtr GLib.Callbacks.C_MarkupParserErrorFieldCallback)
        type AttrBaseTypeConstraint MarkupParserErrorFieldInfo = (~) MarkupParser
        type AttrGetType MarkupParserErrorFieldInfo = Maybe GLib.Callbacks.MarkupParserErrorFieldCallback_WithClosures
        type AttrLabel MarkupParserErrorFieldInfo = "error"
        type AttrOrigin MarkupParserErrorFieldInfo = MarkupParser
        attrGet _ = getMarkupParserError
        attrSet _ = setMarkupParserError
        attrConstruct = undefined
        attrClear _ = clearMarkupParserError

    markupParser_error :: AttrLabelProxy "error"
    markupParser_error = AttrLabelProxy

    #endif

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList MarkupParser
    type instance O.AttributeList MarkupParser = MarkupParserAttributeList
    type MarkupParserAttributeList = ('[ '("startElement", MarkupParserStartElementFieldInfo), '("endElement", MarkupParserEndElementFieldInfo), '("text", MarkupParserTextFieldInfo), '("passthrough", MarkupParserPassthroughFieldInfo), '("error", MarkupParserErrorFieldInfo)] :: [(Symbol, *)])
    #endif

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

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

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveMarkupParserMethod t MarkupParser, O.MethodInfo info MarkupParser p) => O.IsLabel t (MarkupParser -> 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