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