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