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 module glib.VariantType;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 public  import glib.c.types;
31 public  import gtkc.glibtypes;
32 private import gtkd.Loader;
33 
34 
35 /**
36  * This section introduces the GVariant type system. It is based, in
37  * large part, on the D-Bus type system, with two major changes and
38  * some minor lifting of restrictions. The
39  * [D-Bus specification](http://dbus.freedesktop.org/doc/dbus-specification.html),
40  * therefore, provides a significant amount of
41  * information that is useful when working with GVariant.
42  * 
43  * The first major change with respect to the D-Bus type system is the
44  * introduction of maybe (or "nullable") types.  Any type in GVariant can be
45  * converted to a maybe type, in which case, "nothing" (or "null") becomes a
46  * valid value.  Maybe types have been added by introducing the
47  * character "m" to type strings.
48  * 
49  * The second major change is that the GVariant type system supports the
50  * concept of "indefinite types" -- types that are less specific than
51  * the normal types found in D-Bus.  For example, it is possible to speak
52  * of "an array of any type" in GVariant, where the D-Bus type system
53  * would require you to speak of "an array of integers" or "an array of
54  * strings".  Indefinite types have been added by introducing the
55  * characters "*", "?" and "r" to type strings.
56  * 
57  * Finally, all arbitrary restrictions relating to the complexity of
58  * types are lifted along with the restriction that dictionary entries
59  * may only appear nested inside of arrays.
60  * 
61  * Just as in D-Bus, GVariant types are described with strings ("type
62  * strings").  Subject to the differences mentioned above, these strings
63  * are of the same form as those found in DBus.  Note, however: D-Bus
64  * always works in terms of messages and therefore individual type
65  * strings appear nowhere in its interface.  Instead, "signatures"
66  * are a concatenation of the strings of the type of each argument in a
67  * message.  GVariant deals with single values directly so GVariant type
68  * strings always describe the type of exactly one value.  This means
69  * that a D-Bus signature string is generally not a valid GVariant type
70  * string -- except in the case that it is the signature of a message
71  * containing exactly one argument.
72  * 
73  * An indefinite type is similar in spirit to what may be called an
74  * abstract type in other type systems.  No value can exist that has an
75  * indefinite type as its type, but values can exist that have types
76  * that are subtypes of indefinite types.  That is to say,
77  * g_variant_get_type() will never return an indefinite type, but
78  * calling g_variant_is_of_type() with an indefinite type may return
79  * %TRUE.  For example, you cannot have a value that represents "an
80  * array of no particular type", but you can have an "array of integers"
81  * which certainly matches the type of "an array of no particular type",
82  * since "array of integers" is a subtype of "array of no particular
83  * type".
84  * 
85  * This is similar to how instances of abstract classes may not
86  * directly exist in other type systems, but instances of their
87  * non-abstract subtypes may.  For example, in GTK, no object that has
88  * the type of #GtkBin can exist (since #GtkBin is an abstract class),
89  * but a #GtkWindow can certainly be instantiated, and you would say
90  * that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
91  * #GtkBin).
92  * 
93  * ## GVariant Type Strings
94  * 
95  * A GVariant type string can be any of the following:
96  * 
97  * - any basic type string (listed below)
98  * 
99  * - "v", "r" or "*"
100  * 
101  * - one of the characters 'a' or 'm', followed by another type string
102  * 
103  * - the character '(', followed by a concatenation of zero or more other
104  * type strings, followed by the character ')'
105  * 
106  * - the character '{', followed by a basic type string (see below),
107  * followed by another type string, followed by the character '}'
108  * 
109  * A basic type string describes a basic type (as per
110  * g_variant_type_is_basic()) and is always a single character in length.
111  * The valid basic type strings are "b", "y", "n", "q", "i", "u", "x", "t",
112  * "h", "d", "s", "o", "g" and "?".
113  * 
114  * The above definition is recursive to arbitrary depth. "aaaaai" and
115  * "(ui(nq((y)))s)" are both valid type strings, as is
116  * "a(aa(ui)(qna{ya(yd)}))". In order to not hit memory limits, #GVariant
117  * imposes a limit on recursion depth of 65 nested containers. This is the
118  * limit in the D-Bus specification (64) plus one to allow a #GDBusMessage to
119  * be nested in a top-level tuple.
120  * 
121  * The meaning of each of the characters is as follows:
122  * - `b`: the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
123  * - `y`: the type string of %G_VARIANT_TYPE_BYTE; a byte.
124  * - `n`: the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit integer.
125  * - `q`: the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit integer.
126  * - `i`: the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit integer.
127  * - `u`: the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit integer.
128  * - `x`: the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit integer.
129  * - `t`: the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit integer.
130  * - `h`: the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit value
131  * that, by convention, is used as an index into an array of file
132  * descriptors that are sent alongside a D-Bus message.
133  * - `d`: the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
134  * floating point value.
135  * - `s`: the type string of %G_VARIANT_TYPE_STRING; a string.
136  * - `o`: the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in the form
137  * of a D-Bus object path.
138  * - `g`: the type string of %G_VARIANT_TYPE_SIGNATURE; a string in the form of
139  * a D-Bus type signature.
140  * - `?`: the type string of %G_VARIANT_TYPE_BASIC; an indefinite type that
141  * is a supertype of any of the basic types.
142  * - `v`: the type string of %G_VARIANT_TYPE_VARIANT; a container type that
143  * contain any other type of value.
144  * - `a`: used as a prefix on another type string to mean an array of that
145  * type; the type string "ai", for example, is the type of an array of
146  * signed 32-bit integers.
147  * - `m`: used as a prefix on another type string to mean a "maybe", or
148  * "nullable", version of that type; the type string "ms", for example,
149  * is the type of a value that maybe contains a string, or maybe contains
150  * nothing.
151  * - `()`: used to enclose zero or more other concatenated type strings to
152  * create a tuple type; the type string "(is)", for example, is the type of
153  * a pair of an integer and a string.
154  * - `r`: the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type that is
155  * a supertype of any tuple type, regardless of the number of items.
156  * - `{}`: used to enclose a basic type string concatenated with another type
157  * string to create a dictionary entry type, which usually appears inside of
158  * an array to form a dictionary; the type string "a{sd}", for example, is
159  * the type of a dictionary that maps strings to double precision floating
160  * point values.
161  * 
162  * The first type (the basic type) is the key type and the second type is
163  * the value type. The reason that the first type is restricted to being a
164  * basic type is so that it can easily be hashed.
165  * - `*`: the type string of %G_VARIANT_TYPE_ANY; the indefinite type that is
166  * a supertype of all types.  Note that, as with all type strings, this
167  * character represents exactly one type. It cannot be used inside of tuples
168  * to mean "any number of items".
169  * 
170  * Any type string of a container that contains an indefinite type is,
171  * itself, an indefinite type. For example, the type string "a*"
172  * (corresponding to %G_VARIANT_TYPE_ARRAY) is an indefinite type
173  * that is a supertype of every array type. "(*s)" is a supertype
174  * of all tuples that contain exactly two items where the second
175  * item is a string.
176  * 
177  * "a{?*}" is an indefinite type that is a supertype of all arrays
178  * containing dictionary entries where the key is any basic type and
179  * the value is any type at all.  This is, by definition, a dictionary,
180  * so this type string corresponds to %G_VARIANT_TYPE_DICTIONARY. Note
181  * that, due to the restriction that the key of a dictionary entry must
182  * be a basic type, "{**}" is not a valid type string.
183  */
184 public class VariantType
185 {
186 	/** the main Gtk struct */
187 	protected GVariantType* gVariantType;
188 	protected bool ownedRef;
189 
190 	/** Get the main Gtk struct */
191 	public GVariantType* getVariantTypeStruct(bool transferOwnership = false)
192 	{
193 		if (transferOwnership)
194 			ownedRef = false;
195 		return gVariantType;
196 	}
197 
198 	/** the main Gtk struct as a void* */
199 	protected void* getStruct()
200 	{
201 		return cast(void*)gVariantType;
202 	}
203 
204 	/**
205 	 * Sets our main struct and passes it to the parent class.
206 	 */
207 	public this (GVariantType* gVariantType, bool ownedRef = false)
208 	{
209 		this.gVariantType = gVariantType;
210 		this.ownedRef = ownedRef;
211 	}
212 
213 	~this ()
214 	{
215 		if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef )
216 			g_variant_type_free(gVariantType);
217 	}
218 
219 	/**
220 	 * Constructs the type corresponding to a maybe instance containing
221 	 * type type or Nothing.
222 	 *
223 	 * It is appropriate to call free() on the return value.
224 	 *
225 	 * Params:
226 	 *     element = a VariantType
227 	 *
228 	 * Return: a new maybe VariantType
229 	 *
230 	 *     Since 2.24
231 	 *
232 	 * Throws: ConstructionException GTK+ fails to create the object.
233 	 */
234 	public static VariantType newMaybe(VariantType element)
235 	{
236 		auto p = g_variant_type_new_maybe((element is null) ? null : element.getVariantTypeStruct());
237 
238 		if(p is null)
239 		{
240 			throw new ConstructionException("null returned by new_maybe");
241 		}
242 
243 		return new VariantType(cast(GVariantType*) p);
244 	}
245 
246 	/**
247 	 */
248 
249 	/**
250 	 * Creates a new #GVariantType corresponding to the type string given
251 	 * by @type_string.  It is appropriate to call g_variant_type_free() on
252 	 * the return value.
253 	 *
254 	 * It is a programmer error to call this function with an invalid type
255 	 * string.  Use g_variant_type_string_is_valid() if you are unsure.
256 	 *
257 	 * Params:
258 	 *     typeString = a valid GVariant type string
259 	 *
260 	 * Returns: a new #GVariantType
261 	 *
262 	 * Since: 2.24
263 	 *
264 	 * Throws: ConstructionException GTK+ fails to create the object.
265 	 */
266 	public this(string typeString)
267 	{
268 		auto __p = g_variant_type_new(Str.toStringz(typeString));
269 
270 		if(__p is null)
271 		{
272 			throw new ConstructionException("null returned by new");
273 		}
274 
275 		this(cast(GVariantType*) __p);
276 	}
277 
278 	/**
279 	 * Constructs the type corresponding to an array of elements of the
280 	 * type @type.
281 	 *
282 	 * It is appropriate to call g_variant_type_free() on the return value.
283 	 *
284 	 * Params:
285 	 *     element = a #GVariantType
286 	 *
287 	 * Returns: a new array #GVariantType
288 	 *
289 	 *     Since 2.24
290 	 *
291 	 * Throws: ConstructionException GTK+ fails to create the object.
292 	 */
293 	public this(VariantType element)
294 	{
295 		auto __p = g_variant_type_new_array((element is null) ? null : element.getVariantTypeStruct());
296 
297 		if(__p is null)
298 		{
299 			throw new ConstructionException("null returned by new_array");
300 		}
301 
302 		this(cast(GVariantType*) __p);
303 	}
304 
305 	/**
306 	 * Constructs the type corresponding to a dictionary entry with a key
307 	 * of type @key and a value of type @value.
308 	 *
309 	 * It is appropriate to call g_variant_type_free() on the return value.
310 	 *
311 	 * Params:
312 	 *     key = a basic #GVariantType
313 	 *     value = a #GVariantType
314 	 *
315 	 * Returns: a new dictionary entry #GVariantType
316 	 *
317 	 *     Since 2.24
318 	 *
319 	 * Throws: ConstructionException GTK+ fails to create the object.
320 	 */
321 	public this(VariantType key, VariantType value)
322 	{
323 		auto __p = g_variant_type_new_dict_entry((key is null) ? null : key.getVariantTypeStruct(), (value is null) ? null : value.getVariantTypeStruct());
324 
325 		if(__p is null)
326 		{
327 			throw new ConstructionException("null returned by new_dict_entry");
328 		}
329 
330 		this(cast(GVariantType*) __p);
331 	}
332 
333 	/**
334 	 * Constructs a new tuple type, from @items.
335 	 *
336 	 * @length is the number of items in @items, or -1 to indicate that
337 	 * @items is %NULL-terminated.
338 	 *
339 	 * It is appropriate to call g_variant_type_free() on the return value.
340 	 *
341 	 * Params:
342 	 *     items = an array of #GVariantTypes, one for each item
343 	 *
344 	 * Returns: a new tuple #GVariantType
345 	 *
346 	 *     Since 2.24
347 	 *
348 	 * Throws: ConstructionException GTK+ fails to create the object.
349 	 */
350 	public this(VariantType[] items)
351 	{
352 		GVariantType*[] itemsArray = new GVariantType*[items.length];
353 		for ( int i = 0; i < items.length; i++ )
354 		{
355 			itemsArray[i] = items[i].getVariantTypeStruct();
356 		}
357 
358 		auto __p = g_variant_type_new_tuple(itemsArray.ptr, cast(int)items.length);
359 
360 		if(__p is null)
361 		{
362 			throw new ConstructionException("null returned by new_tuple");
363 		}
364 
365 		this(cast(GVariantType*) __p);
366 	}
367 
368 	/**
369 	 * Makes a copy of a #GVariantType.  It is appropriate to call
370 	 * g_variant_type_free() on the return value.  @type may not be %NULL.
371 	 *
372 	 * Returns: a new #GVariantType
373 	 *
374 	 *     Since 2.24
375 	 */
376 	public VariantType copy()
377 	{
378 		auto __p = g_variant_type_copy(gVariantType);
379 
380 		if(__p is null)
381 		{
382 			return null;
383 		}
384 
385 		return new VariantType(cast(GVariantType*) __p, true);
386 	}
387 
388 	/**
389 	 * Returns a newly-allocated copy of the type string corresponding to
390 	 * @type.  The returned string is nul-terminated.  It is appropriate to
391 	 * call g_free() on the return value.
392 	 *
393 	 * Returns: the corresponding type string
394 	 *
395 	 *     Since 2.24
396 	 */
397 	public string dupString()
398 	{
399 		auto retStr = g_variant_type_dup_string(gVariantType);
400 
401 		scope(exit) Str.freeString(retStr);
402 		return Str.toString(retStr);
403 	}
404 
405 	/**
406 	 * Determines the element type of an array or maybe type.
407 	 *
408 	 * This function may only be used with array or maybe types.
409 	 *
410 	 * Returns: the element type of @type
411 	 *
412 	 *     Since 2.24
413 	 */
414 	public VariantType element()
415 	{
416 		auto __p = g_variant_type_element(gVariantType);
417 
418 		if(__p is null)
419 		{
420 			return null;
421 		}
422 
423 		return new VariantType(cast(GVariantType*) __p);
424 	}
425 
426 	/**
427 	 * Compares @type1 and @type2 for equality.
428 	 *
429 	 * Only returns %TRUE if the types are exactly equal.  Even if one type
430 	 * is an indefinite type and the other is a subtype of it, %FALSE will
431 	 * be returned if they are not exactly equal.  If you want to check for
432 	 * subtypes, use g_variant_type_is_subtype_of().
433 	 *
434 	 * The argument types of @type1 and @type2 are only #gconstpointer to
435 	 * allow use with #GHashTable without function pointer casting.  For
436 	 * both arguments, a valid #GVariantType must be provided.
437 	 *
438 	 * Params:
439 	 *     type2 = a #GVariantType
440 	 *
441 	 * Returns: %TRUE if @type1 and @type2 are exactly equal
442 	 *
443 	 *     Since 2.24
444 	 */
445 	public bool equal(VariantType type2)
446 	{
447 		return g_variant_type_equal(gVariantType, (type2 is null) ? null : type2.getVariantTypeStruct()) != 0;
448 	}
449 
450 	/**
451 	 * Determines the first item type of a tuple or dictionary entry
452 	 * type.
453 	 *
454 	 * This function may only be used with tuple or dictionary entry types,
455 	 * but must not be used with the generic tuple type
456 	 * %G_VARIANT_TYPE_TUPLE.
457 	 *
458 	 * In the case of a dictionary entry type, this returns the type of
459 	 * the key.
460 	 *
461 	 * %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
462 	 *
463 	 * This call, together with g_variant_type_next() provides an iterator
464 	 * interface over tuple and dictionary entry types.
465 	 *
466 	 * Returns: the first item type of @type, or %NULL
467 	 *
468 	 *     Since 2.24
469 	 */
470 	public VariantType first()
471 	{
472 		auto __p = g_variant_type_first(gVariantType);
473 
474 		if(__p is null)
475 		{
476 			return null;
477 		}
478 
479 		return new VariantType(cast(GVariantType*) __p);
480 	}
481 
482 	/**
483 	 * Frees a #GVariantType that was allocated with
484 	 * g_variant_type_copy(), g_variant_type_new() or one of the container
485 	 * type constructor functions.
486 	 *
487 	 * In the case that @type is %NULL, this function does nothing.
488 	 *
489 	 * Since 2.24
490 	 */
491 	public void free()
492 	{
493 		g_variant_type_free(gVariantType);
494 		ownedRef = false;
495 	}
496 
497 	/**
498 	 * Returns the length of the type string corresponding to the given
499 	 * @type.  This function must be used to determine the valid extent of
500 	 * the memory region returned by g_variant_type_peek_string().
501 	 *
502 	 * Returns: the length of the corresponding type string
503 	 *
504 	 *     Since 2.24
505 	 */
506 	public size_t getStringLength()
507 	{
508 		return g_variant_type_get_string_length(gVariantType);
509 	}
510 
511 	/**
512 	 * Hashes @type.
513 	 *
514 	 * The argument type of @type is only #gconstpointer to allow use with
515 	 * #GHashTable without function pointer casting.  A valid
516 	 * #GVariantType must be provided.
517 	 *
518 	 * Returns: the hash value
519 	 *
520 	 *     Since 2.24
521 	 */
522 	public uint hash()
523 	{
524 		return g_variant_type_hash(gVariantType);
525 	}
526 
527 	/**
528 	 * Determines if the given @type is an array type.  This is true if the
529 	 * type string for @type starts with an 'a'.
530 	 *
531 	 * This function returns %TRUE for any indefinite type for which every
532 	 * definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
533 	 * example.
534 	 *
535 	 * Returns: %TRUE if @type is an array type
536 	 *
537 	 *     Since 2.24
538 	 */
539 	public bool isArray()
540 	{
541 		return g_variant_type_is_array(gVariantType) != 0;
542 	}
543 
544 	/**
545 	 * Determines if the given @type is a basic type.
546 	 *
547 	 * Basic types are booleans, bytes, integers, doubles, strings, object
548 	 * paths and signatures.
549 	 *
550 	 * Only a basic type may be used as the key of a dictionary entry.
551 	 *
552 	 * This function returns %FALSE for all indefinite types except
553 	 * %G_VARIANT_TYPE_BASIC.
554 	 *
555 	 * Returns: %TRUE if @type is a basic type
556 	 *
557 	 *     Since 2.24
558 	 */
559 	public bool isBasic()
560 	{
561 		return g_variant_type_is_basic(gVariantType) != 0;
562 	}
563 
564 	/**
565 	 * Determines if the given @type is a container type.
566 	 *
567 	 * Container types are any array, maybe, tuple, or dictionary
568 	 * entry types plus the variant type.
569 	 *
570 	 * This function returns %TRUE for any indefinite type for which every
571 	 * definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
572 	 * example.
573 	 *
574 	 * Returns: %TRUE if @type is a container type
575 	 *
576 	 *     Since 2.24
577 	 */
578 	public bool isContainer()
579 	{
580 		return g_variant_type_is_container(gVariantType) != 0;
581 	}
582 
583 	/**
584 	 * Determines if the given @type is definite (ie: not indefinite).
585 	 *
586 	 * A type is definite if its type string does not contain any indefinite
587 	 * type characters ('*', '?', or 'r').
588 	 *
589 	 * A #GVariant instance may not have an indefinite type, so calling
590 	 * this function on the result of g_variant_get_type() will always
591 	 * result in %TRUE being returned.  Calling this function on an
592 	 * indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
593 	 * %FALSE being returned.
594 	 *
595 	 * Returns: %TRUE if @type is definite
596 	 *
597 	 *     Since 2.24
598 	 */
599 	public bool isDefinite()
600 	{
601 		return g_variant_type_is_definite(gVariantType) != 0;
602 	}
603 
604 	/**
605 	 * Determines if the given @type is a dictionary entry type.  This is
606 	 * true if the type string for @type starts with a '{'.
607 	 *
608 	 * This function returns %TRUE for any indefinite type for which every
609 	 * definite subtype is a dictionary entry type --
610 	 * %G_VARIANT_TYPE_DICT_ENTRY, for example.
611 	 *
612 	 * Returns: %TRUE if @type is a dictionary entry type
613 	 *
614 	 *     Since 2.24
615 	 */
616 	public bool isDictEntry()
617 	{
618 		return g_variant_type_is_dict_entry(gVariantType) != 0;
619 	}
620 
621 	/**
622 	 * Determines if the given @type is a maybe type.  This is true if the
623 	 * type string for @type starts with an 'm'.
624 	 *
625 	 * This function returns %TRUE for any indefinite type for which every
626 	 * definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
627 	 * example.
628 	 *
629 	 * Returns: %TRUE if @type is a maybe type
630 	 *
631 	 *     Since 2.24
632 	 */
633 	public bool isMaybe()
634 	{
635 		return g_variant_type_is_maybe(gVariantType) != 0;
636 	}
637 
638 	/**
639 	 * Checks if @type is a subtype of @supertype.
640 	 *
641 	 * This function returns %TRUE if @type is a subtype of @supertype.  All
642 	 * types are considered to be subtypes of themselves.  Aside from that,
643 	 * only indefinite types can have subtypes.
644 	 *
645 	 * Params:
646 	 *     supertype = a #GVariantType
647 	 *
648 	 * Returns: %TRUE if @type is a subtype of @supertype
649 	 *
650 	 *     Since 2.24
651 	 */
652 	public bool isSubtypeOf(VariantType supertype)
653 	{
654 		return g_variant_type_is_subtype_of(gVariantType, (supertype is null) ? null : supertype.getVariantTypeStruct()) != 0;
655 	}
656 
657 	/**
658 	 * Determines if the given @type is a tuple type.  This is true if the
659 	 * type string for @type starts with a '(' or if @type is
660 	 * %G_VARIANT_TYPE_TUPLE.
661 	 *
662 	 * This function returns %TRUE for any indefinite type for which every
663 	 * definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
664 	 * example.
665 	 *
666 	 * Returns: %TRUE if @type is a tuple type
667 	 *
668 	 *     Since 2.24
669 	 */
670 	public bool isTuple()
671 	{
672 		return g_variant_type_is_tuple(gVariantType) != 0;
673 	}
674 
675 	/**
676 	 * Determines if the given @type is the variant type.
677 	 *
678 	 * Returns: %TRUE if @type is the variant type
679 	 *
680 	 *     Since 2.24
681 	 */
682 	public bool isVariant()
683 	{
684 		return g_variant_type_is_variant(gVariantType) != 0;
685 	}
686 
687 	/**
688 	 * Determines the key type of a dictionary entry type.
689 	 *
690 	 * This function may only be used with a dictionary entry type.  Other
691 	 * than the additional restriction, this call is equivalent to
692 	 * g_variant_type_first().
693 	 *
694 	 * Returns: the key type of the dictionary entry
695 	 *
696 	 *     Since 2.24
697 	 */
698 	public VariantType key()
699 	{
700 		auto __p = g_variant_type_key(gVariantType);
701 
702 		if(__p is null)
703 		{
704 			return null;
705 		}
706 
707 		return new VariantType(cast(GVariantType*) __p);
708 	}
709 
710 	/**
711 	 * Determines the number of items contained in a tuple or
712 	 * dictionary entry type.
713 	 *
714 	 * This function may only be used with tuple or dictionary entry types,
715 	 * but must not be used with the generic tuple type
716 	 * %G_VARIANT_TYPE_TUPLE.
717 	 *
718 	 * In the case of a dictionary entry type, this function will always
719 	 * return 2.
720 	 *
721 	 * Returns: the number of items in @type
722 	 *
723 	 *     Since 2.24
724 	 */
725 	public size_t nItems()
726 	{
727 		return g_variant_type_n_items(gVariantType);
728 	}
729 
730 	/**
731 	 * Determines the next item type of a tuple or dictionary entry
732 	 * type.
733 	 *
734 	 * @type must be the result of a previous call to
735 	 * g_variant_type_first() or g_variant_type_next().
736 	 *
737 	 * If called on the key type of a dictionary entry then this call
738 	 * returns the value type.  If called on the value type of a dictionary
739 	 * entry then this call returns %NULL.
740 	 *
741 	 * For tuples, %NULL is returned when @type is the last item in a tuple.
742 	 *
743 	 * Returns: the next #GVariantType after @type, or %NULL
744 	 *
745 	 *     Since 2.24
746 	 */
747 	public VariantType next()
748 	{
749 		auto __p = g_variant_type_next(gVariantType);
750 
751 		if(__p is null)
752 		{
753 			return null;
754 		}
755 
756 		return new VariantType(cast(GVariantType*) __p);
757 	}
758 
759 	/**
760 	 * Returns the type string corresponding to the given @type.  The
761 	 * result is not nul-terminated; in order to determine its length you
762 	 * must call g_variant_type_get_string_length().
763 	 *
764 	 * To get a nul-terminated string, see g_variant_type_dup_string().
765 	 *
766 	 * Returns: the corresponding type string (not nul-terminated)
767 	 *
768 	 *     Since 2.24
769 	 */
770 	public string peekString()
771 	{
772 		return Str.toString(g_variant_type_peek_string(gVariantType));
773 	}
774 
775 	/**
776 	 * Determines the value type of a dictionary entry type.
777 	 *
778 	 * This function may only be used with a dictionary entry type.
779 	 *
780 	 * Returns: the value type of the dictionary entry
781 	 *
782 	 *     Since 2.24
783 	 */
784 	public VariantType value()
785 	{
786 		auto __p = g_variant_type_value(gVariantType);
787 
788 		if(__p is null)
789 		{
790 			return null;
791 		}
792 
793 		return new VariantType(cast(GVariantType*) __p);
794 	}
795 
796 	/** */
797 	public static VariantType checked(string arg0)
798 	{
799 		auto __p = g_variant_type_checked_(Str.toStringz(arg0));
800 
801 		if(__p is null)
802 		{
803 			return null;
804 		}
805 
806 		return new VariantType(cast(GVariantType*) __p);
807 	}
808 
809 	/** */
810 	public static size_t stringGetDepth(string typeString)
811 	{
812 		return g_variant_type_string_get_depth_(Str.toStringz(typeString));
813 	}
814 
815 	/**
816 	 * Checks if @type_string is a valid GVariant type string.  This call is
817 	 * equivalent to calling g_variant_type_string_scan() and confirming
818 	 * that the following character is a nul terminator.
819 	 *
820 	 * Params:
821 	 *     typeString = a pointer to any string
822 	 *
823 	 * Returns: %TRUE if @type_string is exactly one valid type string
824 	 *
825 	 *     Since 2.24
826 	 */
827 	public static bool stringIsValid(string typeString)
828 	{
829 		return g_variant_type_string_is_valid(Str.toStringz(typeString)) != 0;
830 	}
831 
832 	/**
833 	 * Scan for a single complete and valid GVariant type string in @string.
834 	 * The memory pointed to by @limit (or bytes beyond it) is never
835 	 * accessed.
836 	 *
837 	 * If a valid type string is found, @endptr is updated to point to the
838 	 * first character past the end of the string that was found and %TRUE
839 	 * is returned.
840 	 *
841 	 * If there is no valid type string starting at @string, or if the type
842 	 * string does not end before @limit then %FALSE is returned.
843 	 *
844 	 * For the simple case of checking if a string is a valid type string,
845 	 * see g_variant_type_string_is_valid().
846 	 *
847 	 * Params:
848 	 *     string_ = a pointer to any string
849 	 *     limit = the end of @string, or %NULL
850 	 *     endptr = location to store the end pointer, or %NULL
851 	 *
852 	 * Returns: %TRUE if a valid type string was found
853 	 *
854 	 * Since: 2.24
855 	 */
856 	public static bool stringScan(string string_, string limit, out string endptr)
857 	{
858 		char* outendptr = null;
859 
860 		auto __p = g_variant_type_string_scan(Str.toStringz(string_), Str.toStringz(limit), &outendptr) != 0;
861 
862 		endptr = Str.toString(outendptr);
863 
864 		return __p;
865 	}
866 }