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

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

Initial release

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