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