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