{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.UriParamsIter
(
UriParamsIter(..) ,
newZeroUriParamsIter ,
#if defined(ENABLE_OVERLOADING)
ResolveUriParamsIterMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
UriParamsIterInitMethodInfo ,
#endif
uriParamsIterInit ,
#if defined(ENABLE_OVERLOADING)
UriParamsIterNextMethodInfo ,
#endif
uriParamsIterNext ,
) 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
#if MIN_VERSION_base(4,18,0)
import {-# SOURCE #-} qualified GI.GLib.Flags as GLib.Flags
#else
import {-# SOURCE #-} qualified GI.GLib.Flags as GLib.Flags
#endif
newtype UriParamsIter = UriParamsIter (SP.ManagedPtr UriParamsIter)
deriving (UriParamsIter -> UriParamsIter -> Bool
(UriParamsIter -> UriParamsIter -> Bool)
-> (UriParamsIter -> UriParamsIter -> Bool) -> Eq UriParamsIter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UriParamsIter -> UriParamsIter -> Bool
== :: UriParamsIter -> UriParamsIter -> Bool
$c/= :: UriParamsIter -> UriParamsIter -> Bool
/= :: UriParamsIter -> UriParamsIter -> Bool
Eq)
instance SP.ManagedPtrNewtype UriParamsIter where
toManagedPtr :: UriParamsIter -> ManagedPtr UriParamsIter
toManagedPtr (UriParamsIter ManagedPtr UriParamsIter
p) = ManagedPtr UriParamsIter
p
instance BoxedPtr UriParamsIter where
boxedPtrCopy :: UriParamsIter -> IO UriParamsIter
boxedPtrCopy = \UriParamsIter
p -> UriParamsIter
-> (Ptr UriParamsIter -> IO UriParamsIter) -> IO UriParamsIter
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr UriParamsIter
p (Int -> Ptr UriParamsIter -> IO (Ptr UriParamsIter)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
280 (Ptr UriParamsIter -> IO (Ptr UriParamsIter))
-> (Ptr UriParamsIter -> IO UriParamsIter)
-> Ptr UriParamsIter
-> IO UriParamsIter
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr UriParamsIter -> UriParamsIter)
-> Ptr UriParamsIter -> IO UriParamsIter
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr UriParamsIter -> UriParamsIter
UriParamsIter)
boxedPtrFree :: UriParamsIter -> IO ()
boxedPtrFree = \UriParamsIter
x -> UriParamsIter -> (Ptr UriParamsIter -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr UriParamsIter
x Ptr UriParamsIter -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr UriParamsIter where
boxedPtrCalloc :: IO (Ptr UriParamsIter)
boxedPtrCalloc = Int -> IO (Ptr UriParamsIter)
forall a. Int -> IO (Ptr a)
callocBytes Int
280
newZeroUriParamsIter :: MonadIO m => m UriParamsIter
newZeroUriParamsIter :: forall (m :: * -> *). MonadIO m => m UriParamsIter
newZeroUriParamsIter = IO UriParamsIter -> m UriParamsIter
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UriParamsIter -> m UriParamsIter)
-> IO UriParamsIter -> m UriParamsIter
forall a b. (a -> b) -> a -> b
$ IO (Ptr UriParamsIter)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr UriParamsIter)
-> (Ptr UriParamsIter -> IO UriParamsIter) -> IO UriParamsIter
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr UriParamsIter -> UriParamsIter)
-> Ptr UriParamsIter -> IO UriParamsIter
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr UriParamsIter -> UriParamsIter
UriParamsIter
instance tag ~ 'AttrSet => Constructible UriParamsIter tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr UriParamsIter -> UriParamsIter)
-> [AttrOp UriParamsIter tag] -> m UriParamsIter
new ManagedPtr UriParamsIter -> UriParamsIter
_ [AttrOp UriParamsIter tag]
attrs = do
UriParamsIter
o <- m UriParamsIter
forall (m :: * -> *). MonadIO m => m UriParamsIter
newZeroUriParamsIter
UriParamsIter -> [AttrOp UriParamsIter 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set UriParamsIter
o [AttrOp UriParamsIter tag]
[AttrOp UriParamsIter 'AttrSet]
attrs
UriParamsIter -> m UriParamsIter
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return UriParamsIter
o
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList UriParamsIter
type instance O.AttributeList UriParamsIter = UriParamsIterAttributeList
type UriParamsIterAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_uri_params_iter_init" g_uri_params_iter_init ::
Ptr UriParamsIter ->
CString ->
DI.Int64 ->
CString ->
CUInt ->
IO ()
uriParamsIterInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
UriParamsIter
-> T.Text
-> DI.Int64
-> T.Text
-> [GLib.Flags.UriParamsFlags]
-> m ()
uriParamsIterInit :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UriParamsIter -> Text -> Int64 -> Text -> [UriParamsFlags] -> m ()
uriParamsIterInit UriParamsIter
iter Text
params Int64
length_ Text
separators [UriParamsFlags]
flags = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr UriParamsIter
iter' <- UriParamsIter -> IO (Ptr UriParamsIter)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr UriParamsIter
iter
CString
params' <- Text -> IO CString
textToCString Text
params
CString
separators' <- Text -> IO CString
textToCString Text
separators
let flags' :: CUInt
flags' = [UriParamsFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [UriParamsFlags]
flags
Ptr UriParamsIter -> CString -> Int64 -> CString -> CUInt -> IO ()
g_uri_params_iter_init Ptr UriParamsIter
iter' CString
params' Int64
length_ CString
separators' CUInt
flags'
UriParamsIter -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr UriParamsIter
iter
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
params'
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
separators'
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data UriParamsIterInitMethodInfo
instance (signature ~ (T.Text -> DI.Int64 -> T.Text -> [GLib.Flags.UriParamsFlags] -> m ()), MonadIO m) => O.OverloadedMethod UriParamsIterInitMethodInfo UriParamsIter signature where
overloadedMethod = uriParamsIterInit
instance O.OverloadedMethodInfo UriParamsIterInitMethodInfo UriParamsIter where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.UriParamsIter.uriParamsIterInit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-UriParamsIter.html#v:uriParamsIterInit"
})
#endif
foreign import ccall "g_uri_params_iter_next" g_uri_params_iter_next ::
Ptr UriParamsIter ->
Ptr CString ->
Ptr CString ->
Ptr (Ptr GError) ->
IO CInt
uriParamsIterNext ::
(B.CallStack.HasCallStack, MonadIO m) =>
UriParamsIter
-> m ((Maybe T.Text, Maybe T.Text))
uriParamsIterNext :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UriParamsIter -> m (Maybe Text, Maybe Text)
uriParamsIterNext UriParamsIter
iter = IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text))
-> IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
Ptr UriParamsIter
iter' <- UriParamsIter -> IO (Ptr UriParamsIter)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr UriParamsIter
iter
Ptr CString
attribute <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
Ptr CString
value <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
IO (Maybe Text, Maybe Text) -> IO () -> IO (Maybe Text, 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 UriParamsIter
-> Ptr CString -> Ptr CString -> Ptr (Ptr GError) -> IO CInt
g_uri_params_iter_next Ptr UriParamsIter
iter' Ptr CString
attribute Ptr CString
value
CString
attribute' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
attribute
Maybe Text
maybeAttribute' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
attribute' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
attribute'' -> do
Text
attribute''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
attribute''
Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
attribute'''
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
attribute'
CString
value' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
value
Maybe Text
maybeValue' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
value' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
value'' -> do
Text
value''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
value''
Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
value'''
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
UriParamsIter -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr UriParamsIter
iter
Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
attribute
Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
value
(Maybe Text, Maybe Text) -> IO (Maybe Text, Maybe Text)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Text
maybeAttribute', Maybe Text
maybeValue')
) (do
Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
attribute
Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
value
)
#if defined(ENABLE_OVERLOADING)
data UriParamsIterNextMethodInfo
instance (signature ~ (m ((Maybe T.Text, Maybe T.Text))), MonadIO m) => O.OverloadedMethod UriParamsIterNextMethodInfo UriParamsIter signature where
overloadedMethod = uriParamsIterNext
instance O.OverloadedMethodInfo UriParamsIterNextMethodInfo UriParamsIter where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.UriParamsIter.uriParamsIterNext",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-UriParamsIter.html#v:uriParamsIterNext"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveUriParamsIterMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveUriParamsIterMethod "init" o = UriParamsIterInitMethodInfo
ResolveUriParamsIterMethod "next" o = UriParamsIterNextMethodInfo
ResolveUriParamsIterMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveUriParamsIterMethod t UriParamsIter, O.OverloadedMethod info UriParamsIter p) => OL.IsLabel t (UriParamsIter -> 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 ~ ResolveUriParamsIterMethod t UriParamsIter, O.OverloadedMethod info UriParamsIter p, R.HasField t UriParamsIter p) => R.HasField t UriParamsIter p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveUriParamsIterMethod t UriParamsIter, O.OverloadedMethodInfo info UriParamsIter) => OL.IsLabel t (O.MethodProxy info UriParamsIter) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif