1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-GVariant.html
27  * outPack = glib
28  * outFile = Variant
29  * strct   = GVariant
30  * realStrct=
31  * ctorStrct=
32  * clss    = Variant
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_variant_
41  * omit structs:
42  * omit prefixes:
43  * 	- g_variant_iter_
44  * 	- g_variant_builder_
45  * omit code:
46  * 	- g_variant_new_boolean
47  * 	- g_variant_new_bytestring_array
48  * 	- g_variant_new_object_path
49  * 	- g_variant_new_signature
50  * 	- g_variant_new_bytestring
51  * omit signals:
52  * imports:
53  * 	- glib.Str
54  * 	- glib.ErrorG
55  * 	- glib.GException
56  * 	- glib.StringG
57  * 	- glib.VariantType
58  * structWrap:
59  * 	- GString* -> StringG
60  * 	- GVariant* -> Variant
61  * 	- GVariantType* -> VariantType
62  * module aliases:
63  * local aliases:
64  * 	- byte -> b
65  * overrides:
66  */
67 
68 module glib.Variant;
69 
70 public  import gtkc.glibtypes;
71 
72 private import gtkc.glib;
73 private import glib.ConstructionException;
74 
75 
76 private import glib.Str;
77 private import glib.ErrorG;
78 private import glib.GException;
79 private import glib.StringG;
80 private import glib.VariantType;
81 
82 
83 
84 
85 /**
86  * Description
87  * GVariant is a variant datatype; it stores a value along with
88  * information about the type of that value. The range of possible
89  * values is determined by the type. The type system used by GVariant
90  * is GVariantType.
91  * GVariant instances always have a type and a value (which are given
92  * at construction time). The type and value of a GVariant instance
93  * can never change other than by the GVariant itself being
94  * destroyed. A GVariant can not contain a pointer.
95  * GVariant is reference counted using g_variant_ref() and
96  * g_variant_unref(). GVariant also has floating reference counts --
97  * see g_variant_ref_sink().
98  * GVariant is completely threadsafe. A GVariant instance can be
99  * concurrently accessed in any way from any number of threads without
100  * problems.
101  * GVariant is heavily optimised for dealing with data in serialised
102  * form. It works particularly well with data located in memory-mapped
103  * files. It can perform nearly all deserialisation operations in a
104  * small constant time, usually touching only a single memory page.
105  * Serialised GVariant data can also be sent over the network.
106  * GVariant is largely compatible with D-Bus. Almost all types of
107  * GVariant instances can be sent over D-Bus. See GVariantType for
108  * exceptions.
109  * For convenience to C programmers, GVariant features powerful
110  * varargs-based value construction and destruction. This feature is
111  * designed to be embedded in other libraries.
112  * There is a Python-inspired text language for describing GVariant
113  * values. GVariant includes a printer for this language and a parser
114  * with type inferencing.
115  * Memory Use
116  *  GVariant tries to be quite efficient with respect to memory use.
117  *  This section gives a rough idea of how much memory is used by the
118  *  current implementation. The information here is subject to change
119  *  in the future.
120  *  The memory allocated by GVariant can be grouped into 4 broad
121  *  purposes: memory for serialised data, memory for the type
122  *  information cache, buffer management memory and memory for the
123  *  GVariant structure itself.
124  * Serialised Data Memory
125  *  This is the memory that is used for storing GVariant data in
126  *  serialised form. This is what would be sent over the network or
127  *  what would end up on disk.
128  *  The amount of memory required to store a boolean is 1 byte. 16,
129  *  32 and 64 bit integers and double precision floating point numbers
130  *  use their "natural" size. Strings (including object path and
131  *  signature strings) are stored with a nul terminator, and as such
132  *  use the length of the string plus 1 byte.
133  *  Maybe types use no space at all to represent the null value and
134  *  use the same amount of space (sometimes plus one byte) as the
135  *  equivalent non-maybe-typed value to represent the non-null case.
136  *  Arrays use the amount of space required to store each of their
137  *  members, concatenated. Additionally, if the items stored in an
138  *  array are not of a fixed-size (ie: strings, other arrays, etc)
139  *  then an additional framing offset is stored for each item. The
140  *  size of this offset is either 1, 2 or 4 bytes depending on the
141  *  overall size of the container. Additionally, extra padding bytes
142  *  are added as required for alignment of child values.
143  *  Tuples (including dictionary entries) use the amount of space
144  *  required to store each of their members, concatenated, plus one
145  *  framing offset (as per arrays) for each non-fixed-sized item in
146  *  the tuple, except for the last one. Additionally, extra padding
147  *  bytes are added as required for alignment of child values.
148  *  Variants use the same amount of space as the item inside of the
149  *  variant, plus 1 byte, plus the length of the type string for the
150  *  item inside the variant.
151  *  As an example, consider a dictionary mapping strings to variants.
152  *  In the case that the dictionary is empty, 0 bytes are required for
153  *  the serialisation.
154  *  If we add an item "width" that maps to the int32 value of 500 then
155  *  we will use 4 byte to store the int32 (so 6 for the variant
156  *  containing it) and 6 bytes for the string. The variant must be
157  *  aligned to 8 after the 6 bytes of the string, so that's 2 extra
158  *  bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
159  *  for the dictionary entry. An additional 1 byte is added to the
160  *  array as a framing offset making a total of 15 bytes.
161  *  If we add another entry, "title" that maps to a nullable string
162  *  that happens to have a value of null, then we use 0 bytes for the
163  *  null value (and 3 bytes for the variant to contain it along with
164  *  its type string) plus 6 bytes for the string. Again, we need 2
165  *  padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
166  *  We now require extra padding between the two items in the array.
167  *  After the 14 bytes of the first item, that's 2 bytes required. We
168  *  now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
169  *  + 2 = 29 bytes to encode the entire two-item dictionary.
170  * Type Information Cache
171  *  For each GVariant type that currently exists in the program a type
172  *  information structure is kept in the type information cache. The
173  *  type information structure is required for rapid deserialisation.
174  *  Continuing with the above example, if a GVariant exists with the
175  *  type "a{sv}" then a type information struct will exist for
176  *  "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
177  *  will share the same type information. Additionally, all
178  *  single-digit types are stored in read-only static memory and do
179  *  not contribute to the writable memory footprint of a program using
180  *  GVariant.
181  *  Aside from the type information structures stored in read-only
182  *  memory, there are two forms of type information. One is used for
183  *  container types where there is a single element type: arrays and
184  *  maybe types. The other is used for container types where there
185  *  are multiple element types: tuples and dictionary entries.
186  *  Array type info structures are 6 * sizeof (void *), plus the
187  *  memory required to store the type string itself. This means that
188  *  on 32bit systems, the cache entry for "a{sv}" would require 30
189  *  bytes of memory (plus malloc overhead).
190  *  Tuple type info structures are 6 * sizeof (void *), plus 4 *
191  *  sizeof (void *) for each item in the tuple, plus the memory
192  *  required to store the type string itself. A 2-item tuple, for
193  *  example, would have a type information structure that consumed
194  *  writable memory in the size of 14 * sizeof (void *) (plus type
195  *  string) This means that on 32bit systems, the cache entry for
196  *  "{sv}" would require 61 bytes of memory (plus malloc overhead).
197  *  This means that in total, for our "a{sv}" example, 91 bytes of
198  *  type information would be allocated.
199  *  The type information cache, additionally, uses a GHashTable to
200  *  store and lookup the cached items and stores a pointer to this
201  *  hash table in static storage. The hash table is freed when there
202  *  are zero items in the type cache.
203  *  Although these sizes may seem large it is important to remember
204  *  that a program will probably only have a very small number of
205  *  different types of values in it and that only one type information
206  *  structure is required for many different values of the same type.
207  * Buffer Management Memory
208  *  GVariant uses an internal buffer management structure to deal
209  *  with the various different possible sources of serialised data
210  *  that it uses. The buffer is responsible for ensuring that the
211  *  correct call is made when the data is no longer in use by
212  *  GVariant. This may involve a g_free() or a g_slice_free() or
213  *  even g_mapped_file_unref().
214  *  One buffer management structure is used for each chunk of
215  *  serialised data. The size of the buffer management structure is 4
216  *  * (void *). On 32bit systems, that's 16 bytes.
217  * GVariant structure
218  *  The size of a GVariant structure is 6 * (void *). On 32 bit
219  *  systems, that's 24 bytes.
220  *  GVariant structures only exist if they are explicitly created
221  *  with API calls. For example, if a GVariant is constructed out of
222  *  serialised data for the example given above (with the dictionary)
223  *  then although there are 9 individual values that comprise the
224  *  entire dictionary (two keys, two values, two variants containing
225  *  the values, two dictionary entries, plus the dictionary itself),
226  *  only 1 GVariant instance exists -- the one refering to the
227  *  dictionary.
228  *  If calls are made to start accessing the other values then
229  *  GVariant instances will exist for those values only for as long
230  *  as they are in use (ie: until you call g_variant_unref()). The
231  *  type information is shared. The serialised data and the buffer
232  *  management structure for that serialised data is shared by the
233  *  child.
234  * Summary
235  *  To put the entire example together, for our dictionary mapping
236  *  strings to variants (with two entries, as given above), we are
237  *  using 91 bytes of memory for type information, 29 byes of memory
238  *  for the serialised data, 16 bytes for buffer management and 24
239  *  bytes for the GVariant instance, or a total of 160 bytes, plus
240  *  malloc overhead. If we were to use g_variant_get_child_value() to
241  *  access the two dictionary entries, we would use an additional 48
242  *  bytes. If we were to have other dictionaries of the same type, we
243  *  would use more memory for the serialised data and buffer
244  *  management for those dictionaries, but the type information would
245  *  be shared.
246  */
247 public class Variant
248 {
249 	
250 	/** the main Gtk struct */
251 	protected GVariant* gVariant;
252 	
253 	
254 	public GVariant* getVariantStruct()
255 	{
256 		return gVariant;
257 	}
258 	
259 	
260 	/** the main Gtk struct as a void* */
261 	protected void* getStruct()
262 	{
263 		return cast(void*)gVariant;
264 	}
265 	
266 	/**
267 	 * Sets our main struct and passes it to the parent class
268 	 */
269 	public this (GVariant* gVariant)
270 	{
271 		this.gVariant = gVariant;
272 	}
273 	
274 	/**
275 	 * Creates a new boolean GVariant instance -- either TRUE or FALSE.
276 	 * Since 2.24
277 	 * Params:
278 	 * boolean = a gboolean value
279 	 * Throws: ConstructionException GTK+ fails to create the object.
280 	 */
281 	public this (bool boolean)
282 	{
283 		// GVariant * g_variant_new_boolean (gboolean boolean);
284 		auto p = g_variant_new_boolean(boolean);
285 		if(p is null)
286 		{
287 			throw new ConstructionException("null returned by g_variant_new_boolean(boolean)");
288 		}
289 		this(cast(GVariant*) p);
290 	}
291 	
292 	/**
293 	 * Creates a DBus object path GVariant with the contents of string.
294 	 * string must be a valid DBus object path.
295 	 * Use Variant.isObjectPath() if you're not sure.
296 	 * Since 2.24
297 	 *
298 	 * Throws: ConstructionException GTK+ fails to create the object.
299 	 */
300 	public static Variant fromObjectPath(string path)
301 	{
302 		auto p = g_variant_new_object_path(Str.toStringz(path));
303 		if(p is null)
304 		{
305 			throw new ConstructionException("null returned by g_variant_new_object_path");
306 		}
307 		return new Variant(cast(GVariant*) p);
308 	}
309 	
310 	/**
311 	 * Creates a DBus type signature GVariant with the contents of string.
312 	 * string must be a valid DBus type signature.
313 	 * Use Variant.isSignature() if you're not sure.
314 	 * Since 2.24
315 	 *
316 	 * Throws: ConstructionException GTK+ fails to create the object.
317 	 */
318 	public static Variant fromSignature(string signature)
319 	{
320 		auto p = g_variant_new_signature(Str.toStringz(signature));
321 		if(p is null)
322 		{
323 			throw new ConstructionException("null returned by g_variant_new_signature");
324 		}
325 		return new Variant(cast(GVariant*) p);
326 	}
327 	
328 	/**
329 	 * Creates an array-of-bytes GVariant with the contents of string.
330 	 * This function is just like new Variant(string) except that the string
331 	 * need not be valid utf8.
332 	 *
333 	 * The nul terminator character at the end of the string is stored in
334 	 * the array.
335 	 *
336 	 * Throws: ConstructionException GTK+ fails to create the object.
337 	 */
338 	public static Variant fromByteString(string byteString)
339 	{
340 		auto p = g_variant_new_bytestring(Str.toStringz(byteString));
341 		if(p is null)
342 		{
343 			throw new ConstructionException("null returned by g_variant_new_bytestring");
344 		}
345 		return new Variant(cast(GVariant*) p);
346 	}
347 	
348 	/**
349 	 * Constructs an array of bytestring GVariant from the given array of
350 	 * strings. If length is -1 then strv is NULL-terminated.
351 	 * Since 2.26
352 	 *
353 	 * Params:
354 	 *     strv   = an array of strings.
355 	 *     length = the length of strv, or -1
356 	 *
357 	 * Throws: ConstructionException GTK+ fails to create the object.
358 	 */
359 	public static Variant fromByteStringArray(string[] strv)
360 	{
361 		// GVariant * g_variant_new_bytestring_array (const gchar * const *strv,  gssize length);
362 		auto p = g_variant_new_bytestring_array(Str.toStringzArray(strv), strv.length);
363 		if(p is null)
364 		{
365 			throw new ConstructionException("null returned by g_variant_new_bytestring_array(strv, length)");
366 		}
367 		return new Variant(cast(GVariant*) p);
368 	}
369 	
370 	/**
371 	 */
372 	
373 	/**
374 	 * Decreases the reference count of value. When its reference count
375 	 * drops to 0, the memory used by the variant is freed.
376 	 * Since 2.24
377 	 */
378 	public void unref()
379 	{
380 		// void g_variant_unref (GVariant *value);
381 		g_variant_unref(gVariant);
382 	}
383 	
384 	/**
385 	 * Increases the reference count of value.
386 	 * Since 2.24
387 	 * Returns: the same value
388 	 */
389 	public Variant doref()
390 	{
391 		// GVariant * g_variant_ref (GVariant *value);
392 		auto p = g_variant_ref(gVariant);
393 		
394 		if(p is null)
395 		{
396 			return null;
397 		}
398 		
399 		return new Variant(cast(GVariant*) p);
400 	}
401 	
402 	/**
403 	 * GVariant uses a floating reference count system. All functions with
404 	 * names starting with g_variant_new_ return floating
405 	 * references.
406 	 * Calling g_variant_ref_sink() on a GVariant with a floating reference
407 	 * will convert the floating reference into a full reference. Calling
408 	 * g_variant_ref_sink() on a non-floating GVariant results in an
409 	 * additional normal reference being added.
410 	 * In other words, if the value is floating, then this call "assumes
411 	 * ownership" of the floating reference, converting it to a normal
412 	 * reference. If the value is not floating, then this call adds a
413 	 * new normal reference increasing the reference count by one.
414 	 * All calls that result in a GVariant instance being inserted into a
415 	 * container will call g_variant_ref_sink() on the instance. This means
416 	 * that if the value was just created (and has only its floating
417 	 * reference) then the container will assume sole ownership of the value
418 	 * at that point and the caller will not need to unreference it. This
419 	 * makes certain common styles of programming much easier while still
420 	 * maintaining normal refcounting semantics in situations where values
421 	 * are not floating.
422 	 * Since 2.24
423 	 * Returns: the same value
424 	 */
425 	public Variant refSink()
426 	{
427 		// GVariant * g_variant_ref_sink (GVariant *value);
428 		auto p = g_variant_ref_sink(gVariant);
429 		
430 		if(p is null)
431 		{
432 			return null;
433 		}
434 		
435 		return new Variant(cast(GVariant*) p);
436 	}
437 	
438 	/**
439 	 * Checks whether value has a floating reference count.
440 	 * This function should only ever be used to assert that a given variant
441 	 * is or is not floating, or for debug purposes. To acquire a reference
442 	 * to a variant that might be floating, always use g_variant_ref_sink().
443 	 * See g_variant_ref_sink() for more information about floating reference
444 	 * counts.
445 	 * Since 2.26
446 	 * Returns: whether value is floating
447 	 */
448 	public int isFloating()
449 	{
450 		// gboolean g_variant_is_floating (GVariant *value);
451 		return g_variant_is_floating(gVariant);
452 	}
453 	
454 	/**
455 	 * Determines the type of value.
456 	 * The return value is valid for the lifetime of value and must not
457 	 * be freed.
458 	 * Since 2.24
459 	 * Returns: a GVariantType
460 	 */
461 	public VariantType getType()
462 	{
463 		// const GVariantType * g_variant_get_type (GVariant *value);
464 		auto p = g_variant_get_type(gVariant);
465 		
466 		if(p is null)
467 		{
468 			return null;
469 		}
470 		
471 		return new VariantType(cast(GVariantType*) p);
472 	}
473 	
474 	/**
475 	 * Returns the type string of value. Unlike the result of calling
476 	 * g_variant_type_peek_string(), this string is nul-terminated. This
477 	 * string belongs to GVariant and must not be freed.
478 	 * Since 2.24
479 	 * Returns: the type string for the type of value
480 	 */
481 	public string getTypeString()
482 	{
483 		// const gchar * g_variant_get_type_string  (GVariant *value);
484 		return Str.toString(g_variant_get_type_string(gVariant));
485 	}
486 	
487 	/**
488 	 * Checks if a value has a type matching the provided type.
489 	 * Since 2.24
490 	 * Params:
491 	 * type = a GVariantType
492 	 * Returns: TRUE if the type of value matches type
493 	 */
494 	public int isOfType(VariantType type)
495 	{
496 		// gboolean g_variant_is_of_type (GVariant *value,  const GVariantType *type);
497 		return g_variant_is_of_type(gVariant, (type is null) ? null : type.getVariantTypeStruct());
498 	}
499 	
500 	/**
501 	 * Checks if value is a container.
502 	 * Returns: TRUE if value is a container
503 	 */
504 	public int isContainer()
505 	{
506 		// gboolean g_variant_is_container (GVariant *value);
507 		return g_variant_is_container(gVariant);
508 	}
509 	
510 	/**
511 	 * Compares one and two.
512 	 * The types of one and two are gconstpointer only to allow use of
513 	 * this function with GTree, GPtrArray, etc. They must each be a
514 	 * GVariant.
515 	 * Comparison is only defined for basic types (ie: booleans, numbers,
516 	 * strings). For booleans, FALSE is less than TRUE. Numbers are
517 	 * ordered in the usual way. Strings are in ASCII lexographical order.
518 	 * It is a programmer error to attempt to compare container values or
519 	 * two values that have types that are not exactly equal. For example,
520 	 * you can not compare a 32-bit signed integer with a 32-bit unsigned
521 	 * integer. Also note that this function is not particularly
522 	 * well-behaved when it comes to comparison of doubles; in particular,
523 	 * the handling of incomparable values (ie: NaN) is undefined.
524 	 * If you only require an equality comparison, g_variant_equal() is more
525 	 * general.
526 	 * Since 2.26
527 	 * Params:
528 	 * one = a basic-typed GVariant instance. [type GVariant]
529 	 * two = a GVariant instance of the same type. [type GVariant]
530 	 * Returns: negative value if a < b; zero if a = b; positive value if a > b.
531 	 */
532 	public static int compare(void* one, void* two)
533 	{
534 		// gint g_variant_compare (gconstpointer one,  gconstpointer two);
535 		return g_variant_compare(one, two);
536 	}
537 	
538 	/**
539 	 * Classifies value according to its top-level type.
540 	 * Since 2.24
541 	 * Returns: the GVariantClass of value
542 	 */
543 	public GVariantClass classify()
544 	{
545 		// GVariantClass g_variant_classify (GVariant *value);
546 		return g_variant_classify(gVariant);
547 	}
548 	
549 	/**
550 	 * This function is intended to be used by libraries based on GVariant
551 	 * that want to provide g_variant_get()-like functionality to their
552 	 * users.
553 	 * The API is more general than g_variant_get() to allow a wider range
554 	 * of possible uses.
555 	 * format_string must still point to a valid format string, but it only
556 	 * need to be nul-terminated if endptr is NULL. If endptr is
557 	 * non-NULL then it is updated to point to the first character past the
558 	 * end of the format string.
559 	 * app is a pointer to a va_list. The arguments, according to
560 	 * format_string, are collected from this va_list and the list is left
561 	 * pointing to the argument following the last.
562 	 * These two generalisations allow mixing of multiple calls to
563 	 * g_variant_new_va() and g_variant_get_va() within a single actual
564 	 * varargs call by the user.
565 	 * Since 2.24
566 	 * Params:
567 	 * formatString = a string that is prefixed with a format string
568 	 * endptr = location to store the end pointer,
569 	 * or NULL. [allow-none][default NULL]
570 	 * app = a pointer to a va_list
571 	 */
572 	public void getVa(string formatString, out string endptr, void** app)
573 	{
574 		// void g_variant_get_va (GVariant *value,  const gchar *format_string,  const gchar **endptr,  va_list *app);
575 		char* outendptr = null;
576 		
577 		g_variant_get_va(gVariant, Str.toStringz(formatString), &outendptr, app);
578 		
579 		endptr = Str.toString(outendptr);
580 	}
581 	
582 	/**
583 	 * This function is intended to be used by libraries based on
584 	 * GVariant that want to provide g_variant_new()-like functionality
585 	 * to their users.
586 	 * The API is more general than g_variant_new() to allow a wider range
587 	 * of possible uses.
588 	 * format_string must still point to a valid format string, but it only
589 	 * needs to be nul-terminated if endptr is NULL. If endptr is
590 	 * non-NULL then it is updated to point to the first character past the
591 	 * end of the format string.
592 	 * app is a pointer to a va_list. The arguments, according to
593 	 * format_string, are collected from this va_list and the list is left
594 	 * pointing to the argument following the last.
595 	 * These two generalisations allow mixing of multiple calls to
596 	 * g_variant_new_va() and g_variant_get_va() within a single actual
597 	 * varargs call by the user.
598 	 * The return value will be floating if it was a newly created GVariant
599 	 * instance (for example, if the format string was "(ii)"). In the case
600 	 * that the format_string was '*', '?', 'r', or a format starting with
601 	 * '@' then the collected GVariant pointer will be returned unmodified,
602 	 * without adding any additional references.
603 	 * In order to behave correctly in all cases it is necessary for the
604 	 * calling function to g_variant_ref_sink() the return result before
605 	 * returning control to the user that originally provided the pointer.
606 	 * At this point, the caller will have their own full reference to the
607 	 * result. This can also be done by adding the result to a container,
608 	 * or by passing it to another g_variant_new() call.
609 	 * Since 2.24
610 	 * Params:
611 	 * formatString = a string that is prefixed with a format string
612 	 * endptr = location to store the end pointer,
613 	 * or NULL. [allow-none][default NULL]
614 	 * app = a pointer to a va_list
615 	 * Throws: ConstructionException GTK+ fails to create the object.
616 	 */
617 	public this (string formatString, out string endptr, void** app)
618 	{
619 		// GVariant * g_variant_new_va (const gchar *format_string,  const gchar **endptr,  va_list *app);
620 		char* outendptr = null;
621 		
622 		auto p = g_variant_new_va(Str.toStringz(formatString), &outendptr, app);
623 		if(p is null)
624 		{
625 			throw new ConstructionException("null returned by g_variant_new_va(Str.toStringz(formatString), &outendptr, app)");
626 		}
627 		
628 		endptr = Str.toString(outendptr);
629 		this(cast(GVariant*) p);
630 	}
631 	
632 	/**
633 	 * Creates a new byte GVariant instance.
634 	 * Since 2.24
635 	 * Params:
636 	 * value = a guint8 value
637 	 * Throws: ConstructionException GTK+ fails to create the object.
638 	 */
639 	public this (char value)
640 	{
641 		// GVariant * g_variant_new_byte (guchar value);
642 		auto p = g_variant_new_byte(value);
643 		if(p is null)
644 		{
645 			throw new ConstructionException("null returned by g_variant_new_byte(value)");
646 		}
647 		this(cast(GVariant*) p);
648 	}
649 	
650 	/**
651 	 * Creates a new int16 GVariant instance.
652 	 * Since 2.24
653 	 * Params:
654 	 * value = a gint16 value
655 	 * Throws: ConstructionException GTK+ fails to create the object.
656 	 */
657 	public this (short value)
658 	{
659 		// GVariant * g_variant_new_int16 (gint16 value);
660 		auto p = g_variant_new_int16(value);
661 		if(p is null)
662 		{
663 			throw new ConstructionException("null returned by g_variant_new_int16(value)");
664 		}
665 		this(cast(GVariant*) p);
666 	}
667 	
668 	/**
669 	 * Creates a new uint16 GVariant instance.
670 	 * Since 2.24
671 	 * Params:
672 	 * value = a guint16 value
673 	 * Throws: ConstructionException GTK+ fails to create the object.
674 	 */
675 	public this (ushort value)
676 	{
677 		// GVariant * g_variant_new_uint16 (guint16 value);
678 		auto p = g_variant_new_uint16(value);
679 		if(p is null)
680 		{
681 			throw new ConstructionException("null returned by g_variant_new_uint16(value)");
682 		}
683 		this(cast(GVariant*) p);
684 	}
685 	
686 	/**
687 	 * Creates a new int32 GVariant instance.
688 	 * Since 2.24
689 	 * Params:
690 	 * value = a gint32 value
691 	 * Throws: ConstructionException GTK+ fails to create the object.
692 	 */
693 	public this (int value)
694 	{
695 		// GVariant * g_variant_new_int32 (gint32 value);
696 		auto p = g_variant_new_int32(value);
697 		if(p is null)
698 		{
699 			throw new ConstructionException("null returned by g_variant_new_int32(value)");
700 		}
701 		this(cast(GVariant*) p);
702 	}
703 	
704 	/**
705 	 * Creates a new uint32 GVariant instance.
706 	 * Since 2.24
707 	 * Params:
708 	 * value = a guint32 value
709 	 * Throws: ConstructionException GTK+ fails to create the object.
710 	 */
711 	public this (uint value)
712 	{
713 		// GVariant * g_variant_new_uint32 (guint32 value);
714 		auto p = g_variant_new_uint32(value);
715 		if(p is null)
716 		{
717 			throw new ConstructionException("null returned by g_variant_new_uint32(value)");
718 		}
719 		this(cast(GVariant*) p);
720 	}
721 	
722 	/**
723 	 * Creates a new int64 GVariant instance.
724 	 * Since 2.24
725 	 * Params:
726 	 * value = a gint64 value
727 	 * Throws: ConstructionException GTK+ fails to create the object.
728 	 */
729 	public this (long value)
730 	{
731 		// GVariant * g_variant_new_int64 (gint64 value);
732 		auto p = g_variant_new_int64(value);
733 		if(p is null)
734 		{
735 			throw new ConstructionException("null returned by g_variant_new_int64(value)");
736 		}
737 		this(cast(GVariant*) p);
738 	}
739 	
740 	/**
741 	 * Creates a new uint64 GVariant instance.
742 	 * Since 2.24
743 	 * Params:
744 	 * value = a guint64 value
745 	 * Throws: ConstructionException GTK+ fails to create the object.
746 	 */
747 	public this (ulong value)
748 	{
749 		// GVariant * g_variant_new_uint64 (guint64 value);
750 		auto p = g_variant_new_uint64(value);
751 		if(p is null)
752 		{
753 			throw new ConstructionException("null returned by g_variant_new_uint64(value)");
754 		}
755 		this(cast(GVariant*) p);
756 	}
757 	
758 	/**
759 	 * Creates a new double GVariant instance.
760 	 * Since 2.24
761 	 * Params:
762 	 * value = a gdouble floating point value
763 	 * Throws: ConstructionException GTK+ fails to create the object.
764 	 */
765 	public this (double value)
766 	{
767 		// GVariant * g_variant_new_double (gdouble value);
768 		auto p = g_variant_new_double(value);
769 		if(p is null)
770 		{
771 			throw new ConstructionException("null returned by g_variant_new_double(value)");
772 		}
773 		this(cast(GVariant*) p);
774 	}
775 	
776 	/**
777 	 * Creates a string GVariant with the contents of string.
778 	 * string must be valid utf8.
779 	 * Since 2.24
780 	 * Params:
781 	 * string = a normal utf8 nul-terminated string
782 	 * Throws: ConstructionException GTK+ fails to create the object.
783 	 */
784 	public this (string string)
785 	{
786 		// GVariant * g_variant_new_string (const gchar *string);
787 		auto p = g_variant_new_string(Str.toStringz(string));
788 		if(p is null)
789 		{
790 			throw new ConstructionException("null returned by g_variant_new_string(Str.toStringz(string))");
791 		}
792 		this(cast(GVariant*) p);
793 	}
794 	
795 	/**
796 	 * Determines if a given string is a valid D-Bus object path. You
797 	 * should ensure that a string is a valid D-Bus object path before
798 	 * passing it to g_variant_new_object_path().
799 	 * A valid object path starts with '/' followed by zero or more
800 	 * sequences of characters separated by '/' characters. Each sequence
801 	 * must contain only the characters "[A-Z][a-z][0-9]_". No sequence
802 	 * (including the one following the final '/' character) may be empty.
803 	 * Since 2.24
804 	 * Params:
805 	 * string = a normal C nul-terminated string
806 	 * Returns: TRUE if string is a D-Bus object path
807 	 */
808 	public static int isObjectPath(string string)
809 	{
810 		// gboolean g_variant_is_object_path (const gchar *string);
811 		return g_variant_is_object_path(Str.toStringz(string));
812 	}
813 	
814 	/**
815 	 * Determines if a given string is a valid D-Bus type signature. You
816 	 * should ensure that a string is a valid D-Bus type signature before
817 	 * passing it to g_variant_new_signature().
818 	 * D-Bus type signatures consist of zero or more definite GVariantType
819 	 * strings in sequence.
820 	 * Since 2.24
821 	 * Params:
822 	 * string = a normal C nul-terminated string
823 	 * Returns: TRUE if string is a D-Bus type signature
824 	 */
825 	public static int isSignature(string string)
826 	{
827 		// gboolean g_variant_is_signature (const gchar *string);
828 		return g_variant_is_signature(Str.toStringz(string));
829 	}
830 	
831 	/**
832 	 * Boxes value. The result is a GVariant instance representing a
833 	 * variant containing the original value.
834 	 * If child is a floating reference (see g_variant_ref_sink()), the new
835 	 * instance takes ownership of child.
836 	 * Since 2.24
837 	 * Params:
838 	 * value = a GVariant instance
839 	 * Throws: ConstructionException GTK+ fails to create the object.
840 	 */
841 	public this (Variant value)
842 	{
843 		// GVariant * g_variant_new_variant (GVariant *value);
844 		auto p = g_variant_new_variant((value is null) ? null : value.getVariantStruct());
845 		if(p is null)
846 		{
847 			throw new ConstructionException("null returned by g_variant_new_variant((value is null) ? null : value.getVariantStruct())");
848 		}
849 		this(cast(GVariant*) p);
850 	}
851 	
852 	/**
853 	 * Constructs an array of strings GVariant from the given array of
854 	 * strings.
855 	 * If length is -1 then strv is NULL-terminated.
856 	 * Since 2.24
857 	 * Params:
858 	 * strv = an array of strings. [array length=length][element-type utf8]
859 	 * Throws: ConstructionException GTK+ fails to create the object.
860 	 */
861 	public this (string[] strv)
862 	{
863 		// GVariant * g_variant_new_strv (const gchar * const *strv,  gssize length);
864 		auto p = g_variant_new_strv(Str.toStringzArray(strv), cast(int) strv.length);
865 		if(p is null)
866 		{
867 			throw new ConstructionException("null returned by g_variant_new_strv(Str.toStringzArray(strv), cast(int) strv.length)");
868 		}
869 		this(cast(GVariant*) p);
870 	}
871 	
872 	/**
873 	 * Returns the boolean value of value.
874 	 * It is an error to call this function with a value of any type
875 	 * other than G_VARIANT_TYPE_BOOLEAN.
876 	 * Since 2.24
877 	 * Returns: TRUE or FALSE
878 	 */
879 	public int getBoolean()
880 	{
881 		// gboolean g_variant_get_boolean (GVariant *value);
882 		return g_variant_get_boolean(gVariant);
883 	}
884 	
885 	/**
886 	 * Returns the byte value of value.
887 	 * It is an error to call this function with a value of any type
888 	 * other than G_VARIANT_TYPE_BYTE.
889 	 * Since 2.24
890 	 * Returns: a guchar
891 	 */
892 	public char getByte()
893 	{
894 		// guchar g_variant_get_byte (GVariant *value);
895 		return g_variant_get_byte(gVariant);
896 	}
897 	
898 	/**
899 	 * Returns the 16-bit signed integer value of value.
900 	 * It is an error to call this function with a value of any type
901 	 * other than G_VARIANT_TYPE_INT16.
902 	 * Since 2.24
903 	 * Returns: a gint16
904 	 */
905 	public short getInt16()
906 	{
907 		// gint16 g_variant_get_int16 (GVariant *value);
908 		return g_variant_get_int16(gVariant);
909 	}
910 	
911 	/**
912 	 * Returns the 16-bit unsigned integer value of value.
913 	 * It is an error to call this function with a value of any type
914 	 * other than G_VARIANT_TYPE_UINT16.
915 	 * Since 2.24
916 	 * Returns: a guint16
917 	 */
918 	public ushort getUint16()
919 	{
920 		// guint16 g_variant_get_uint16 (GVariant *value);
921 		return g_variant_get_uint16(gVariant);
922 	}
923 	
924 	/**
925 	 * Returns the 32-bit signed integer value of value.
926 	 * It is an error to call this function with a value of any type
927 	 * other than G_VARIANT_TYPE_INT32.
928 	 * Since 2.24
929 	 * Returns: a gint32
930 	 */
931 	public int getInt32()
932 	{
933 		// gint32 g_variant_get_int32 (GVariant *value);
934 		return g_variant_get_int32(gVariant);
935 	}
936 	
937 	/**
938 	 * Returns the 32-bit unsigned integer value of value.
939 	 * It is an error to call this function with a value of any type
940 	 * other than G_VARIANT_TYPE_UINT32.
941 	 * Since 2.24
942 	 * Returns: a guint32
943 	 */
944 	public uint getUint32()
945 	{
946 		// guint32 g_variant_get_uint32 (GVariant *value);
947 		return g_variant_get_uint32(gVariant);
948 	}
949 	
950 	/**
951 	 * Returns the 64-bit signed integer value of value.
952 	 * It is an error to call this function with a value of any type
953 	 * other than G_VARIANT_TYPE_INT64.
954 	 * Since 2.24
955 	 * Returns: a gint64
956 	 */
957 	public long getInt64()
958 	{
959 		// gint64 g_variant_get_int64 (GVariant *value);
960 		return g_variant_get_int64(gVariant);
961 	}
962 	
963 	/**
964 	 * Returns the 64-bit unsigned integer value of value.
965 	 * It is an error to call this function with a value of any type
966 	 * other than G_VARIANT_TYPE_UINT64.
967 	 * Since 2.24
968 	 * Returns: a guint64
969 	 */
970 	public ulong getUint64()
971 	{
972 		// guint64 g_variant_get_uint64 (GVariant *value);
973 		return g_variant_get_uint64(gVariant);
974 	}
975 	
976 	/**
977 	 * Returns the 32-bit signed integer value of value.
978 	 * It is an error to call this function with a value of any type other
979 	 * than G_VARIANT_TYPE_HANDLE.
980 	 * By convention, handles are indexes into an array of file descriptors
981 	 * that are sent alongside a D-Bus message. If you're not interacting
982 	 * with D-Bus, you probably don't need them.
983 	 * Since 2.24
984 	 * Returns: a gint32
985 	 */
986 	public int getHandle()
987 	{
988 		// gint32 g_variant_get_handle (GVariant *value);
989 		return g_variant_get_handle(gVariant);
990 	}
991 	
992 	/**
993 	 * Returns the double precision floating point value of value.
994 	 * It is an error to call this function with a value of any type
995 	 * other than G_VARIANT_TYPE_DOUBLE.
996 	 * Since 2.24
997 	 * Returns: a gdouble
998 	 */
999 	public double getDouble()
1000 	{
1001 		// gdouble g_variant_get_double (GVariant *value);
1002 		return g_variant_get_double(gVariant);
1003 	}
1004 	
1005 	/**
1006 	 * Returns the string value of a GVariant instance with a string
1007 	 * type. This includes the types G_VARIANT_TYPE_STRING,
1008 	 * G_VARIANT_TYPE_OBJECT_PATH and G_VARIANT_TYPE_SIGNATURE.
1009 	 * The string will always be utf8 encoded.
1010 	 * If length is non-NULL then the length of the string (in bytes) is
1011 	 * returned there. For trusted values, this information is already
1012 	 * known. For untrusted values, a strlen() will be performed.
1013 	 * It is an error to call this function with a value of any type
1014 	 * other than those three.
1015 	 * The return value remains valid as long as value exists.
1016 	 * Since 2.24
1017 	 * Params:
1018 	 * length = a pointer to a gsize,
1019 	 * to store the length. [allow-none][default NULL][out]
1020 	 * Returns: the constant string, utf8 encoded
1021 	 */
1022 	public string getString(out gsize length)
1023 	{
1024 		// const gchar * g_variant_get_string (GVariant *value,  gsize *length);
1025 		return Str.toString(g_variant_get_string(gVariant, &length));
1026 	}
1027 	
1028 	/**
1029 	 * Similar to g_variant_get_string() except that instead of returning
1030 	 * a constant string, the string is duplicated.
1031 	 * The string will always be utf8 encoded.
1032 	 * The return value must be freed using g_free().
1033 	 * Since 2.24
1034 	 * Returns: a newly allocated string, utf8 encoded
1035 	 */
1036 	public string dupString()
1037 	{
1038 		// gchar * g_variant_dup_string (GVariant *value,  gsize *length);
1039 		gsize length;
1040 		auto p = g_variant_dup_string(gVariant, &length);
1041 		return Str.toString(p, length);
1042 	}
1043 	
1044 	/**
1045 	 * Unboxes value. The result is the GVariant instance that was
1046 	 * contained in value.
1047 	 * Since 2.24
1048 	 * Returns: the item contained in the variant
1049 	 */
1050 	public Variant getVariant()
1051 	{
1052 		// GVariant * g_variant_get_variant (GVariant *value);
1053 		auto p = g_variant_get_variant(gVariant);
1054 		
1055 		if(p is null)
1056 		{
1057 			return null;
1058 		}
1059 		
1060 		return new Variant(cast(GVariant*) p);
1061 	}
1062 	
1063 	/**
1064 	 * Gets the contents of an array of strings GVariant. This call
1065 	 * makes a shallow copy; the return result should be released with
1066 	 * g_free(), but the individual strings must not be modified.
1067 	 * If length is non-NULL then the number of elements in the result
1068 	 * is stored there. In any case, the resulting array will be
1069 	 * NULL-terminated.
1070 	 * For an empty array, length will be set to 0 and a pointer to a
1071 	 * NULL pointer will be returned.
1072 	 * Since 2.24
1073 	 * Returns: an array of constant strings. [array length=length][transfer container]
1074 	 */
1075 	public string[] getStrv()
1076 	{
1077 		// const gchar ** g_variant_get_strv (GVariant *value,  gsize *length);
1078 		gsize length;
1079 		auto p = g_variant_get_strv(gVariant, &length);
1080 		
1081 		string[] strArray = null;
1082 		foreach ( cstr; p[0 .. length] )
1083 		{
1084 			strArray ~= Str.toString(cstr);
1085 		}
1086 		
1087 		return strArray;
1088 	}
1089 	
1090 	/**
1091 	 * Gets the contents of an array of strings GVariant. This call
1092 	 * makes a deep copy; the return result should be released with
1093 	 * g_strfreev().
1094 	 * If length is non-NULL then the number of elements in the result
1095 	 * is stored there. In any case, the resulting array will be
1096 	 * NULL-terminated.
1097 	 * For an empty array, length will be set to 0 and a pointer to a
1098 	 * NULL pointer will be returned.
1099 	 * Since 2.24
1100 	 * Returns: an array of strings. [array length=length]
1101 	 */
1102 	public string[] dupStrv()
1103 	{
1104 		// gchar ** g_variant_dup_strv (GVariant *value,  gsize *length);
1105 		gsize length;
1106 		auto p = g_variant_dup_strv(gVariant, &length);
1107 		
1108 		string[] strArray = null;
1109 		foreach ( cstr; p[0 .. length] )
1110 		{
1111 			strArray ~= Str.toString(cstr);
1112 		}
1113 		
1114 		return strArray;
1115 	}
1116 	
1117 	/**
1118 	 * Returns the string value of a GVariant instance with an
1119 	 * array-of-bytes type. The string has no particular encoding.
1120 	 * If the array does not end with a nul terminator character, the empty
1121 	 * string is returned. For this reason, you can always trust that a
1122 	 * non-NULL nul-terminated string will be returned by this function.
1123 	 * If the array contains a nul terminator character somewhere other than
1124 	 * the last byte then the returned string is the string, up to the first
1125 	 * such nul character.
1126 	 * It is an error to call this function with a value that is not an
1127 	 * array of bytes.
1128 	 * The return value remains valid as long as value exists.
1129 	 * Since 2.26
1130 	 * Returns: the constant string
1131 	 */
1132 	public string getBytestring()
1133 	{
1134 		// const gchar * g_variant_get_bytestring  (GVariant *value);
1135 		return Str.toString(g_variant_get_bytestring(gVariant));
1136 	}
1137 	
1138 	/**
1139 	 * Similar to g_variant_get_bytestring() except that instead of
1140 	 * returning a constant string, the string is duplicated.
1141 	 * The return value must be freed using g_free().
1142 	 * Since 2.26
1143 	 * Returns: a newly allocated string
1144 	 */
1145 	public string dupBytestring()
1146 	{
1147 		// gchar * g_variant_dup_bytestring  (GVariant *value,  gsize *length);
1148 		gsize length;
1149 		auto p = g_variant_dup_bytestring(gVariant, &length);
1150 		return Str.toString(p, length);
1151 	}
1152 	
1153 	/**
1154 	 * Gets the contents of an array of array of bytes GVariant. This call
1155 	 * makes a shallow copy; the return result should be released with
1156 	 * g_free(), but the individual strings must not be modified.
1157 	 * If length is non-NULL then the number of elements in the result is
1158 	 * stored there. In any case, the resulting array will be
1159 	 * NULL-terminated.
1160 	 * For an empty array, length will be set to 0 and a pointer to a
1161 	 * NULL pointer will be returned.
1162 	 * Since 2.26
1163 	 * Returns: an array of constant strings. [array length=length]
1164 	 */
1165 	public string[] getBytestringArray()
1166 	{
1167 		// const gchar ** g_variant_get_bytestring_array  (GVariant *value,  gsize *length);
1168 		gsize length;
1169 		auto p = g_variant_get_bytestring_array(gVariant, &length);
1170 		
1171 		string[] strArray = null;
1172 		foreach ( cstr; p[0 .. length] )
1173 		{
1174 			strArray ~= Str.toString(cstr);
1175 		}
1176 		
1177 		return strArray;
1178 	}
1179 	
1180 	/**
1181 	 * Gets the contents of an array of array of bytes GVariant. This call
1182 	 * makes a deep copy; the return result should be released with
1183 	 * g_strfreev().
1184 	 * If length is non-NULL then the number of elements in the result is
1185 	 * stored there. In any case, the resulting array will be
1186 	 * NULL-terminated.
1187 	 * For an empty array, length will be set to 0 and a pointer to a
1188 	 * NULL pointer will be returned.
1189 	 * Since 2.26
1190 	 * Returns: an array of strings. [array length=length]
1191 	 */
1192 	public string[] dupBytestringArray()
1193 	{
1194 		// gchar ** g_variant_dup_bytestring_array  (GVariant *value,  gsize *length);
1195 		gsize length;
1196 		auto p = g_variant_dup_bytestring_array(gVariant, &length);
1197 		
1198 		string[] strArray = null;
1199 		foreach ( cstr; p[0 .. length] )
1200 		{
1201 			strArray ~= Str.toString(cstr);
1202 		}
1203 		
1204 		return strArray;
1205 	}
1206 	
1207 	/**
1208 	 * Depending on if child is NULL, either wraps child inside of a
1209 	 * maybe container or creates a Nothing instance for the given type.
1210 	 * At least one of child_type and child must be non-NULL.
1211 	 * If child_type is non-NULL then it must be a definite type.
1212 	 * If they are both non-NULL then child_type must be the type
1213 	 * of child.
1214 	 * If child is a floating reference (see g_variant_ref_sink()), the new
1215 	 * instance takes ownership of child.
1216 	 * Since 2.24
1217 	 * Params:
1218 	 * childType = the GVariantType of the child, or NULL. [allow-none]
1219 	 * child = the child value, or NULL. [allow-none]
1220 	 * Throws: ConstructionException GTK+ fails to create the object.
1221 	 */
1222 	public this (VariantType childType, Variant child)
1223 	{
1224 		// GVariant * g_variant_new_maybe (const GVariantType *child_type,  GVariant *child);
1225 		auto p = g_variant_new_maybe((childType is null) ? null : childType.getVariantTypeStruct(), (child is null) ? null : child.getVariantStruct());
1226 		if(p is null)
1227 		{
1228 			throw new ConstructionException("null returned by g_variant_new_maybe((childType is null) ? null : childType.getVariantTypeStruct(), (child is null) ? null : child.getVariantStruct())");
1229 		}
1230 		this(cast(GVariant*) p);
1231 	}
1232 	
1233 	/**
1234 	 * Creates a new GVariant array from children.
1235 	 * child_type must be non-NULL if n_children is zero. Otherwise, the
1236 	 * child type is determined by inspecting the first element of the
1237 	 * children array. If child_type is non-NULL then it must be a
1238 	 * definite type.
1239 	 * The items of the array are taken from the children array. No entry
1240 	 * in the children array may be NULL.
1241 	 * All items in the array must have the same type, which must be the
1242 	 * same as child_type, if given.
1243 	 * If the children are floating references (see g_variant_ref_sink()), the
1244 	 * new instance takes ownership of them as if via g_variant_ref_sink().
1245 	 * Since 2.24
1246 	 * Params:
1247 	 * childType = the element type of the new array. [allow-none]
1248 	 * children = an array of
1249 	 * GVariant pointers, the children. [allow-none][array length=n_children]
1250 	 * Throws: ConstructionException GTK+ fails to create the object.
1251 	 */
1252 	public this (VariantType childType, Variant[] children)
1253 	{
1254 		// GVariant * g_variant_new_array (const GVariantType *child_type,  GVariant * const *children,  gsize n_children);
1255 		
1256 		GVariant*[] childrenArray = new GVariant*[children.length];
1257 		for ( int i = 0; i < children.length ; i++ )
1258 		{
1259 			childrenArray[i] = children[i].getVariantStruct();
1260 		}
1261 		
1262 		auto p = g_variant_new_array((childType is null) ? null : childType.getVariantTypeStruct(), childrenArray.ptr, cast(int) children.length);
1263 		if(p is null)
1264 		{
1265 			throw new ConstructionException("null returned by g_variant_new_array((childType is null) ? null : childType.getVariantTypeStruct(), childrenArray.ptr, cast(int) children.length)");
1266 		}
1267 		this(cast(GVariant*) p);
1268 	}
1269 	
1270 	/**
1271 	 * Creates a new tuple GVariant out of the items in children. The
1272 	 * type is determined from the types of children. No entry in the
1273 	 * children array may be NULL.
1274 	 * If n_children is 0 then the unit tuple is constructed.
1275 	 * If the children are floating references (see g_variant_ref_sink()), the
1276 	 * new instance takes ownership of them as if via g_variant_ref_sink().
1277 	 * Since 2.24
1278 	 * Params:
1279 	 * children = the items to make the tuple out of. [array length=n_children]
1280 	 * Throws: ConstructionException GTK+ fails to create the object.
1281 	 */
1282 	public this (Variant[] children)
1283 	{
1284 		// GVariant * g_variant_new_tuple (GVariant * const *children,  gsize n_children);
1285 		
1286 		GVariant*[] childrenArray = new GVariant*[children.length];
1287 		for ( int i = 0; i < children.length ; i++ )
1288 		{
1289 			childrenArray[i] = children[i].getVariantStruct();
1290 		}
1291 		
1292 		auto p = g_variant_new_tuple(childrenArray.ptr, cast(int) children.length);
1293 		if(p is null)
1294 		{
1295 			throw new ConstructionException("null returned by g_variant_new_tuple(childrenArray.ptr, cast(int) children.length)");
1296 		}
1297 		this(cast(GVariant*) p);
1298 	}
1299 	
1300 	/**
1301 	 * Creates a new dictionary entry GVariant. key and value must be
1302 	 * non-NULL.
1303 	 * key must be a value of a basic type (ie: not a container).
1304 	 * If the key or value are floating references (see g_variant_ref_sink()),
1305 	 * the new instance takes ownership of them as if via g_variant_ref_sink().
1306 	 * Since 2.24
1307 	 * Params:
1308 	 * key = a basic GVariant, the key
1309 	 * value = a GVariant, the value
1310 	 * Throws: ConstructionException GTK+ fails to create the object.
1311 	 */
1312 	public this (Variant key, Variant value)
1313 	{
1314 		// GVariant * g_variant_new_dict_entry  (GVariant *key,  GVariant *value);
1315 		auto p = g_variant_new_dict_entry((key is null) ? null : key.getVariantStruct(), (value is null) ? null : value.getVariantStruct());
1316 		if(p is null)
1317 		{
1318 			throw new ConstructionException("null returned by g_variant_new_dict_entry((key is null) ? null : key.getVariantStruct(), (value is null) ? null : value.getVariantStruct())");
1319 		}
1320 		this(cast(GVariant*) p);
1321 	}
1322 	
1323 	/**
1324 	 * Given a maybe-typed GVariant instance, extract its value. If the
1325 	 * value is Nothing, then this function returns NULL.
1326 	 * Since 2.24
1327 	 * Returns: the contents of value, or NULL. [allow-none]
1328 	 */
1329 	public Variant getMaybe()
1330 	{
1331 		// GVariant * g_variant_get_maybe (GVariant *value);
1332 		auto p = g_variant_get_maybe(gVariant);
1333 		
1334 		if(p is null)
1335 		{
1336 			return null;
1337 		}
1338 		
1339 		return new Variant(cast(GVariant*) p);
1340 	}
1341 	
1342 	/**
1343 	 * Determines the number of children in a container GVariant instance.
1344 	 * This includes variants, maybes, arrays, tuples and dictionary
1345 	 * entries. It is an error to call this function on any other type of
1346 	 * GVariant.
1347 	 * For variants, the return value is always 1. For values with maybe
1348 	 * types, it is always zero or one. For arrays, it is the length of the
1349 	 * array. For tuples it is the number of tuple items (which depends
1350 	 * only on the type). For dictionary entries, it is always 2
1351 	 * This function is O(1).
1352 	 * Since 2.24
1353 	 * Returns: the number of children in the container
1354 	 */
1355 	public gsize nChildren()
1356 	{
1357 		// gsize g_variant_n_children (GVariant *value);
1358 		return g_variant_n_children(gVariant);
1359 	}
1360 	
1361 	/**
1362 	 * Reads a child item out of a container GVariant instance. This
1363 	 * includes variants, maybes, arrays, tuples and dictionary
1364 	 * entries. It is an error to call this function on any other type of
1365 	 * GVariant.
1366 	 * It is an error if index_ is greater than the number of child items
1367 	 * in the container. See g_variant_n_children().
1368 	 * This function is O(1).
1369 	 * Since 2.24
1370 	 * Params:
1371 	 * index = the index of the child to fetch
1372 	 * Returns: the child at the specified index
1373 	 */
1374 	public Variant getChildValue(gsize index)
1375 	{
1376 		// GVariant * g_variant_get_child_value  (GVariant *value,  gsize index_);
1377 		auto p = g_variant_get_child_value(gVariant, index);
1378 		
1379 		if(p is null)
1380 		{
1381 			return null;
1382 		}
1383 		
1384 		return new Variant(cast(GVariant*) p);
1385 	}
1386 	
1387 	/**
1388 	 * Looks up a value in a dictionary GVariant.
1389 	 * This function works with dictionaries of the type
1390 	 * a{s*} (and equally well with type
1391 	 * a{o*}, but we only further discuss the string case
1392 	 * for sake of clarity).
1393 	 * In the event that dictionary has the type a{sv},
1394 	 * the expected_type string specifies what type of value is expected to
1395 	 * be inside of the variant. If the value inside the variant has a
1396 	 * different type then NULL is returned. In the event that dictionary
1397 	 * has a value type other than v then expected_type
1398 	 * must directly match the key type and it is used to unpack the value
1399 	 * directly or an error occurs.
1400 	 * In either case, if key is not found in dictionary, NULL is
1401 	 * returned.
1402 	 * If the key is found and the value has the correct type, it is
1403 	 * returned. If expected_type was specified then any non-NULL return
1404 	 * value will have this type.
1405 	 * Since 2.28
1406 	 * Params:
1407 	 * key = the key to lookup in the dictionary
1408 	 * expectedType = a GVariantType, or NULL
1409 	 * Returns: the value of the dictionary key, or NULL
1410 	 */
1411 	public Variant lookupValue(string key, VariantType expectedType)
1412 	{
1413 		// GVariant * g_variant_lookup_value (GVariant *dictionary,  const gchar *key,  const GVariantType *expected_type);
1414 		auto p = g_variant_lookup_value(gVariant, Str.toStringz(key), (expectedType is null) ? null : expectedType.getVariantTypeStruct());
1415 		
1416 		if(p is null)
1417 		{
1418 			return null;
1419 		}
1420 		
1421 		return new Variant(cast(GVariant*) p);
1422 	}
1423 	
1424 	/**
1425 	 * Provides access to the serialised data for an array of fixed-sized
1426 	 * items.
1427 	 * value must be an array with fixed-sized elements. Numeric types are
1428 	 * fixed-size as are tuples containing only other fixed-sized types.
1429 	 * element_size must be the size of a single element in the array. For
1430 	 * example, if calling this function for an array of 32 bit integers,
1431 	 * you might say sizeof (gint32). This value isn't used
1432 	 * except for the purpose of a double-check that the form of the
1433 	 * seralised data matches the caller's expectation.
1434 	 * n_elements, which must be non-NULL is set equal to the number of
1435 	 * items in the array.
1436 	 * Since 2.24
1437 	 * Params:
1438 	 * nElements = a pointer to the location to store the number of items
1439 	 * elementSize = the size of each element
1440 	 * Returns: a pointer to the fixed array. [array length=n_elements]
1441 	 */
1442 	public void* getFixedArray(gsize* nElements, gsize elementSize)
1443 	{
1444 		// gconstpointer g_variant_get_fixed_array (GVariant *value,  gsize *n_elements,  gsize element_size);
1445 		return g_variant_get_fixed_array(gVariant, nElements, elementSize);
1446 	}
1447 	
1448 	/**
1449 	 * Determines the number of bytes that would be required to store value
1450 	 * with g_variant_store().
1451 	 * If value has a fixed-sized type then this function always returned
1452 	 * that fixed size.
1453 	 * In the case that value is already in serialised form or the size has
1454 	 * already been calculated (ie: this function has been called before)
1455 	 * then this function is O(1). Otherwise, the size is calculated, an
1456 	 * operation which is approximately O(n) in the number of values
1457 	 * involved.
1458 	 * Since 2.24
1459 	 * Returns: the serialised size of value
1460 	 */
1461 	public gsize getSize()
1462 	{
1463 		// gsize g_variant_get_size (GVariant *value);
1464 		return g_variant_get_size(gVariant);
1465 	}
1466 	
1467 	/**
1468 	 * Returns a pointer to the serialised form of a GVariant instance.
1469 	 * The returned data may not be in fully-normalised form if read from an
1470 	 * untrusted source. The returned data must not be freed; it remains
1471 	 * valid for as long as value exists.
1472 	 * If value is a fixed-sized value that was deserialised from a
1473 	 * corrupted serialised container then NULL may be returned. In this
1474 	 * case, the proper thing to do is typically to use the appropriate
1475 	 * number of nul bytes in place of value. If value is not fixed-sized
1476 	 * then NULL is never returned.
1477 	 * In the case that value is already in serialised form, this function
1478 	 * is O(1). If the value is not already in serialised form,
1479 	 * serialisation occurs implicitly and is approximately O(n) in the size
1480 	 * of the result.
1481 	 * Since 2.24
1482 	 * Returns: the serialised form of value, or NULL
1483 	 */
1484 	public void* getData()
1485 	{
1486 		// gconstpointer g_variant_get_data (GVariant *value);
1487 		return g_variant_get_data(gVariant);
1488 	}
1489 	
1490 	/**
1491 	 * Stores the serialised form of value at data. data should be
1492 	 * large enough. See g_variant_get_size().
1493 	 * The stored data is in machine native byte order but may not be in
1494 	 * fully-normalised form if read from an untrusted source. See
1495 	 * g_variant_get_normal_form() for a solution.
1496 	 * This function is approximately O(n) in the size of data.
1497 	 * Since 2.24
1498 	 * Params:
1499 	 * data = the location to store the serialised data at
1500 	 */
1501 	public void store(void* data)
1502 	{
1503 		// void g_variant_store (GVariant *value,  gpointer data);
1504 		g_variant_store(gVariant, data);
1505 	}
1506 	
1507 	/**
1508 	 * Creates a new GVariant instance from serialised data.
1509 	 * type is the type of GVariant instance that will be constructed.
1510 	 * The interpretation of data depends on knowing the type.
1511 	 * data is not modified by this function and must remain valid with an
1512 	 * unchanging value until such a time as notify is called with
1513 	 * user_data. If the contents of data change before that time then
1514 	 * the result is undefined.
1515 	 * If data is trusted to be serialised data in normal form then
1516 	 * trusted should be TRUE. This applies to serialised data created
1517 	 * within this process or read from a trusted location on the disk (such
1518 	 * as a file installed in /usr/lib alongside your application). You
1519 	 * should set trusted to FALSE if data is read from the network, a
1520 	 * file in the user's home directory, etc.
1521 	 * notify will be called with user_data when data is no longer
1522 	 * needed. The exact time of this call is unspecified and might even be
1523 	 * before this function returns.
1524 	 * Since 2.24
1525 	 * Params:
1526 	 * type = a definite GVariantType
1527 	 * data = the serialised data
1528 	 * size = the size of data
1529 	 * trusted = TRUE if data is definitely in normal form
1530 	 * notify = function to call when data is no longer needed
1531 	 * userData = data for notify
1532 	 * Throws: ConstructionException GTK+ fails to create the object.
1533 	 */
1534 	public this (VariantType type, void* data, gsize size, int trusted, GDestroyNotify notify, void* userData)
1535 	{
1536 		// GVariant * g_variant_new_from_data  (const GVariantType *type,  gconstpointer data,  gsize size,  gboolean trusted,  GDestroyNotify notify,  gpointer user_data);
1537 		auto p = g_variant_new_from_data((type is null) ? null : type.getVariantTypeStruct(), data, size, trusted, notify, userData);
1538 		if(p is null)
1539 		{
1540 			throw new ConstructionException("null returned by g_variant_new_from_data((type is null) ? null : type.getVariantTypeStruct(), data, size, trusted, notify, userData)");
1541 		}
1542 		this(cast(GVariant*) p);
1543 	}
1544 	
1545 	/**
1546 	 * Performs a byteswapping operation on the contents of value. The
1547 	 * result is that all multi-byte numeric data contained in value is
1548 	 * byteswapped. That includes 16, 32, and 64bit signed and unsigned
1549 	 * integers as well as file handles and double precision floating point
1550 	 * values.
1551 	 * This function is an identity mapping on any value that does not
1552 	 * contain multi-byte numeric data. That include strings, booleans,
1553 	 * bytes and containers containing only these things (recursively).
1554 	 * The returned value is always in normal form and is marked as trusted.
1555 	 * Since 2.24
1556 	 * Returns: the byteswapped form of value
1557 	 */
1558 	public Variant byteswap()
1559 	{
1560 		// GVariant * g_variant_byteswap (GVariant *value);
1561 		auto p = g_variant_byteswap(gVariant);
1562 		
1563 		if(p is null)
1564 		{
1565 			return null;
1566 		}
1567 		
1568 		return new Variant(cast(GVariant*) p);
1569 	}
1570 	
1571 	/**
1572 	 * Gets a GVariant instance that has the same value as value and is
1573 	 * trusted to be in normal form.
1574 	 * If value is already trusted to be in normal form then a new
1575 	 * reference to value is returned.
1576 	 * If value is not already trusted, then it is scanned to check if it
1577 	 * is in normal form. If it is found to be in normal form then it is
1578 	 * marked as trusted and a new reference to it is returned.
1579 	 * If value is found not to be in normal form then a new trusted
1580 	 * GVariant is created with the same value as value.
1581 	 * It makes sense to call this function if you've received GVariant
1582 	 * data from untrusted sources and you want to ensure your serialised
1583 	 * output is definitely in normal form.
1584 	 * Since 2.24
1585 	 * Returns: a trusted GVariant
1586 	 */
1587 	public Variant getNormalForm()
1588 	{
1589 		// GVariant * g_variant_get_normal_form  (GVariant *value);
1590 		auto p = g_variant_get_normal_form(gVariant);
1591 		
1592 		if(p is null)
1593 		{
1594 			return null;
1595 		}
1596 		
1597 		return new Variant(cast(GVariant*) p);
1598 	}
1599 	
1600 	/**
1601 	 * Checks if value is in normal form.
1602 	 * The main reason to do this is to detect if a given chunk of
1603 	 * serialised data is in normal form: load the data into a GVariant
1604 	 * using g_variant_new_from_data() and then use this function to
1605 	 * check.
1606 	 * If value is found to be in normal form then it will be marked as
1607 	 * being trusted. If the value was already marked as being trusted then
1608 	 * this function will immediately return TRUE.
1609 	 * Since 2.24
1610 	 * Returns: TRUE if value is in normal form
1611 	 */
1612 	public int isNormalForm()
1613 	{
1614 		// gboolean g_variant_is_normal_form (GVariant *value);
1615 		return g_variant_is_normal_form(gVariant);
1616 	}
1617 	
1618 	/**
1619 	 * Generates a hash value for a GVariant instance.
1620 	 * The output of this function is guaranteed to be the same for a given
1621 	 * value only per-process. It may change between different processor
1622 	 * architectures or even different versions of GLib. Do not use this
1623 	 * function as a basis for building protocols or file formats.
1624 	 * The type of value is gconstpointer only to allow use of this
1625 	 * function with GHashTable. value must be a GVariant.
1626 	 * Since 2.24
1627 	 * Params:
1628 	 * value = a basic GVariant value as a gconstpointer. [type GVariant]
1629 	 * Returns: a hash value corresponding to value
1630 	 */
1631 	public static uint hash(void* value)
1632 	{
1633 		// guint g_variant_hash (gconstpointer value);
1634 		return g_variant_hash(value);
1635 	}
1636 	
1637 	/**
1638 	 * Checks if one and two have the same type and value.
1639 	 * The types of one and two are gconstpointer only to allow use of
1640 	 * this function with GHashTable. They must each be a GVariant.
1641 	 * Since 2.24
1642 	 * Params:
1643 	 * one = a GVariant instance. [type GVariant]
1644 	 * two = a GVariant instance. [type GVariant]
1645 	 * Returns: TRUE if one and two are equal
1646 	 */
1647 	public static int equal(void* one, void* two)
1648 	{
1649 		// gboolean g_variant_equal (gconstpointer one,  gconstpointer two);
1650 		return g_variant_equal(one, two);
1651 	}
1652 	
1653 	/**
1654 	 * Pretty-prints value in the format understood by g_variant_parse().
1655 	 * The format is described here.
1656 	 * If type_annotate is TRUE, then type information is included in
1657 	 * the output.
1658 	 * Params:
1659 	 * typeAnnotate = TRUE if type information should be included in
1660 	 * the output
1661 	 * Returns: a newly-allocated string holding the result.
1662 	 */
1663 	public string print(int typeAnnotate)
1664 	{
1665 		// gchar * g_variant_print (GVariant *value,  gboolean type_annotate);
1666 		return Str.toString(g_variant_print(gVariant, typeAnnotate));
1667 	}
1668 	
1669 	/**
1670 	 * Behaves as g_variant_print(), but operates on a GString.
1671 	 * If string is non-NULL then it is appended to and returned. Else,
1672 	 * a new empty GString is allocated and it is returned.
1673 	 * Since 2.24
1674 	 * Params:
1675 	 * string = a GString, or NULL. [allow-none][default NULL]
1676 	 * typeAnnotate = TRUE if type information should be included in
1677 	 * the output
1678 	 * Returns: a GString containing the string
1679 	 */
1680 	public StringG printString(StringG string, int typeAnnotate)
1681 	{
1682 		// GString * g_variant_print_string (GVariant *value,  GString *string,  gboolean type_annotate);
1683 		auto p = g_variant_print_string(gVariant, (string is null) ? null : string.getStringGStruct(), typeAnnotate);
1684 		
1685 		if(p is null)
1686 		{
1687 			return null;
1688 		}
1689 		
1690 		return new StringG(cast(GString*) p);
1691 	}
1692 	
1693 	/**
1694 	 * Parses a GVariant from a text representation.
1695 	 * A single GVariant is parsed from the content of text.
1696 	 * The format is described here.
1697 	 * The memory at limit will never be accessed and the parser behaves as
1698 	 * if the character at limit is the nul terminator. This has the
1699 	 * effect of bounding text.
1700 	 * If endptr is non-NULL then text is permitted to contain data
1701 	 * following the value that this function parses and endptr will be
1702 	 * updated to point to the first character past the end of the text
1703 	 * parsed by this function. If endptr is NULL and there is extra data
1704 	 * then an error is returned.
1705 	 * If type is non-NULL then the value will be parsed to have that
1706 	 * type. This may result in additional parse errors (in the case that
1707 	 * the parsed value doesn't fit the type) but may also result in fewer
1708 	 * errors (in the case that the type would have been ambiguous, such as
1709 	 * with empty arrays).
1710 	 * In the event that the parsing is successful, the resulting GVariant
1711 	 * is returned.
1712 	 * In case of any error, NULL will be returned. If error is non-NULL
1713 	 * then it will be set to reflect the error that occured.
1714 	 * Officially, the language understood by the parser is "any string
1715 	 * produced by g_variant_print()".
1716 	 * Params:
1717 	 * type = a GVariantType, or NULL
1718 	 * text = a string containing a GVariant in text form
1719 	 * limit = a pointer to the end of text, or NULL
1720 	 * endptr = a location to store the end pointer, or NULL
1721 	 * Returns: a reference to a GVariant, or NULL
1722 	 * Throws: GException on failure.
1723 	 */
1724 	public static Variant parse(VariantType type, string text, string limit, out string endptr)
1725 	{
1726 		// GVariant * g_variant_parse (const GVariantType *type,  const gchar *text,  const gchar *limit,  const gchar **endptr,  GError **error);
1727 		char* outendptr = null;
1728 		GError* err = null;
1729 		
1730 		auto p = g_variant_parse((type is null) ? null : type.getVariantTypeStruct(), Str.toStringz(text), Str.toStringz(limit), &outendptr, &err);
1731 		
1732 		if (err !is null)
1733 		{
1734 			throw new GException( new ErrorG(err) );
1735 		}
1736 		
1737 		endptr = Str.toString(outendptr);
1738 		
1739 		if(p is null)
1740 		{
1741 			return null;
1742 		}
1743 		
1744 		return new Variant(cast(GVariant*) p);
1745 	}
1746 	
1747 	/**
1748 	 * Parses format and returns the result.
1749 	 * This is the version of g_variant_new_parsed() intended to be used
1750 	 * from libraries.
1751 	 * The return value will be floating if it was a newly created GVariant
1752 	 * instance. In the case that format simply specified the collection
1753 	 * of a GVariant pointer (eg: format was "%*") then the collected
1754 	 * GVariant pointer will be returned unmodified, without adding any
1755 	 * additional references.
1756 	 * In order to behave correctly in all cases it is necessary for the
1757 	 * calling function to g_variant_ref_sink() the return result before
1758 	 * returning control to the user that originally provided the pointer.
1759 	 * At this point, the caller will have their own full reference to the
1760 	 * result. This can also be done by adding the result to a container,
1761 	 * or by passing it to another g_variant_new() call.
1762 	 * Params:
1763 	 * format = a text format GVariant
1764 	 * app = a pointer to a va_list
1765 	 * Throws: ConstructionException GTK+ fails to create the object.
1766 	 */
1767 	public this (string format, void** app)
1768 	{
1769 		// GVariant * g_variant_new_parsed_va  (const gchar *format,  va_list *app);
1770 		auto p = g_variant_new_parsed_va(Str.toStringz(format), app);
1771 		if(p is null)
1772 		{
1773 			throw new ConstructionException("null returned by g_variant_new_parsed_va(Str.toStringz(format), app)");
1774 		}
1775 		this(cast(GVariant*) p);
1776 	}
1777 }