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