gi-soup-2.4.18: GI/Soup/Structs/XMLRPCParams.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
Opaque structure containing XML-RPC methodCall parameter values.
Can be parsed using 'GI.Soup.Structs.XMLRPCParams.xMLRPCParamsParse' and freed with
'GI.Soup.Structs.XMLRPCParams.xMLRPCParamsFree'.
/Since: 2.52/
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Soup.Structs.XMLRPCParams
(
-- * Exported types
XMLRPCParams(..) ,
noXMLRPCParams ,
-- * Methods
-- ** free #method:free#
#if ENABLE_OVERLOADING
XMLRPCParamsFreeMethodInfo ,
#endif
xMLRPCParamsFree ,
-- ** parse #method:parse#
#if ENABLE_OVERLOADING
XMLRPCParamsParseMethodInfo ,
#endif
xMLRPCParamsParse ,
) 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
-- | Memory-managed wrapper type.
newtype XMLRPCParams = XMLRPCParams (ManagedPtr XMLRPCParams)
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr XMLRPCParams where
wrappedPtrCalloc = return nullPtr
wrappedPtrCopy = return
wrappedPtrFree = Nothing
-- | A convenience alias for `Nothing` :: `Maybe` `XMLRPCParams`.
noXMLRPCParams :: Maybe XMLRPCParams
noXMLRPCParams = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList XMLRPCParams
type instance O.AttributeList XMLRPCParams = XMLRPCParamsAttributeList
type XMLRPCParamsAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method XMLRPCParams::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "XMLRPCParams"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a SoupXMLRPCParams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "soup_xmlrpc_params_free" soup_xmlrpc_params_free ::
Ptr XMLRPCParams -> -- self : TInterface (Name {namespace = "Soup", name = "XMLRPCParams"})
IO ()
{- |
Free a 'GI.Soup.Structs.XMLRPCParams.XMLRPCParams' returned by 'GI.Soup.Functions.xmlrpcParseRequest'.
/Since: 2.52/
-}
xMLRPCParamsFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
XMLRPCParams
{- ^ /@self@/: a SoupXMLRPCParams -}
-> m ()
xMLRPCParamsFree self = liftIO $ do
self' <- unsafeManagedPtrGetPtr self
soup_xmlrpc_params_free self'
touchManagedPtr self
return ()
#if ENABLE_OVERLOADING
data XMLRPCParamsFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo XMLRPCParamsFreeMethodInfo XMLRPCParams signature where
overloadedMethod _ = xMLRPCParamsFree
#endif
-- method XMLRPCParams::parse
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "XMLRPCParams"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #SoupXMLRPCParams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signature", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A valid #GVariant type string, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : True
-- Skip return : False
foreign import ccall "soup_xmlrpc_params_parse" soup_xmlrpc_params_parse ::
Ptr XMLRPCParams -> -- self : TInterface (Name {namespace = "Soup", name = "XMLRPCParams"})
CString -> -- signature : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO (Ptr GVariant)
{- |
Parse method parameters returned by 'GI.Soup.Functions.xmlrpcParseRequest'.
Deserialization details:
- If /@signature@/ is provided, <int> and <i4> can be deserialized
to byte, int16, uint16, int32, uint32, int64 or uint64. Otherwise
it will be deserialized to int32. If the value is out of range
for the target type it will return an error.
- <struct> will be deserialized to \"a{sv}\". /@signature@/ could define
another value type (e.g. \"a{ss}\").
- <array> will be deserialized to \"av\". /@signature@/ could define
another element type (e.g. \"as\") or could be a tuple (e.g. \"(ss)\").
- <base64> will be deserialized to \"ay\".
- <string> will be deserialized to \"s\".
- <dateTime.iso8601> will be deserialized to an unspecified variant
type. If /@signature@/ is provided it must have the generic \"v\" type, which
means there is no guarantee that it\'s actually a datetime that has been
received. 'GI.Soup.Functions.xmlrpcVariantGetDatetime' must be used to parse and
type check this special variant.
- /@signature@/ must not have maybes, otherwise an error is returned.
- Dictionaries must have string keys, otherwise an error is returned.
/Since: 2.52/
-}
xMLRPCParamsParse ::
(B.CallStack.HasCallStack, MonadIO m) =>
XMLRPCParams
{- ^ /@self@/: A 'GI.Soup.Structs.XMLRPCParams.XMLRPCParams' -}
-> Maybe (T.Text)
{- ^ /@signature@/: A valid 'GVariant' type string, or 'Nothing' -}
-> m GVariant
{- ^ __Returns:__ a new (non-floating) 'GVariant', or 'Nothing' /(Can throw 'Data.GI.Base.GError.GError')/ -}
xMLRPCParamsParse self signature = liftIO $ do
self' <- unsafeManagedPtrGetPtr self
maybeSignature <- case signature of
Nothing -> return nullPtr
Just jSignature -> do
jSignature' <- textToCString jSignature
return jSignature'
onException (do
result <- propagateGError $ soup_xmlrpc_params_parse self' maybeSignature
checkUnexpectedReturnNULL "xMLRPCParamsParse" result
result' <- B.GVariant.wrapGVariantPtr result
touchManagedPtr self
freeMem maybeSignature
return result'
) (do
freeMem maybeSignature
)
#if ENABLE_OVERLOADING
data XMLRPCParamsParseMethodInfo
instance (signature ~ (Maybe (T.Text) -> m GVariant), MonadIO m) => O.MethodInfo XMLRPCParamsParseMethodInfo XMLRPCParams signature where
overloadedMethod _ = xMLRPCParamsParse
#endif
#if ENABLE_OVERLOADING
type family ResolveXMLRPCParamsMethod (t :: Symbol) (o :: *) :: * where
ResolveXMLRPCParamsMethod "free" o = XMLRPCParamsFreeMethodInfo
ResolveXMLRPCParamsMethod "parse" o = XMLRPCParamsParseMethodInfo
ResolveXMLRPCParamsMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveXMLRPCParamsMethod t XMLRPCParams, O.MethodInfo info XMLRPCParams p) => OL.IsLabel t (XMLRPCParams -> 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