1 module soup.XMLRPCParams;
2 
3 private import glib.ErrorG;
4 private import glib.GException;
5 private import glib.Str;
6 private import glib.Variant;
7 private import soup.c.functions;
8 public  import soup.c.types;
9 
10 
11 /**
12  * Opaque structure containing XML-RPC methodCall parameter values.
13  * Can be parsed using soup_xmlrpc_params_parse() and freed with
14  * soup_xmlrpc_params_free().
15  *
16  * Since: 2.52
17  */
18 public class XMLRPCParams
19 {
20 	/** the main Gtk struct */
21 	protected SoupXMLRPCParams* soupXMLRPCParams;
22 	protected bool ownedRef;
23 
24 	/** Get the main Gtk struct */
25 	public SoupXMLRPCParams* getXMLRPCParamsStruct(bool transferOwnership = false)
26 	{
27 		if (transferOwnership)
28 			ownedRef = false;
29 		return soupXMLRPCParams;
30 	}
31 
32 	/** the main Gtk struct as a void* */
33 	protected void* getStruct()
34 	{
35 		return cast(void*)soupXMLRPCParams;
36 	}
37 
38 	/**
39 	 * Sets our main struct and passes it to the parent class.
40 	 */
41 	public this (SoupXMLRPCParams* soupXMLRPCParams, bool ownedRef = false)
42 	{
43 		this.soupXMLRPCParams = soupXMLRPCParams;
44 		this.ownedRef = ownedRef;
45 	}
46 
47 	~this ()
48 	{
49 		if ( ownedRef )
50 			soup_xmlrpc_params_free(soupXMLRPCParams);
51 	}
52 
53 
54 	/**
55 	 * Free a #SoupXMLRPCParams returned by soup_xmlrpc_parse_request().
56 	 *
57 	 * Since: 2.52
58 	 */
59 	public void free()
60 	{
61 		soup_xmlrpc_params_free(soupXMLRPCParams);
62 		ownedRef = false;
63 	}
64 
65 	/**
66 	 * Parse method parameters returned by soup_xmlrpc_parse_request().
67 	 *
68 	 * Deserialization details:
69 	 * - If @signature is provided, <int> and <i4> can be deserialized
70 	 * to byte, int16, uint16, int32, uint32, int64 or uint64. Otherwise
71 	 * it will be deserialized to int32. If the value is out of range
72 	 * for the target type it will return an error.
73 	 * - <struct> will be deserialized to "a{sv}". @signature could define
74 	 * another value type (e.g. "a{ss}").
75 	 * - <array> will be deserialized to "av". @signature could define
76 	 * another element type (e.g. "as") or could be a tuple (e.g. "(ss)").
77 	 * - <base64> will be deserialized to "ay".
78 	 * - <string> will be deserialized to "s".
79 	 * - <dateTime.iso8601> will be deserialized to an unspecified variant
80 	 * type. If @signature is provided it must have the generic "v" type, which
81 	 * means there is no guarantee that it's actually a datetime that has been
82 	 * received. soup_xmlrpc_variant_get_datetime() must be used to parse and
83 	 * type check this special variant.
84 	 * - @signature must not have maybes, otherwise an error is returned.
85 	 * - Dictionaries must have string keys, otherwise an error is returned.
86 	 *
87 	 * Params:
88 	 *     signature = A valid #GVariant type string, or %NULL
89 	 *
90 	 * Returns: a new (non-floating) #GVariant, or %NULL
91 	 *
92 	 * Since: 2.52
93 	 *
94 	 * Throws: GException on failure.
95 	 */
96 	public Variant parse(string signature)
97 	{
98 		GError* err = null;
99 
100 		auto __p = soup_xmlrpc_params_parse(soupXMLRPCParams, Str.toStringz(signature), &err);
101 
102 		if (err !is null)
103 		{
104 			throw new GException( new ErrorG(err) );
105 		}
106 
107 		if(__p is null)
108 		{
109 			return null;
110 		}
111 
112 		return new Variant(cast(GVariant*) __p, true);
113 	}
114 }