source: appstream-generator/build/girepo/glib/Variant.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 71.9 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.Variant;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.Bytes;
26private import glib.ConstructionException;
27private import glib.ErrorG;
28private import glib.GException;
29private import glib.Str;
30private import glib.StringG;
31private import glib.VariantIter;
32private import glib.VariantType;
33
34
35/**
36 * #GVariant is a variant datatype; it stores a value along with
37 * information about the type of that value.  The range of possible
38 * values is determined by the type.  The type system used by #GVariant
39 * is #GVariantType.
40 *
41 * #GVariant instances always have a type and a value (which are given
42 * at construction time).  The type and value of a #GVariant instance
43 * can never change other than by the #GVariant itself being
44 * destroyed.  A #GVariant cannot contain a pointer.
45 *
46 * #GVariant is reference counted using g_variant_ref() and
47 * g_variant_unref().  #GVariant also has floating reference counts --
48 * see g_variant_ref_sink().
49 *
50 * #GVariant is completely threadsafe.  A #GVariant instance can be
51 * concurrently accessed in any way from any number of threads without
52 * problems.
53 *
54 * #GVariant is heavily optimised for dealing with data in serialised
55 * form.  It works particularly well with data located in memory-mapped
56 * files.  It can perform nearly all deserialisation operations in a
57 * small constant time, usually touching only a single memory page.
58 * Serialised #GVariant data can also be sent over the network.
59 *
60 * #GVariant is largely compatible with D-Bus.  Almost all types of
61 * #GVariant instances can be sent over D-Bus.  See #GVariantType for
62 * exceptions.  (However, #GVariant's serialisation format is not the same
63 * as the serialisation format of a D-Bus message body: use #GDBusMessage,
64 * in the gio library, for those.)
65 *
66 * For space-efficiency, the #GVariant serialisation format does not
67 * automatically include the variant's length, type or endianness,
68 * which must either be implied from context (such as knowledge that a
69 * particular file format always contains a little-endian
70 * %G_VARIANT_TYPE_VARIANT which occupies the whole length of the file)
71 * or supplied out-of-band (for instance, a length, type and/or endianness
72 * indicator could be placed at the beginning of a file, network message
73 * or network stream).
74 *
75 * A #GVariant's size is limited mainly by any lower level operating
76 * system constraints, such as the number of bits in #gsize.  For
77 * example, it is reasonable to have a 2GB file mapped into memory
78 * with #GMappedFile, and call g_variant_new_from_data() on it.
79 *
80 * For convenience to C programmers, #GVariant features powerful
81 * varargs-based value construction and destruction.  This feature is
82 * designed to be embedded in other libraries.
83 *
84 * There is a Python-inspired text language for describing #GVariant
85 * values.  #GVariant includes a printer for this language and a parser
86 * with type inferencing.
87 *
88 * ## Memory Use
89 *
90 * #GVariant tries to be quite efficient with respect to memory use.
91 * This section gives a rough idea of how much memory is used by the
92 * current implementation.  The information here is subject to change
93 * in the future.
94 *
95 * The memory allocated by #GVariant can be grouped into 4 broad
96 * purposes: memory for serialised data, memory for the type
97 * information cache, buffer management memory and memory for the
98 * #GVariant structure itself.
99 *
100 * ## Serialised Data Memory
101 *
102 * This is the memory that is used for storing GVariant data in
103 * serialised form.  This is what would be sent over the network or
104 * what would end up on disk, not counting any indicator of the
105 * endianness, or of the length or type of the top-level variant.
106 *
107 * The amount of memory required to store a boolean is 1 byte. 16,
108 * 32 and 64 bit integers and double precision floating point numbers
109 * use their "natural" size.  Strings (including object path and
110 * signature strings) are stored with a nul terminator, and as such
111 * use the length of the string plus 1 byte.
112 *
113 * Maybe types use no space at all to represent the null value and
114 * use the same amount of space (sometimes plus one byte) as the
115 * equivalent non-maybe-typed value to represent the non-null case.
116 *
117 * Arrays use the amount of space required to store each of their
118 * members, concatenated.  Additionally, if the items stored in an
119 * array are not of a fixed-size (ie: strings, other arrays, etc)
120 * then an additional framing offset is stored for each item.  The
121 * size of this offset is either 1, 2 or 4 bytes depending on the
122 * overall size of the container.  Additionally, extra padding bytes
123 * are added as required for alignment of child values.
124 *
125 * Tuples (including dictionary entries) use the amount of space
126 * required to store each of their members, concatenated, plus one
127 * framing offset (as per arrays) for each non-fixed-sized item in
128 * the tuple, except for the last one.  Additionally, extra padding
129 * bytes are added as required for alignment of child values.
130 *
131 * Variants use the same amount of space as the item inside of the
132 * variant, plus 1 byte, plus the length of the type string for the
133 * item inside the variant.
134 *
135 * As an example, consider a dictionary mapping strings to variants.
136 * In the case that the dictionary is empty, 0 bytes are required for
137 * the serialisation.
138 *
139 * If we add an item "width" that maps to the int32 value of 500 then
140 * we will use 4 byte to store the int32 (so 6 for the variant
141 * containing it) and 6 bytes for the string.  The variant must be
142 * aligned to 8 after the 6 bytes of the string, so that's 2 extra
143 * bytes.  6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
144 * for the dictionary entry.  An additional 1 byte is added to the
145 * array as a framing offset making a total of 15 bytes.
146 *
147 * If we add another entry, "title" that maps to a nullable string
148 * that happens to have a value of null, then we use 0 bytes for the
149 * null value (and 3 bytes for the variant to contain it along with
150 * its type string) plus 6 bytes for the string.  Again, we need 2
151 * padding bytes.  That makes a total of 6 + 2 + 3 = 11 bytes.
152 *
153 * We now require extra padding between the two items in the array.
154 * After the 14 bytes of the first item, that's 2 bytes required.
155 * We now require 2 framing offsets for an extra two
156 * bytes. 14 + 2 + 11 + 2 = 29 bytes to encode the entire two-item
157 * dictionary.
158 *
159 * ## Type Information Cache
160 *
161 * For each GVariant type that currently exists in the program a type
162 * information structure is kept in the type information cache.  The
163 * type information structure is required for rapid deserialisation.
164 *
165 * Continuing with the above example, if a #GVariant exists with the
166 * type "a{sv}" then a type information struct will exist for
167 * "a{sv}", "{sv}", "s", and "v".  Multiple uses of the same type
168 * will share the same type information.  Additionally, all
169 * single-digit types are stored in read-only static memory and do
170 * not contribute to the writable memory footprint of a program using
171 * #GVariant.
172 *
173 * Aside from the type information structures stored in read-only
174 * memory, there are two forms of type information.  One is used for
175 * container types where there is a single element type: arrays and
176 * maybe types.  The other is used for container types where there
177 * are multiple element types: tuples and dictionary entries.
178 *
179 * Array type info structures are 6 * sizeof (void *), plus the
180 * memory required to store the type string itself.  This means that
181 * on 32-bit systems, the cache entry for "a{sv}" would require 30
182 * bytes of memory (plus malloc overhead).
183 *
184 * Tuple type info structures are 6 * sizeof (void *), plus 4 *
185 * sizeof (void *) for each item in the tuple, plus the memory
186 * required to store the type string itself.  A 2-item tuple, for
187 * example, would have a type information structure that consumed
188 * writable memory in the size of 14 * sizeof (void *) (plus type
189 * string)  This means that on 32-bit systems, the cache entry for
190 * "{sv}" would require 61 bytes of memory (plus malloc overhead).
191 *
192 * This means that in total, for our "a{sv}" example, 91 bytes of
193 * type information would be allocated.
194 *
195 * The type information cache, additionally, uses a #GHashTable to
196 * store and lookup the cached items and stores a pointer to this
197 * hash table in static storage.  The hash table is freed when there
198 * are zero items in the type cache.
199 *
200 * Although these sizes may seem large it is important to remember
201 * that a program will probably only have a very small number of
202 * different types of values in it and that only one type information
203 * structure is required for many different values of the same type.
204 *
205 * ## Buffer Management Memory
206 *
207 * #GVariant uses an internal buffer management structure to deal
208 * with the various different possible sources of serialised data
209 * that it uses.  The buffer is responsible for ensuring that the
210 * correct call is made when the data is no longer in use by
211 * #GVariant.  This may involve a g_free() or a g_slice_free() or
212 * even g_mapped_file_unref().
213 *
214 * One buffer management structure is used for each chunk of
215 * serialised data.  The size of the buffer management structure
216 * is 4 * (void *).  On 32-bit systems, that's 16 bytes.
217 *
218 * ## GVariant structure
219 *
220 * The size of a #GVariant structure is 6 * (void *).  On 32-bit
221 * systems, that's 24 bytes.
222 *
223 * #GVariant structures only exist if they are explicitly created
224 * with API calls.  For example, if a #GVariant is constructed out of
225 * serialised data for the example given above (with the dictionary)
226 * then although there are 9 individual values that comprise the
227 * entire dictionary (two keys, two values, two variants containing
228 * the values, two dictionary entries, plus the dictionary itself),
229 * only 1 #GVariant instance exists -- the one referring to the
230 * dictionary.
231 *
232 * If calls are made to start accessing the other values then
233 * #GVariant instances will exist for those values only for as long
234 * as they are in use (ie: until you call g_variant_unref()).  The
235 * type information is shared.  The serialised data and the buffer
236 * management structure for that serialised data is shared by the
237 * child.
238 *
239 * ## Summary
240 *
241 * To put the entire example together, for our dictionary mapping
242 * strings to variants (with two entries, as given above), we are
243 * using 91 bytes of memory for type information, 29 byes of memory
244 * for the serialised data, 16 bytes for buffer management and 24
245 * bytes for the #GVariant instance, or a total of 160 bytes, plus
246 * malloc overhead.  If we were to use g_variant_get_child_value() to
247 * access the two dictionary entries, we would use an additional 48
248 * bytes.  If we were to have other dictionaries of the same type, we
249 * would use more memory for the serialised data and buffer
250 * management for those dictionaries, but the type information would
251 * be shared.
252 *
253 * Since: 2.24
254 */
255public class Variant
256{
257        /** the main Gtk struct */
258        protected GVariant* gVariant;
259        protected bool ownedRef;
260
261        /** Get the main Gtk struct */
262        public GVariant* getVariantStruct()
263        {
264                return gVariant;
265        }
266
267        /** the main Gtk struct as a void* */
268        protected void* getStruct()
269        {
270                return cast(void*)gVariant;
271        }
272
273        /**
274         * Sets our main struct and passes it to the parent class.
275         */
276        public this (GVariant* gVariant, bool ownedRef = false)
277        {
278                this.gVariant = gVariant;
279                this.ownedRef = ownedRef;
280        }
281
282        /**
283         * Creates a DBus object path GVariant with the contents of string.
284         * string must be a valid DBus object path.
285         * Use Variant.isObjectPath() if you're not sure.
286         *
287         * Since: 2.24
288         *
289         * Throws: ConstructionException GTK+ fails to create the object.
290         */
291        public static Variant fromObjectPath(string path)
292        {
293                auto p = g_variant_new_object_path(Str.toStringz(path));
294                if(p is null)
295                {
296                        throw new ConstructionException("null returned by g_variant_new_object_path");
297                }
298                return new Variant(cast(GVariant*) p);
299        }
300       
301        /**
302         * Creates a DBus type signature GVariant with the contents of string.
303         * string must be a valid DBus type signature.
304         * Use Variant.isSignature() if you're not sure.
305         *
306         * Since: 2.24
307         *
308         * Throws: ConstructionException GTK+ fails to create the object.
309         */
310        public static Variant fromSignature(string signature)
311        {
312                auto p = g_variant_new_signature(Str.toStringz(signature));
313                if(p is null)
314                {
315                        throw new ConstructionException("null returned by g_variant_new_signature");
316                }
317                return new Variant(cast(GVariant*) p);
318        }
319       
320        /**
321         * Creates an array-of-bytes GVariant with the contents of string.
322         * This function is just like new Variant(string) except that the string
323         * need not be valid utf8.
324         *
325         * The nul terminator character at the end of the string is stored in
326         * the array.
327         *
328         * Throws: ConstructionException GTK+ fails to create the object.
329         */
330        public static Variant fromByteString(string byteString)
331        {
332                auto p = g_variant_new_bytestring(Str.toStringz(byteString));
333                if(p is null)
334                {
335                        throw new ConstructionException("null returned by g_variant_new_bytestring");
336                }
337                return new Variant(cast(GVariant*) p);
338        }
339       
340        /**
341         * Constructs an array of object paths Variant from the given array
342         * of strings.
343         *
344         * Each string must be a valid Variant object path.
345         *
346         * Since: 2.30
347         *
348         * Params:
349         *     strv   = an array of strings.
350         *
351         * Throws: ConstructionException GTK+ fails to create the object.
352         */
353        public static Variant fromObjv(string[] strv)
354        {
355                // GVariant * g_variant_new_objv (const gchar * const *strv,  gssize length);
356                auto p = g_variant_new_objv(Str.toStringzArray(strv), strv.length);
357                if(p is null)
358                {
359                        throw new ConstructionException("null returned by g_variant_new_objv(strv, length)");
360                }
361                return new Variant(cast(GVariant*) p);
362        }
363       
364        /**
365         * Constructs an array of bytestring GVariant from the given array of
366         * strings. If length is -1 then strv is null-terminated.
367         *
368         * Since: 2.26
369         *
370         * Params:
371         *     strv   = an array of strings.
372         *
373         * Throws: ConstructionException GTK+ fails to create the object.
374         */
375        public static Variant fromByteStringArray(string[] strv)
376        {
377                auto p = g_variant_new_bytestring_array(Str.toStringzArray(strv), strv.length);
378                if(p is null)
379                {
380                        throw new ConstructionException("null returned by g_variant_new_bytestring_array(strv, length)");
381                }
382                return new Variant(cast(GVariant*) p);
383        }
384
385        /**
386         */
387
388        /**
389         * Creates a new #GVariant array from @children.
390         *
391         * @child_type must be non-%NULL if @n_children is zero.  Otherwise, the
392         * child type is determined by inspecting the first element of the
393         * @children array.  If @child_type is non-%NULL then it must be a
394         * definite type.
395         *
396         * The items of the array are taken from the @children array.  No entry
397         * in the @children array may be %NULL.
398         *
399         * All items in the array must have the same type, which must be the
400         * same as @child_type, if given.
401         *
402         * If the @children are floating references (see g_variant_ref_sink()), the
403         * new instance takes ownership of them as if via g_variant_ref_sink().
404         *
405         * Params:
406         *     childType = the element type of the new array
407         *     children = an array of
408         *         #GVariant pointers, the children
409         *     nChildren = the length of @children
410         *
411         * Returns: a floating reference to a new #GVariant array
412         *
413         * Since: 2.24
414         *
415         * Throws: ConstructionException GTK+ fails to create the object.
416         */
417        public this(VariantType childType, Variant[] children)
418        {
419                GVariant*[] childrenArray = new GVariant*[children.length];
420                for ( int i = 0; i < children.length; i++ )
421                {
422                        childrenArray[i] = children[i].getVariantStruct();
423                }
424               
425                auto p = g_variant_new_array((childType is null) ? null : childType.getVariantTypeStruct(), childrenArray.ptr, cast(size_t)children.length);
426               
427                if(p is null)
428                {
429                        throw new ConstructionException("null returned by new_array");
430                }
431               
432                this(cast(GVariant*) p);
433        }
434
435        /**
436         * Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
437         *
438         * Params:
439         *     value = a #gboolean value
440         *
441         * Returns: a floating reference to a new boolean #GVariant instance
442         *
443         * Since: 2.24
444         *
445         * Throws: ConstructionException GTK+ fails to create the object.
446         */
447        public this(bool value)
448        {
449                auto p = g_variant_new_boolean(value);
450               
451                if(p is null)
452                {
453                        throw new ConstructionException("null returned by new_boolean");
454                }
455               
456                this(cast(GVariant*) p);
457        }
458
459        /**
460         * Creates a new byte #GVariant instance.
461         *
462         * Params:
463         *     value = a #guint8 value
464         *
465         * Returns: a floating reference to a new byte #GVariant instance
466         *
467         * Since: 2.24
468         *
469         * Throws: ConstructionException GTK+ fails to create the object.
470         */
471        public this(char value)
472        {
473                auto p = g_variant_new_byte(value);
474               
475                if(p is null)
476                {
477                        throw new ConstructionException("null returned by new_byte");
478                }
479               
480                this(cast(GVariant*) p);
481        }
482
483        /**
484         * Creates a new dictionary entry #GVariant. @key and @value must be
485         * non-%NULL. @key must be a value of a basic type (ie: not a container).
486         *
487         * If the @key or @value are floating references (see g_variant_ref_sink()),
488         * the new instance takes ownership of them as if via g_variant_ref_sink().
489         *
490         * Params:
491         *     key = a basic #GVariant, the key
492         *     value = a #GVariant, the value
493         *
494         * Returns: a floating reference to a new dictionary entry #GVariant
495         *
496         * Since: 2.24
497         *
498         * Throws: ConstructionException GTK+ fails to create the object.
499         */
500        public this(Variant key, Variant value)
501        {
502                auto p = g_variant_new_dict_entry((key is null) ? null : key.getVariantStruct(), (value is null) ? null : value.getVariantStruct());
503               
504                if(p is null)
505                {
506                        throw new ConstructionException("null returned by new_dict_entry");
507                }
508               
509                this(cast(GVariant*) p);
510        }
511
512        /**
513         * Creates a new double #GVariant instance.
514         *
515         * Params:
516         *     value = a #gdouble floating point value
517         *
518         * Returns: a floating reference to a new double #GVariant instance
519         *
520         * Since: 2.24
521         *
522         * Throws: ConstructionException GTK+ fails to create the object.
523         */
524        public this(double value)
525        {
526                auto p = g_variant_new_double(value);
527               
528                if(p is null)
529                {
530                        throw new ConstructionException("null returned by new_double");
531                }
532               
533                this(cast(GVariant*) p);
534        }
535
536        /**
537         * Provides access to the serialised data for an array of fixed-sized
538         * items.
539         *
540         * @value must be an array with fixed-sized elements.  Numeric types are
541         * fixed-size as are tuples containing only other fixed-sized types.
542         *
543         * @element_size must be the size of a single element in the array.
544         * For example, if calling this function for an array of 32-bit integers,
545         * you might say sizeof(gint32). This value isn't used except for the purpose
546         * of a double-check that the form of the serialised data matches the caller's
547         * expectation.
548         *
549         * @n_elements, which must be non-%NULL is set equal to the number of
550         * items in the array.
551         *
552         * Params:
553         *     elementType = the #GVariantType of each element
554         *     elements = a pointer to the fixed array of contiguous elements
555         *     nElements = the number of elements
556         *     elementSize = the size of each element
557         *
558         * Returns: a floating reference to a new array #GVariant instance
559         *
560         * Since: 2.32
561         *
562         * Throws: ConstructionException GTK+ fails to create the object.
563         */
564        public this(VariantType elementType, void* elements, size_t nElements, size_t elementSize)
565        {
566                auto p = g_variant_new_fixed_array((elementType is null) ? null : elementType.getVariantTypeStruct(), elements, nElements, elementSize);
567               
568                if(p is null)
569                {
570                        throw new ConstructionException("null returned by new_fixed_array");
571                }
572               
573                this(cast(GVariant*) p);
574        }
575
576        /**
577         * Constructs a new serialised-mode #GVariant instance.  This is the
578         * inner interface for creation of new serialised values that gets
579         * called from various functions in gvariant.c.
580         *
581         * A reference is taken on @bytes.
582         *
583         * Params:
584         *     type = a #GVariantType
585         *     bytes = a #GBytes
586         *     trusted = if the contents of @bytes are trusted
587         *
588         * Returns: a new #GVariant with a floating reference
589         *
590         * Since: 2.36
591         *
592         * Throws: ConstructionException GTK+ fails to create the object.
593         */
594        public this(VariantType type, Bytes bytes, bool trusted)
595        {
596                auto p = g_variant_new_from_bytes((type is null) ? null : type.getVariantTypeStruct(), (bytes is null) ? null : bytes.getBytesStruct(), trusted);
597               
598                if(p is null)
599                {
600                        throw new ConstructionException("null returned by new_from_bytes");
601                }
602               
603                this(cast(GVariant*) p);
604        }
605
606        /**
607         * Creates a new #GVariant instance from serialised data.
608         *
609         * @type is the type of #GVariant instance that will be constructed.
610         * The interpretation of @data depends on knowing the type.
611         *
612         * @data is not modified by this function and must remain valid with an
613         * unchanging value until such a time as @notify is called with
614         * @user_data.  If the contents of @data change before that time then
615         * the result is undefined.
616         *
617         * If @data is trusted to be serialised data in normal form then
618         * @trusted should be %TRUE.  This applies to serialised data created
619         * within this process or read from a trusted location on the disk (such
620         * as a file installed in /usr/lib alongside your application).  You
621         * should set trusted to %FALSE if @data is read from the network, a
622         * file in the user's home directory, etc.
623         *
624         * If @data was not stored in this machine's native endianness, any multi-byte
625         * numeric values in the returned variant will also be in non-native
626         * endianness. g_variant_byteswap() can be used to recover the original values.
627         *
628         * @notify will be called with @user_data when @data is no longer
629         * needed.  The exact time of this call is unspecified and might even be
630         * before this function returns.
631         *
632         * Params:
633         *     type = a definite #GVariantType
634         *     data = the serialised data
635         *     size = the size of @data
636         *     trusted = %TRUE if @data is definitely in normal form
637         *     notify = function to call when @data is no longer needed
638         *     userData = data for @notify
639         *
640         * Returns: a new floating #GVariant of type @type
641         *
642         * Since: 2.24
643         *
644         * Throws: ConstructionException GTK+ fails to create the object.
645         */
646        public this(VariantType type, ubyte[] data, bool trusted, GDestroyNotify notify, void* userData)
647        {
648                auto p = g_variant_new_from_data((type is null) ? null : type.getVariantTypeStruct(), data.ptr, cast(size_t)data.length, trusted, notify, userData);
649               
650                if(p is null)
651                {
652                        throw new ConstructionException("null returned by new_from_data");
653                }
654               
655                this(cast(GVariant*) p);
656        }
657
658        /**
659         * Creates a new int16 #GVariant instance.
660         *
661         * Params:
662         *     value = a #gint16 value
663         *
664         * Returns: a floating reference to a new int16 #GVariant instance
665         *
666         * Since: 2.24
667         *
668         * Throws: ConstructionException GTK+ fails to create the object.
669         */
670        public this(short value)
671        {
672                auto p = g_variant_new_int16(value);
673               
674                if(p is null)
675                {
676                        throw new ConstructionException("null returned by new_int16");
677                }
678               
679                this(cast(GVariant*) p);
680        }
681
682        /**
683         * Creates a new int32 #GVariant instance.
684         *
685         * Params:
686         *     value = a #gint32 value
687         *
688         * Returns: a floating reference to a new int32 #GVariant instance
689         *
690         * Since: 2.24
691         *
692         * Throws: ConstructionException GTK+ fails to create the object.
693         */
694        public this(int value)
695        {
696                auto p = g_variant_new_int32(value);
697               
698                if(p is null)
699                {
700                        throw new ConstructionException("null returned by new_int32");
701                }
702               
703                this(cast(GVariant*) p);
704        }
705
706        /**
707         * Creates a new int64 #GVariant instance.
708         *
709         * Params:
710         *     value = a #gint64 value
711         *
712         * Returns: a floating reference to a new int64 #GVariant instance
713         *
714         * Since: 2.24
715         *
716         * Throws: ConstructionException GTK+ fails to create the object.
717         */
718        public this(long value)
719        {
720                auto p = g_variant_new_int64(value);
721               
722                if(p is null)
723                {
724                        throw new ConstructionException("null returned by new_int64");
725                }
726               
727                this(cast(GVariant*) p);
728        }
729
730        /**
731         * Depending on if @child is %NULL, either wraps @child inside of a
732         * maybe container or creates a Nothing instance for the given @type.
733         *
734         * At least one of @child_type and @child must be non-%NULL.
735         * If @child_type is non-%NULL then it must be a definite type.
736         * If they are both non-%NULL then @child_type must be the type
737         * of @child.
738         *
739         * If @child is a floating reference (see g_variant_ref_sink()), the new
740         * instance takes ownership of @child.
741         *
742         * Params:
743         *     childType = the #GVariantType of the child, or %NULL
744         *     child = the child value, or %NULL
745         *
746         * Returns: a floating reference to a new #GVariant maybe instance
747         *
748         * Since: 2.24
749         *
750         * Throws: ConstructionException GTK+ fails to create the object.
751         */
752        public this(VariantType childType, Variant child)
753        {
754                auto p = g_variant_new_maybe((childType is null) ? null : childType.getVariantTypeStruct(), (child is null) ? null : child.getVariantStruct());
755               
756                if(p is null)
757                {
758                        throw new ConstructionException("null returned by new_maybe");
759                }
760               
761                this(cast(GVariant*) p);
762        }
763
764        /**
765         * Parses @format and returns the result.
766         *
767         * This is the version of g_variant_new_parsed() intended to be used
768         * from libraries.
769         *
770         * The return value will be floating if it was a newly created GVariant
771         * instance.  In the case that @format simply specified the collection
772         * of a #GVariant pointer (eg: @format was "%*") then the collected
773         * #GVariant pointer will be returned unmodified, without adding any
774         * additional references.
775         *
776         * Note that the arguments in @app must be of the correct width for their types
777         * specified in @format when collected into the #va_list. See
778         * the [GVariant varargs documentation][gvariant-varargs].
779         *
780         * In order to behave correctly in all cases it is necessary for the
781         * calling function to g_variant_ref_sink() the return result before
782         * returning control to the user that originally provided the pointer.
783         * At this point, the caller will have their own full reference to the
784         * result.  This can also be done by adding the result to a container,
785         * or by passing it to another g_variant_new() call.
786         *
787         * Params:
788         *     format = a text format #GVariant
789         *     app = a pointer to a #va_list
790         *
791         * Returns: a new, usually floating, #GVariant
792         *
793         * Throws: ConstructionException GTK+ fails to create the object.
794         */
795        public this(string format, void** app)
796        {
797                auto p = g_variant_new_parsed_va(Str.toStringz(format), app);
798               
799                if(p is null)
800                {
801                        throw new ConstructionException("null returned by new_parsed_va");
802                }
803               
804                this(cast(GVariant*) p);
805        }
806
807        /**
808         * Creates a string #GVariant with the contents of @string.
809         *
810         * @string must be valid UTF-8, and must not be %NULL. To encode
811         * potentially-%NULL strings, use g_variant_new() with `ms` as the
812         * [format string][gvariant-format-strings-maybe-types].
813         *
814         * Params:
815         *     str = a normal UTF-8 nul-terminated string
816         *
817         * Returns: a floating reference to a new string #GVariant instance
818         *
819         * Since: 2.24
820         *
821         * Throws: ConstructionException GTK+ fails to create the object.
822         */
823        public this(string str)
824        {
825                auto p = g_variant_new_string(Str.toStringz(str));
826               
827                if(p is null)
828                {
829                        throw new ConstructionException("null returned by new_string");
830                }
831               
832                this(cast(GVariant*) p);
833        }
834
835        /**
836         * Constructs an array of strings #GVariant from the given array of
837         * strings.
838         *
839         * If @length is -1 then @strv is %NULL-terminated.
840         *
841         * Params:
842         *     strv = an array of strings
843         *     length = the length of @strv, or -1
844         *
845         * Returns: a new floating #GVariant instance
846         *
847         * Since: 2.24
848         *
849         * Throws: ConstructionException GTK+ fails to create the object.
850         */
851        public this(string[] strv)
852        {
853                auto p = g_variant_new_strv(Str.toStringzArray(strv), cast(ptrdiff_t)strv.length);
854               
855                if(p is null)
856                {
857                        throw new ConstructionException("null returned by new_strv");
858                }
859               
860                this(cast(GVariant*) p);
861        }
862
863        /**
864         * Creates a new tuple #GVariant out of the items in @children.  The
865         * type is determined from the types of @children.  No entry in the
866         * @children array may be %NULL.
867         *
868         * If @n_children is 0 then the unit tuple is constructed.
869         *
870         * If the @children are floating references (see g_variant_ref_sink()), the
871         * new instance takes ownership of them as if via g_variant_ref_sink().
872         *
873         * Params:
874         *     children = the items to make the tuple out of
875         *     nChildren = the length of @children
876         *
877         * Returns: a floating reference to a new #GVariant tuple
878         *
879         * Since: 2.24
880         *
881         * Throws: ConstructionException GTK+ fails to create the object.
882         */
883        public this(Variant[] children)
884        {
885                GVariant*[] childrenArray = new GVariant*[children.length];
886                for ( int i = 0; i < children.length; i++ )
887                {
888                        childrenArray[i] = children[i].getVariantStruct();
889                }
890               
891                auto p = g_variant_new_tuple(childrenArray.ptr, cast(size_t)children.length);
892               
893                if(p is null)
894                {
895                        throw new ConstructionException("null returned by new_tuple");
896                }
897               
898                this(cast(GVariant*) p);
899        }
900
901        /**
902         * Creates a new uint16 #GVariant instance.
903         *
904         * Params:
905         *     value = a #guint16 value
906         *
907         * Returns: a floating reference to a new uint16 #GVariant instance
908         *
909         * Since: 2.24
910         *
911         * Throws: ConstructionException GTK+ fails to create the object.
912         */
913        public this(ushort value)
914        {
915                auto p = g_variant_new_uint16(value);
916               
917                if(p is null)
918                {
919                        throw new ConstructionException("null returned by new_uint16");
920                }
921               
922                this(cast(GVariant*) p);
923        }
924
925        /**
926         * Creates a new uint32 #GVariant instance.
927         *
928         * Params:
929         *     value = a #guint32 value
930         *
931         * Returns: a floating reference to a new uint32 #GVariant instance
932         *
933         * Since: 2.24
934         *
935         * Throws: ConstructionException GTK+ fails to create the object.
936         */
937        public this(uint value)
938        {
939                auto p = g_variant_new_uint32(value);
940               
941                if(p is null)
942                {
943                        throw new ConstructionException("null returned by new_uint32");
944                }
945               
946                this(cast(GVariant*) p);
947        }
948
949        /**
950         * Creates a new uint64 #GVariant instance.
951         *
952         * Params:
953         *     value = a #guint64 value
954         *
955         * Returns: a floating reference to a new uint64 #GVariant instance
956         *
957         * Since: 2.24
958         *
959         * Throws: ConstructionException GTK+ fails to create the object.
960         */
961        public this(ulong value)
962        {
963                auto p = g_variant_new_uint64(value);
964               
965                if(p is null)
966                {
967                        throw new ConstructionException("null returned by new_uint64");
968                }
969               
970                this(cast(GVariant*) p);
971        }
972
973        /**
974         * This function is intended to be used by libraries based on
975         * #GVariant that want to provide g_variant_new()-like functionality
976         * to their users.
977         *
978         * The API is more general than g_variant_new() to allow a wider range
979         * of possible uses.
980         *
981         * @format_string must still point to a valid format string, but it only
982         * needs to be nul-terminated if @endptr is %NULL.  If @endptr is
983         * non-%NULL then it is updated to point to the first character past the
984         * end of the format string.
985         *
986         * @app is a pointer to a #va_list.  The arguments, according to
987         * @format_string, are collected from this #va_list and the list is left
988         * pointing to the argument following the last.
989         *
990         * Note that the arguments in @app must be of the correct width for their
991         * types specified in @format_string when collected into the #va_list.
992         * See the [GVariant varargs documentation][gvariant-varargs.
993         *
994         * These two generalisations allow mixing of multiple calls to
995         * g_variant_new_va() and g_variant_get_va() within a single actual
996         * varargs call by the user.
997         *
998         * The return value will be floating if it was a newly created GVariant
999         * instance (for example, if the format string was "(ii)").  In the case
1000         * that the format_string was '*', '?', 'r', or a format starting with
1001         * '@' then the collected #GVariant pointer will be returned unmodified,
1002         * without adding any additional references.
1003         *
1004         * In order to behave correctly in all cases it is necessary for the
1005         * calling function to g_variant_ref_sink() the return result before
1006         * returning control to the user that originally provided the pointer.
1007         * At this point, the caller will have their own full reference to the
1008         * result.  This can also be done by adding the result to a container,
1009         * or by passing it to another g_variant_new() call.
1010         *
1011         * Params:
1012         *     formatString = a string that is prefixed with a format string
1013         *     endptr = location to store the end pointer,
1014         *         or %NULL
1015         *     app = a pointer to a #va_list
1016         *
1017         * Returns: a new, usually floating, #GVariant
1018         *
1019         * Since: 2.24
1020         *
1021         * Throws: ConstructionException GTK+ fails to create the object.
1022         */
1023        public this(string formatString, string[] endptr, void** app)
1024        {
1025                auto p = g_variant_new_va(Str.toStringz(formatString), Str.toStringzArray(endptr), app);
1026               
1027                if(p is null)
1028                {
1029                        throw new ConstructionException("null returned by new_va");
1030                }
1031               
1032                this(cast(GVariant*) p);
1033        }
1034
1035        /**
1036         * Boxes @value.  The result is a #GVariant instance representing a
1037         * variant containing the original value.
1038         *
1039         * If @child is a floating reference (see g_variant_ref_sink()), the new
1040         * instance takes ownership of @child.
1041         *
1042         * Params:
1043         *     value = a #GVariant instance
1044         *
1045         * Returns: a floating reference to a new variant #GVariant instance
1046         *
1047         * Since: 2.24
1048         *
1049         * Throws: ConstructionException GTK+ fails to create the object.
1050         */
1051        public this(Variant value)
1052        {
1053                auto p = g_variant_new_variant((value is null) ? null : value.getVariantStruct());
1054               
1055                if(p is null)
1056                {
1057                        throw new ConstructionException("null returned by new_variant");
1058                }
1059               
1060                this(cast(GVariant*) p);
1061        }
1062
1063        /**
1064         * Performs a byteswapping operation on the contents of @value.  The
1065         * result is that all multi-byte numeric data contained in @value is
1066         * byteswapped.  That includes 16, 32, and 64bit signed and unsigned
1067         * integers as well as file handles and double precision floating point
1068         * values.
1069         *
1070         * This function is an identity mapping on any value that does not
1071         * contain multi-byte numeric data.  That include strings, booleans,
1072         * bytes and containers containing only these things (recursively).
1073         *
1074         * The returned value is always in normal form and is marked as trusted.
1075         *
1076         * Returns: the byteswapped form of @value
1077         *
1078         * Since: 2.24
1079         */
1080        public Variant byteswap()
1081        {
1082                auto p = g_variant_byteswap(gVariant);
1083               
1084                if(p is null)
1085                {
1086                        return null;
1087                }
1088               
1089                return new Variant(cast(GVariant*) p, true);
1090        }
1091
1092        /**
1093         * Checks if calling g_variant_get() with @format_string on @value would
1094         * be valid from a type-compatibility standpoint.  @format_string is
1095         * assumed to be a valid format string (from a syntactic standpoint).
1096         *
1097         * If @copy_only is %TRUE then this function additionally checks that it
1098         * would be safe to call g_variant_unref() on @value immediately after
1099         * the call to g_variant_get() without invalidating the result.  This is
1100         * only possible if deep copies are made (ie: there are no pointers to
1101         * the data inside of the soon-to-be-freed #GVariant instance).  If this
1102         * check fails then a g_critical() is printed and %FALSE is returned.
1103         *
1104         * This function is meant to be used by functions that wish to provide
1105         * varargs accessors to #GVariant values of uncertain values (eg:
1106         * g_variant_lookup() or g_menu_model_get_item_attribute()).
1107         *
1108         * Params:
1109         *     formatString = a valid #GVariant format string
1110         *     copyOnly = %TRUE to ensure the format string makes deep copies
1111         *
1112         * Returns: %TRUE if @format_string is safe to use
1113         *
1114         * Since: 2.34
1115         */
1116        public bool checkFormatString(string formatString, bool copyOnly)
1117        {
1118                return g_variant_check_format_string(gVariant, Str.toStringz(formatString), copyOnly) != 0;
1119        }
1120
1121        /**
1122         * Classifies @value according to its top-level type.
1123         *
1124         * Returns: the #GVariantClass of @value
1125         *
1126         * Since: 2.24
1127         */
1128        public GVariantClass classify()
1129        {
1130                return g_variant_classify(gVariant);
1131        }
1132
1133        /**
1134         * Compares @one and @two.
1135         *
1136         * The types of @one and @two are #gconstpointer only to allow use of
1137         * this function with #GTree, #GPtrArray, etc.  They must each be a
1138         * #GVariant.
1139         *
1140         * Comparison is only defined for basic types (ie: booleans, numbers,
1141         * strings).  For booleans, %FALSE is less than %TRUE.  Numbers are
1142         * ordered in the usual way.  Strings are in ASCII lexographical order.
1143         *
1144         * It is a programmer error to attempt to compare container values or
1145         * two values that have types that are not exactly equal.  For example,
1146         * you cannot compare a 32-bit signed integer with a 32-bit unsigned
1147         * integer.  Also note that this function is not particularly
1148         * well-behaved when it comes to comparison of doubles; in particular,
1149         * the handling of incomparable values (ie: NaN) is undefined.
1150         *
1151         * If you only require an equality comparison, g_variant_equal() is more
1152         * general.
1153         *
1154         * Params:
1155         *     two = a #GVariant instance of the same type
1156         *
1157         * Returns: negative value if a < b;
1158         *     zero if a = b;
1159         *     positive value if a > b.
1160         *
1161         * Since: 2.26
1162         */
1163        public int compare(Variant two)
1164        {
1165                return g_variant_compare(gVariant, (two is null) ? null : two.getVariantStruct());
1166        }
1167
1168        /**
1169         * Similar to g_variant_get_bytestring() except that instead of
1170         * returning a constant string, the string is duplicated.
1171         *
1172         * The return value must be freed using g_free().
1173         *
1174         * Returns: a newly allocated string
1175         *
1176         * Since: 2.26
1177         */
1178        public string dupBytestring()
1179        {
1180                size_t length;
1181               
1182                auto retStr = g_variant_dup_bytestring(gVariant, &length);
1183               
1184                scope(exit) Str.freeString(retStr);
1185                return Str.toString(retStr, length);
1186        }
1187
1188        /**
1189         * Gets the contents of an array of array of bytes #GVariant.  This call
1190         * makes a deep copy; the return result should be released with
1191         * g_strfreev().
1192         *
1193         * If @length is non-%NULL then the number of elements in the result is
1194         * stored there.  In any case, the resulting array will be
1195         * %NULL-terminated.
1196         *
1197         * For an empty array, @length will be set to 0 and a pointer to a
1198         * %NULL pointer will be returned.
1199         *
1200         * Returns: an array of strings
1201         *
1202         * Since: 2.26
1203         */
1204        public string[] dupBytestringArray()
1205        {
1206                size_t length;
1207               
1208                auto retStr = g_variant_dup_bytestring_array(gVariant, &length);
1209               
1210                scope(exit) Str.freeStringArray(retStr);
1211                return Str.toStringArray(retStr, length);
1212        }
1213
1214        /**
1215         * Gets the contents of an array of object paths #GVariant.  This call
1216         * makes a deep copy; the return result should be released with
1217         * g_strfreev().
1218         *
1219         * If @length is non-%NULL then the number of elements in the result
1220         * is stored there.  In any case, the resulting array will be
1221         * %NULL-terminated.
1222         *
1223         * For an empty array, @length will be set to 0 and a pointer to a
1224         * %NULL pointer will be returned.
1225         *
1226         * Returns: an array of strings
1227         *
1228         * Since: 2.30
1229         */
1230        public string[] dupObjv()
1231        {
1232                size_t length;
1233               
1234                auto retStr = g_variant_dup_objv(gVariant, &length);
1235               
1236                scope(exit) Str.freeStringArray(retStr);
1237                return Str.toStringArray(retStr, length);
1238        }
1239
1240        /**
1241         * Similar to g_variant_get_string() except that instead of returning
1242         * a constant string, the string is duplicated.
1243         *
1244         * The string will always be UTF-8 encoded.
1245         *
1246         * The return value must be freed using g_free().
1247         *
1248         * Params:
1249         *     length = a pointer to a #gsize, to store the length
1250         *
1251         * Returns: a newly allocated string, UTF-8 encoded
1252         *
1253         * Since: 2.24
1254         */
1255        public string dupString(out size_t length)
1256        {
1257                auto retStr = g_variant_dup_string(gVariant, &length);
1258               
1259                scope(exit) Str.freeString(retStr);
1260                return Str.toString(retStr);
1261        }
1262
1263        /**
1264         * Gets the contents of an array of strings #GVariant.  This call
1265         * makes a deep copy; the return result should be released with
1266         * g_strfreev().
1267         *
1268         * If @length is non-%NULL then the number of elements in the result
1269         * is stored there.  In any case, the resulting array will be
1270         * %NULL-terminated.
1271         *
1272         * For an empty array, @length will be set to 0 and a pointer to a
1273         * %NULL pointer will be returned.
1274         *
1275         * Returns: an array of strings
1276         *
1277         * Since: 2.24
1278         */
1279        public string[] dupStrv()
1280        {
1281                size_t length;
1282               
1283                auto retStr = g_variant_dup_strv(gVariant, &length);
1284               
1285                scope(exit) Str.freeStringArray(retStr);
1286                return Str.toStringArray(retStr, length);
1287        }
1288
1289        /**
1290         * Checks if @one and @two have the same type and value.
1291         *
1292         * The types of @one and @two are #gconstpointer only to allow use of
1293         * this function with #GHashTable.  They must each be a #GVariant.
1294         *
1295         * Params:
1296         *     two = a #GVariant instance
1297         *
1298         * Returns: %TRUE if @one and @two are equal
1299         *
1300         * Since: 2.24
1301         */
1302        public bool equal(Variant two)
1303        {
1304                return g_variant_equal(gVariant, (two is null) ? null : two.getVariantStruct()) != 0;
1305        }
1306
1307        /**
1308         * Returns the boolean value of @value.
1309         *
1310         * It is an error to call this function with a @value of any type
1311         * other than %G_VARIANT_TYPE_BOOLEAN.
1312         *
1313         * Returns: %TRUE or %FALSE
1314         *
1315         * Since: 2.24
1316         */
1317        public bool getBoolean()
1318        {
1319                return g_variant_get_boolean(gVariant) != 0;
1320        }
1321
1322        /**
1323         * Returns the byte value of @value.
1324         *
1325         * It is an error to call this function with a @value of any type
1326         * other than %G_VARIANT_TYPE_BYTE.
1327         *
1328         * Returns: a #guchar
1329         *
1330         * Since: 2.24
1331         */
1332        public char getByte()
1333        {
1334                return g_variant_get_byte(gVariant);
1335        }
1336
1337        /**
1338         * Returns the string value of a #GVariant instance with an
1339         * array-of-bytes type.  The string has no particular encoding.
1340         *
1341         * If the array does not end with a nul terminator character, the empty
1342         * string is returned.  For this reason, you can always trust that a
1343         * non-%NULL nul-terminated string will be returned by this function.
1344         *
1345         * If the array contains a nul terminator character somewhere other than
1346         * the last byte then the returned string is the string, up to the first
1347         * such nul character.
1348         *
1349         * It is an error to call this function with a @value that is not an
1350         * array of bytes.
1351         *
1352         * The return value remains valid as long as @value exists.
1353         *
1354         * Returns: the constant string
1355         *
1356         * Since: 2.26
1357         */
1358        public string getBytestring()
1359        {
1360                return Str.toString(g_variant_get_bytestring(gVariant));
1361        }
1362
1363        /**
1364         * Gets the contents of an array of array of bytes #GVariant.  This call
1365         * makes a shallow copy; the return result should be released with
1366         * g_free(), but the individual strings must not be modified.
1367         *
1368         * If @length is non-%NULL then the number of elements in the result is
1369         * stored there.  In any case, the resulting array will be
1370         * %NULL-terminated.
1371         *
1372         * For an empty array, @length will be set to 0 and a pointer to a
1373         * %NULL pointer will be returned.
1374         *
1375         * Returns: an array of constant strings
1376         *
1377         * Since: 2.26
1378         */
1379        public string[] getBytestringArray()
1380        {
1381                size_t length;
1382               
1383                return Str.toStringArray(g_variant_get_bytestring_array(gVariant, &length));
1384        }
1385
1386        /**
1387         * Reads a child item out of a container #GVariant instance.  This
1388         * includes variants, maybes, arrays, tuples and dictionary
1389         * entries.  It is an error to call this function on any other type of
1390         * #GVariant.
1391         *
1392         * It is an error if @index_ is greater than the number of child items
1393         * in the container.  See g_variant_n_children().
1394         *
1395         * The returned value is never floating.  You should free it with
1396         * g_variant_unref() when you're done with it.
1397         *
1398         * This function is O(1).
1399         *
1400         * Params:
1401         *     index = the index of the child to fetch
1402         *
1403         * Returns: the child at the specified index
1404         *
1405         * Since: 2.24
1406         */
1407        public Variant getChildValue(size_t index)
1408        {
1409                auto p = g_variant_get_child_value(gVariant, index);
1410               
1411                if(p is null)
1412                {
1413                        return null;
1414                }
1415               
1416                return new Variant(cast(GVariant*) p, true);
1417        }
1418
1419        /**
1420         * Returns a pointer to the serialised form of a #GVariant instance.
1421         * The returned data may not be in fully-normalised form if read from an
1422         * untrusted source.  The returned data must not be freed; it remains
1423         * valid for as long as @value exists.
1424         *
1425         * If @value is a fixed-sized value that was deserialised from a
1426         * corrupted serialised container then %NULL may be returned.  In this
1427         * case, the proper thing to do is typically to use the appropriate
1428         * number of nul bytes in place of @value.  If @value is not fixed-sized
1429         * then %NULL is never returned.
1430         *
1431         * In the case that @value is already in serialised form, this function
1432         * is O(1).  If the value is not already in serialised form,
1433         * serialisation occurs implicitly and is approximately O(n) in the size
1434         * of the result.
1435         *
1436         * To deserialise the data returned by this function, in addition to the
1437         * serialised data, you must know the type of the #GVariant, and (if the
1438         * machine might be different) the endianness of the machine that stored
1439         * it. As a result, file formats or network messages that incorporate
1440         * serialised #GVariants must include this information either
1441         * implicitly (for instance "the file always contains a
1442         * %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
1443         * explicitly (by storing the type and/or endianness in addition to the
1444         * serialised data).
1445         *
1446         * Returns: the serialised form of @value, or %NULL
1447         *
1448         * Since: 2.24
1449         */
1450        public void* getData()
1451        {
1452                return g_variant_get_data(gVariant);
1453        }
1454
1455        /**
1456         * Returns a pointer to the serialised form of a #GVariant instance.
1457         * The semantics of this function are exactly the same as
1458         * g_variant_get_data(), except that the returned #GBytes holds
1459         * a reference to the variant data.
1460         *
1461         * Returns: A new #GBytes representing the variant data
1462         *
1463         * Since: 2.36
1464         */
1465        public Bytes getDataAsBytes()
1466        {
1467                auto p = g_variant_get_data_as_bytes(gVariant);
1468               
1469                if(p is null)
1470                {
1471                        return null;
1472                }
1473               
1474                return new Bytes(cast(GBytes*) p, true);
1475        }
1476
1477        /**
1478         * Returns the double precision floating point value of @value.
1479         *
1480         * It is an error to call this function with a @value of any type
1481         * other than %G_VARIANT_TYPE_DOUBLE.
1482         *
1483         * Returns: a #gdouble
1484         *
1485         * Since: 2.24
1486         */
1487        public double getDouble()
1488        {
1489                return g_variant_get_double(gVariant);
1490        }
1491
1492        /**
1493         * Provides access to the serialised data for an array of fixed-sized
1494         * items.
1495         *
1496         * @value must be an array with fixed-sized elements.  Numeric types are
1497         * fixed-size, as are tuples containing only other fixed-sized types.
1498         *
1499         * @element_size must be the size of a single element in the array,
1500         * as given by the section on
1501         * [serialized data memory][gvariant-serialised-data-memory].
1502         *
1503         * In particular, arrays of these fixed-sized types can be interpreted
1504         * as an array of the given C type, with @element_size set to the size
1505         * the appropriate type:
1506         * - %G_VARIANT_TYPE_INT16 (etc.): #gint16 (etc.)
1507         * - %G_VARIANT_TYPE_BOOLEAN: #guchar (not #gboolean!)
1508         * - %G_VARIANT_TYPE_BYTE: #guchar
1509         * - %G_VARIANT_TYPE_HANDLE: #guint32
1510         * - %G_VARIANT_TYPE_DOUBLE: #gdouble
1511         *
1512         * For example, if calling this function for an array of 32-bit integers,
1513         * you might say sizeof(gint32). This value isn't used except for the purpose
1514         * of a double-check that the form of the serialised data matches the caller's
1515         * expectation.
1516         *
1517         * @n_elements, which must be non-%NULL is set equal to the number of
1518         * items in the array.
1519         *
1520         * Params:
1521         *     elementSize = the size of each element
1522         *
1523         * Returns: a pointer to
1524         *     the fixed array
1525         *
1526         * Since: 2.24
1527         */
1528        public void[] getFixedArray(size_t elementSize)
1529        {
1530                size_t nElements;
1531               
1532                auto p = g_variant_get_fixed_array(gVariant, &nElements, elementSize);
1533               
1534                return p[0 .. nElements];
1535        }
1536
1537        /**
1538         * Returns the 32-bit signed integer value of @value.
1539         *
1540         * It is an error to call this function with a @value of any type other
1541         * than %G_VARIANT_TYPE_HANDLE.
1542         *
1543         * By convention, handles are indexes into an array of file descriptors
1544         * that are sent alongside a D-Bus message.  If you're not interacting
1545         * with D-Bus, you probably don't need them.
1546         *
1547         * Returns: a #gint32
1548         *
1549         * Since: 2.24
1550         */
1551        public int getHandle()
1552        {
1553                return g_variant_get_handle(gVariant);
1554        }
1555
1556        /**
1557         * Returns the 16-bit signed integer value of @value.
1558         *
1559         * It is an error to call this function with a @value of any type
1560         * other than %G_VARIANT_TYPE_INT16.
1561         *
1562         * Returns: a #gint16
1563         *
1564         * Since: 2.24
1565         */
1566        public short getInt16()
1567        {
1568                return g_variant_get_int16(gVariant);
1569        }
1570
1571        /**
1572         * Returns the 32-bit signed integer value of @value.
1573         *
1574         * It is an error to call this function with a @value of any type
1575         * other than %G_VARIANT_TYPE_INT32.
1576         *
1577         * Returns: a #gint32
1578         *
1579         * Since: 2.24
1580         */
1581        public int getInt32()
1582        {
1583                return g_variant_get_int32(gVariant);
1584        }
1585
1586        /**
1587         * Returns the 64-bit signed integer value of @value.
1588         *
1589         * It is an error to call this function with a @value of any type
1590         * other than %G_VARIANT_TYPE_INT64.
1591         *
1592         * Returns: a #gint64
1593         *
1594         * Since: 2.24
1595         */
1596        public long getInt64()
1597        {
1598                return g_variant_get_int64(gVariant);
1599        }
1600
1601        /**
1602         * Given a maybe-typed #GVariant instance, extract its value.  If the
1603         * value is Nothing, then this function returns %NULL.
1604         *
1605         * Returns: the contents of @value, or %NULL
1606         *
1607         * Since: 2.24
1608         */
1609        public Variant getMaybe()
1610        {
1611                auto p = g_variant_get_maybe(gVariant);
1612               
1613                if(p is null)
1614                {
1615                        return null;
1616                }
1617               
1618                return new Variant(cast(GVariant*) p, true);
1619        }
1620
1621        /**
1622         * Gets a #GVariant instance that has the same value as @value and is
1623         * trusted to be in normal form.
1624         *
1625         * If @value is already trusted to be in normal form then a new
1626         * reference to @value is returned.
1627         *
1628         * If @value is not already trusted, then it is scanned to check if it
1629         * is in normal form.  If it is found to be in normal form then it is
1630         * marked as trusted and a new reference to it is returned.
1631         *
1632         * If @value is found not to be in normal form then a new trusted
1633         * #GVariant is created with the same value as @value.
1634         *
1635         * It makes sense to call this function if you've received #GVariant
1636         * data from untrusted sources and you want to ensure your serialised
1637         * output is definitely in normal form.
1638         *
1639         * Returns: a trusted #GVariant
1640         *
1641         * Since: 2.24
1642         */
1643        public Variant getNormalForm()
1644        {
1645                auto p = g_variant_get_normal_form(gVariant);
1646               
1647                if(p is null)
1648                {
1649                        return null;
1650                }
1651               
1652                return new Variant(cast(GVariant*) p, true);
1653        }
1654
1655        /**
1656         * Gets the contents of an array of object paths #GVariant.  This call
1657         * makes a shallow copy; the return result should be released with
1658         * g_free(), but the individual strings must not be modified.
1659         *
1660         * If @length is non-%NULL then the number of elements in the result
1661         * is stored there.  In any case, the resulting array will be
1662         * %NULL-terminated.
1663         *
1664         * For an empty array, @length will be set to 0 and a pointer to a
1665         * %NULL pointer will be returned.
1666         *
1667         * Returns: an array of constant strings
1668         *
1669         * Since: 2.30
1670         */
1671        public string[] getObjv()
1672        {
1673                size_t length;
1674               
1675                return Str.toStringArray(g_variant_get_objv(gVariant, &length));
1676        }
1677
1678        /**
1679         * Determines the number of bytes that would be required to store @value
1680         * with g_variant_store().
1681         *
1682         * If @value has a fixed-sized type then this function always returned
1683         * that fixed size.
1684         *
1685         * In the case that @value is already in serialised form or the size has
1686         * already been calculated (ie: this function has been called before)
1687         * then this function is O(1).  Otherwise, the size is calculated, an
1688         * operation which is approximately O(n) in the number of values
1689         * involved.
1690         *
1691         * Returns: the serialised size of @value
1692         *
1693         * Since: 2.24
1694         */
1695        public size_t getSize()
1696        {
1697                return g_variant_get_size(gVariant);
1698        }
1699
1700        /**
1701         * Returns the string value of a #GVariant instance with a string
1702         * type.  This includes the types %G_VARIANT_TYPE_STRING,
1703         * %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
1704         *
1705         * The string will always be UTF-8 encoded, and will never be %NULL.
1706         *
1707         * If @length is non-%NULL then the length of the string (in bytes) is
1708         * returned there.  For trusted values, this information is already
1709         * known.  For untrusted values, a strlen() will be performed.
1710         *
1711         * It is an error to call this function with a @value of any type
1712         * other than those three.
1713         *
1714         * The return value remains valid as long as @value exists.
1715         *
1716         * Params:
1717         *     length = a pointer to a #gsize,
1718         *         to store the length
1719         *
1720         * Returns: the constant string, UTF-8 encoded
1721         *
1722         * Since: 2.24
1723         */
1724        public string getString(out size_t length)
1725        {
1726                return Str.toString(g_variant_get_string(gVariant, &length));
1727        }
1728
1729        /**
1730         * Gets the contents of an array of strings #GVariant.  This call
1731         * makes a shallow copy; the return result should be released with
1732         * g_free(), but the individual strings must not be modified.
1733         *
1734         * If @length is non-%NULL then the number of elements in the result
1735         * is stored there.  In any case, the resulting array will be
1736         * %NULL-terminated.
1737         *
1738         * For an empty array, @length will be set to 0 and a pointer to a
1739         * %NULL pointer will be returned.
1740         *
1741         * Returns: an array of constant strings
1742         *
1743         * Since: 2.24
1744         */
1745        public string[] getStrv()
1746        {
1747                size_t length;
1748               
1749                return Str.toStringArray(g_variant_get_strv(gVariant, &length));
1750        }
1751
1752        /**
1753         * Determines the type of @value.
1754         *
1755         * The return value is valid for the lifetime of @value and must not
1756         * be freed.
1757         *
1758         * Returns: a #GVariantType
1759         *
1760         * Since: 2.24
1761         */
1762        public VariantType getType()
1763        {
1764                auto p = g_variant_get_type(gVariant);
1765               
1766                if(p is null)
1767                {
1768                        return null;
1769                }
1770               
1771                return new VariantType(cast(GVariantType*) p);
1772        }
1773
1774        /**
1775         * Returns the type string of @value.  Unlike the result of calling
1776         * g_variant_type_peek_string(), this string is nul-terminated.  This
1777         * string belongs to #GVariant and must not be freed.
1778         *
1779         * Returns: the type string for the type of @value
1780         *
1781         * Since: 2.24
1782         */
1783        public string getTypeString()
1784        {
1785                return Str.toString(g_variant_get_type_string(gVariant));
1786        }
1787
1788        /**
1789         * Returns the 16-bit unsigned integer value of @value.
1790         *
1791         * It is an error to call this function with a @value of any type
1792         * other than %G_VARIANT_TYPE_UINT16.
1793         *
1794         * Returns: a #guint16
1795         *
1796         * Since: 2.24
1797         */
1798        public ushort getUint16()
1799        {
1800                return g_variant_get_uint16(gVariant);
1801        }
1802
1803        /**
1804         * Returns the 32-bit unsigned integer value of @value.
1805         *
1806         * It is an error to call this function with a @value of any type
1807         * other than %G_VARIANT_TYPE_UINT32.
1808         *
1809         * Returns: a #guint32
1810         *
1811         * Since: 2.24
1812         */
1813        public uint getUint32()
1814        {
1815                return g_variant_get_uint32(gVariant);
1816        }
1817
1818        /**
1819         * Returns the 64-bit unsigned integer value of @value.
1820         *
1821         * It is an error to call this function with a @value of any type
1822         * other than %G_VARIANT_TYPE_UINT64.
1823         *
1824         * Returns: a #guint64
1825         *
1826         * Since: 2.24
1827         */
1828        public ulong getUint64()
1829        {
1830                return g_variant_get_uint64(gVariant);
1831        }
1832
1833        /**
1834         * This function is intended to be used by libraries based on #GVariant
1835         * that want to provide g_variant_get()-like functionality to their
1836         * users.
1837         *
1838         * The API is more general than g_variant_get() to allow a wider range
1839         * of possible uses.
1840         *
1841         * @format_string must still point to a valid format string, but it only
1842         * need to be nul-terminated if @endptr is %NULL.  If @endptr is
1843         * non-%NULL then it is updated to point to the first character past the
1844         * end of the format string.
1845         *
1846         * @app is a pointer to a #va_list.  The arguments, according to
1847         * @format_string, are collected from this #va_list and the list is left
1848         * pointing to the argument following the last.
1849         *
1850         * These two generalisations allow mixing of multiple calls to
1851         * g_variant_new_va() and g_variant_get_va() within a single actual
1852         * varargs call by the user.
1853         *
1854         * @format_string determines the C types that are used for unpacking
1855         * the values and also determines if the values are copied or borrowed,
1856         * see the section on
1857         * [GVariant format strings][gvariant-format-strings-pointers].
1858         *
1859         * Params:
1860         *     formatString = a string that is prefixed with a format string
1861         *     endptr = location to store the end pointer,
1862         *         or %NULL
1863         *     app = a pointer to a #va_list
1864         *
1865         * Since: 2.24
1866         */
1867        public void getVa(string formatString, string[] endptr, void** app)
1868        {
1869                g_variant_get_va(gVariant, Str.toStringz(formatString), Str.toStringzArray(endptr), app);
1870        }
1871
1872        /**
1873         * Unboxes @value.  The result is the #GVariant instance that was
1874         * contained in @value.
1875         *
1876         * Returns: the item contained in the variant
1877         *
1878         * Since: 2.24
1879         */
1880        public Variant getVariant()
1881        {
1882                auto p = g_variant_get_variant(gVariant);
1883               
1884                if(p is null)
1885                {
1886                        return null;
1887                }
1888               
1889                return new Variant(cast(GVariant*) p, true);
1890        }
1891
1892        /**
1893         * Generates a hash value for a #GVariant instance.
1894         *
1895         * The output of this function is guaranteed to be the same for a given
1896         * value only per-process.  It may change between different processor
1897         * architectures or even different versions of GLib.  Do not use this
1898         * function as a basis for building protocols or file formats.
1899         *
1900         * The type of @value is #gconstpointer only to allow use of this
1901         * function with #GHashTable.  @value must be a #GVariant.
1902         *
1903         * Returns: a hash value corresponding to @value
1904         *
1905         * Since: 2.24
1906         */
1907        public uint hash()
1908        {
1909                return g_variant_hash(gVariant);
1910        }
1911
1912        /**
1913         * Checks if @value is a container.
1914         *
1915         * Returns: %TRUE if @value is a container
1916         *
1917         * Since: 2.24
1918         */
1919        public bool isContainer()
1920        {
1921                return g_variant_is_container(gVariant) != 0;
1922        }
1923
1924        /**
1925         * Checks whether @value has a floating reference count.
1926         *
1927         * This function should only ever be used to assert that a given variant
1928         * is or is not floating, or for debug purposes. To acquire a reference
1929         * to a variant that might be floating, always use g_variant_ref_sink()
1930         * or g_variant_take_ref().
1931         *
1932         * See g_variant_ref_sink() for more information about floating reference
1933         * counts.
1934         *
1935         * Returns: whether @value is floating
1936         *
1937         * Since: 2.26
1938         */
1939        public bool isFloating()
1940        {
1941                return g_variant_is_floating(gVariant) != 0;
1942        }
1943
1944        /**
1945         * Checks if @value is in normal form.
1946         *
1947         * The main reason to do this is to detect if a given chunk of
1948         * serialised data is in normal form: load the data into a #GVariant
1949         * using g_variant_new_from_data() and then use this function to
1950         * check.
1951         *
1952         * If @value is found to be in normal form then it will be marked as
1953         * being trusted.  If the value was already marked as being trusted then
1954         * this function will immediately return %TRUE.
1955         *
1956         * Returns: %TRUE if @value is in normal form
1957         *
1958         * Since: 2.24
1959         */
1960        public bool isNormalForm()
1961        {
1962                return g_variant_is_normal_form(gVariant) != 0;
1963        }
1964
1965        /**
1966         * Checks if a value has a type matching the provided type.
1967         *
1968         * Params:
1969         *     type = a #GVariantType
1970         *
1971         * Returns: %TRUE if the type of @value matches @type
1972         *
1973         * Since: 2.24
1974         */
1975        public bool isOfType(VariantType type)
1976        {
1977                return g_variant_is_of_type(gVariant, (type is null) ? null : type.getVariantTypeStruct()) != 0;
1978        }
1979
1980        /**
1981         * Creates a heap-allocated #GVariantIter for iterating over the items
1982         * in @value.
1983         *
1984         * Use g_variant_iter_free() to free the return value when you no longer
1985         * need it.
1986         *
1987         * A reference is taken to @value and will be released only when
1988         * g_variant_iter_free() is called.
1989         *
1990         * Returns: a new heap-allocated #GVariantIter
1991         *
1992         * Since: 2.24
1993         */
1994        public VariantIter iterNew()
1995        {
1996                auto p = g_variant_iter_new(gVariant);
1997               
1998                if(p is null)
1999                {
2000                        return null;
2001                }
2002               
2003                return new VariantIter(cast(GVariantIter*) p, true);
2004        }
2005
2006        /**
2007         * Looks up a value in a dictionary #GVariant.
2008         *
2009         * This function works with dictionaries of the type a{s*} (and equally
2010         * well with type a{o*}, but we only further discuss the string case
2011         * for sake of clarity).
2012         *
2013         * In the event that @dictionary has the type a{sv}, the @expected_type
2014         * string specifies what type of value is expected to be inside of the
2015         * variant. If the value inside the variant has a different type then
2016         * %NULL is returned. In the event that @dictionary has a value type other
2017         * than v then @expected_type must directly match the key type and it is
2018         * used to unpack the value directly or an error occurs.
2019         *
2020         * In either case, if @key is not found in @dictionary, %NULL is returned.
2021         *
2022         * If the key is found and the value has the correct type, it is
2023         * returned.  If @expected_type was specified then any non-%NULL return
2024         * value will have this type.
2025         *
2026         * This function is currently implemented with a linear scan.  If you
2027         * plan to do many lookups then #GVariantDict may be more efficient.
2028         *
2029         * Params:
2030         *     key = the key to lookup in the dictionary
2031         *     expectedType = a #GVariantType, or %NULL
2032         *
2033         * Returns: the value of the dictionary key, or %NULL
2034         *
2035         * Since: 2.28
2036         */
2037        public Variant lookupValue(string key, VariantType expectedType)
2038        {
2039                auto p = g_variant_lookup_value(gVariant, Str.toStringz(key), (expectedType is null) ? null : expectedType.getVariantTypeStruct());
2040               
2041                if(p is null)
2042                {
2043                        return null;
2044                }
2045               
2046                return new Variant(cast(GVariant*) p, true);
2047        }
2048
2049        /**
2050         * Determines the number of children in a container #GVariant instance.
2051         * This includes variants, maybes, arrays, tuples and dictionary
2052         * entries.  It is an error to call this function on any other type of
2053         * #GVariant.
2054         *
2055         * For variants, the return value is always 1.  For values with maybe
2056         * types, it is always zero or one.  For arrays, it is the length of the
2057         * array.  For tuples it is the number of tuple items (which depends
2058         * only on the type).  For dictionary entries, it is always 2
2059         *
2060         * This function is O(1).
2061         *
2062         * Returns: the number of children in the container
2063         *
2064         * Since: 2.24
2065         */
2066        public size_t nChildren()
2067        {
2068                return g_variant_n_children(gVariant);
2069        }
2070
2071        /**
2072         * Pretty-prints @value in the format understood by g_variant_parse().
2073         *
2074         * The format is described [here][gvariant-text].
2075         *
2076         * If @type_annotate is %TRUE, then type information is included in
2077         * the output.
2078         *
2079         * Params:
2080         *     typeAnnotate = %TRUE if type information should be included in
2081         *         the output
2082         *
2083         * Returns: a newly-allocated string holding the result.
2084         *
2085         * Since: 2.24
2086         */
2087        public string print(bool typeAnnotate)
2088        {
2089                auto retStr = g_variant_print(gVariant, typeAnnotate);
2090               
2091                scope(exit) Str.freeString(retStr);
2092                return Str.toString(retStr);
2093        }
2094
2095        /**
2096         * Behaves as g_variant_print(), but operates on a #GString.
2097         *
2098         * If @string is non-%NULL then it is appended to and returned.  Else,
2099         * a new empty #GString is allocated and it is returned.
2100         *
2101         * Params:
2102         *     str = a #GString, or %NULL
2103         *     typeAnnotate = %TRUE if type information should be included in
2104         *         the output
2105         *
2106         * Returns: a #GString containing the string
2107         *
2108         * Since: 2.24
2109         */
2110        public StringG printString(StringG str, bool typeAnnotate)
2111        {
2112                auto p = g_variant_print_string(gVariant, (str is null) ? null : str.getStringGStruct(), typeAnnotate);
2113               
2114                if(p is null)
2115                {
2116                        return null;
2117                }
2118               
2119                return new StringG(cast(GString*) p, true);
2120        }
2121
2122        /**
2123         * Increases the reference count of @value.
2124         *
2125         * Returns: the same @value
2126         *
2127         * Since: 2.24
2128         */
2129        public Variant doref()
2130        {
2131                auto p = g_variant_ref(gVariant);
2132               
2133                if(p is null)
2134                {
2135                        return null;
2136                }
2137               
2138                return new Variant(cast(GVariant*) p, true);
2139        }
2140
2141        /**
2142         * #GVariant uses a floating reference count system.  All functions with
2143         * names starting with `g_variant_new_` return floating
2144         * references.
2145         *
2146         * Calling g_variant_ref_sink() on a #GVariant with a floating reference
2147         * will convert the floating reference into a full reference.  Calling
2148         * g_variant_ref_sink() on a non-floating #GVariant results in an
2149         * additional normal reference being added.
2150         *
2151         * In other words, if the @value is floating, then this call "assumes
2152         * ownership" of the floating reference, converting it to a normal
2153         * reference.  If the @value is not floating, then this call adds a
2154         * new normal reference increasing the reference count by one.
2155         *
2156         * All calls that result in a #GVariant instance being inserted into a
2157         * container will call g_variant_ref_sink() on the instance.  This means
2158         * that if the value was just created (and has only its floating
2159         * reference) then the container will assume sole ownership of the value
2160         * at that point and the caller will not need to unreference it.  This
2161         * makes certain common styles of programming much easier while still
2162         * maintaining normal refcounting semantics in situations where values
2163         * are not floating.
2164         *
2165         * Returns: the same @value
2166         *
2167         * Since: 2.24
2168         */
2169        public Variant refSink()
2170        {
2171                auto p = g_variant_ref_sink(gVariant);
2172               
2173                if(p is null)
2174                {
2175                        return null;
2176                }
2177               
2178                return new Variant(cast(GVariant*) p, true);
2179        }
2180
2181        /**
2182         * Stores the serialised form of @value at @data.  @data should be
2183         * large enough.  See g_variant_get_size().
2184         *
2185         * The stored data is in machine native byte order but may not be in
2186         * fully-normalised form if read from an untrusted source.  See
2187         * g_variant_get_normal_form() for a solution.
2188         *
2189         * As with g_variant_get_data(), to be able to deserialise the
2190         * serialised variant successfully, its type and (if the destination
2191         * machine might be different) its endianness must also be available.
2192         *
2193         * This function is approximately O(n) in the size of @data.
2194         *
2195         * Params:
2196         *     data = the location to store the serialised data at
2197         *
2198         * Since: 2.24
2199         */
2200        public void store(void* data)
2201        {
2202                g_variant_store(gVariant, data);
2203        }
2204
2205        /**
2206         * If @value is floating, sink it.  Otherwise, do nothing.
2207         *
2208         * Typically you want to use g_variant_ref_sink() in order to
2209         * automatically do the correct thing with respect to floating or
2210         * non-floating references, but there is one specific scenario where
2211         * this function is helpful.
2212         *
2213         * The situation where this function is helpful is when creating an API
2214         * that allows the user to provide a callback function that returns a
2215         * #GVariant.  We certainly want to allow the user the flexibility to
2216         * return a non-floating reference from this callback (for the case
2217         * where the value that is being returned already exists).
2218         *
2219         * At the same time, the style of the #GVariant API makes it likely that
2220         * for newly-created #GVariant instances, the user can be saved some
2221         * typing if they are allowed to return a #GVariant with a floating
2222         * reference.
2223         *
2224         * Using this function on the return value of the user's callback allows
2225         * the user to do whichever is more convenient for them.  The caller
2226         * will alway receives exactly one full reference to the value: either
2227         * the one that was returned in the first place, or a floating reference
2228         * that has been converted to a full reference.
2229         *
2230         * This function has an odd interaction when combined with
2231         * g_variant_ref_sink() running at the same time in another thread on
2232         * the same #GVariant instance.  If g_variant_ref_sink() runs first then
2233         * the result will be that the floating reference is converted to a hard
2234         * reference.  If g_variant_take_ref() runs first then the result will
2235         * be that the floating reference is converted to a hard reference and
2236         * an additional reference on top of that one is added.  It is best to
2237         * avoid this situation.
2238         *
2239         * Returns: the same @value
2240         */
2241        public Variant takeRef()
2242        {
2243                auto p = g_variant_take_ref(gVariant);
2244               
2245                if(p is null)
2246                {
2247                        return null;
2248                }
2249               
2250                return new Variant(cast(GVariant*) p, true);
2251        }
2252
2253        /**
2254         * Decreases the reference count of @value.  When its reference count
2255         * drops to 0, the memory used by the variant is freed.
2256         *
2257         * Since: 2.24
2258         */
2259        public void unref()
2260        {
2261                g_variant_unref(gVariant);
2262        }
2263
2264        /**
2265         * Determines if a given string is a valid D-Bus object path.  You
2266         * should ensure that a string is a valid D-Bus object path before
2267         * passing it to g_variant_new_object_path().
2268         *
2269         * A valid object path starts with '/' followed by zero or more
2270         * sequences of characters separated by '/' characters.  Each sequence
2271         * must contain only the characters "[A-Z][a-z][0-9]_".  No sequence
2272         * (including the one following the final '/' character) may be empty.
2273         *
2274         * Params:
2275         *     str = a normal C nul-terminated string
2276         *
2277         * Returns: %TRUE if @string is a D-Bus object path
2278         *
2279         * Since: 2.24
2280         */
2281        public static bool isObjectPath(string str)
2282        {
2283                return g_variant_is_object_path(Str.toStringz(str)) != 0;
2284        }
2285
2286        /**
2287         * Determines if a given string is a valid D-Bus type signature.  You
2288         * should ensure that a string is a valid D-Bus type signature before
2289         * passing it to g_variant_new_signature().
2290         *
2291         * D-Bus type signatures consist of zero or more definite #GVariantType
2292         * strings in sequence.
2293         *
2294         * Params:
2295         *     str = a normal C nul-terminated string
2296         *
2297         * Returns: %TRUE if @string is a D-Bus type signature
2298         *
2299         * Since: 2.24
2300         */
2301        public static bool isSignature(string str)
2302        {
2303                return g_variant_is_signature(Str.toStringz(str)) != 0;
2304        }
2305
2306        /**
2307         * Parses a #GVariant from a text representation.
2308         *
2309         * A single #GVariant is parsed from the content of @text.
2310         *
2311         * The format is described [here][gvariant-text].
2312         *
2313         * The memory at @limit will never be accessed and the parser behaves as
2314         * if the character at @limit is the nul terminator.  This has the
2315         * effect of bounding @text.
2316         *
2317         * If @endptr is non-%NULL then @text is permitted to contain data
2318         * following the value that this function parses and @endptr will be
2319         * updated to point to the first character past the end of the text
2320         * parsed by this function.  If @endptr is %NULL and there is extra data
2321         * then an error is returned.
2322         *
2323         * If @type is non-%NULL then the value will be parsed to have that
2324         * type.  This may result in additional parse errors (in the case that
2325         * the parsed value doesn't fit the type) but may also result in fewer
2326         * errors (in the case that the type would have been ambiguous, such as
2327         * with empty arrays).
2328         *
2329         * In the event that the parsing is successful, the resulting #GVariant
2330         * is returned. It is never floating, and must be freed with
2331         * g_variant_unref().
2332         *
2333         * In case of any error, %NULL will be returned.  If @error is non-%NULL
2334         * then it will be set to reflect the error that occurred.
2335         *
2336         * Officially, the language understood by the parser is "any string
2337         * produced by g_variant_print()".
2338         *
2339         * Params:
2340         *     type = a #GVariantType, or %NULL
2341         *     text = a string containing a GVariant in text form
2342         *     limit = a pointer to the end of @text, or %NULL
2343         *     endptr = a location to store the end pointer, or %NULL
2344         *
2345         * Returns: a non-floating reference to a #GVariant, or %NULL
2346         *
2347         * Throws: GException on failure.
2348         */
2349        public static Variant parse(VariantType type, string text, string limit, string[] endptr)
2350        {
2351                GError* err = null;
2352               
2353                auto p = g_variant_parse((type is null) ? null : type.getVariantTypeStruct(), Str.toStringz(text), Str.toStringz(limit), Str.toStringzArray(endptr), &err);
2354               
2355                if (err !is null)
2356                {
2357                        throw new GException( new ErrorG(err) );
2358                }
2359               
2360                if(p is null)
2361                {
2362                        return null;
2363                }
2364               
2365                return new Variant(cast(GVariant*) p, true);
2366        }
2367
2368        /**
2369         * Pretty-prints a message showing the context of a #GVariant parse
2370         * error within the string for which parsing was attempted.
2371         *
2372         * The resulting string is suitable for output to the console or other
2373         * monospace media where newlines are treated in the usual way.
2374         *
2375         * The message will typically look something like one of the following:
2376         *
2377         * |[
2378         * unterminated string constant:
2379         * (1, 2, 3, 'abc
2380         * ^^^^
2381         * ]|
2382         *
2383         * or
2384         *
2385         * |[
2386         * unable to find a common type:
2387         * [1, 2, 3, 'str']
2388         * ^        ^^^^^
2389         * ]|
2390         *
2391         * The format of the message may change in a future version.
2392         *
2393         * @error must have come from a failed attempt to g_variant_parse() and
2394         * @source_str must be exactly the same string that caused the error.
2395         * If @source_str was not nul-terminated when you passed it to
2396         * g_variant_parse() then you must add nul termination before using this
2397         * function.
2398         *
2399         * Params:
2400         *     error = a #GError from the #GVariantParseError domain
2401         *     sourceStr = the string that was given to the parser
2402         *
2403         * Returns: the printed message
2404         *
2405         * Since: 2.40
2406         */
2407        public static string parseErrorPrintContext(ErrorG error, string sourceStr)
2408        {
2409                auto retStr = g_variant_parse_error_print_context((error is null) ? null : error.getErrorGStruct(), Str.toStringz(sourceStr));
2410               
2411                scope(exit) Str.freeString(retStr);
2412                return Str.toString(retStr);
2413        }
2414
2415        /** */
2416        public static GQuark parseErrorQuark()
2417        {
2418                return g_variant_parse_error_quark();
2419        }
2420
2421        /**
2422         * Same as g_variant_error_quark().
2423         *
2424         * Deprecated: Use g_variant_parse_error_quark() instead.
2425         */
2426        public static GQuark parserGetErrorQuark()
2427        {
2428                return g_variant_parser_get_error_quark();
2429        }
2430}
Note: See TracBrowser for help on using the repository browser.