Glib::Variant(3)
πΈ NAME πΈ
This is Glib::Variant(3) from the User Contributed Perl Documentation corner of the internet, and itβs all about Glib::Variant β the strongly typed value datatype. Yes bestie, strongly typed. We love a value with range. π
β¨ SYNOPSIS β¨
my $v = Glib::Variant->new ('as', ['GTK+', 'Perl']);
my $aref = $v->get ('as');
π DESCRIPTION π
Okay so there are literally two sets of APIs for creating and dealing with Glib::Variants: the low-level API described below under METHODS, and the convenience API described in this section. Both are right here on the same page, so no scrambling.
π CONVENIENCE API π
variant = Glib::Variant->new ($format_string, $value)β constructs a variant from$format_stringand$value. It also supports constructing multiple variants when the format string is a concatenation of multiple types.(variant1, ...) = Glib::Variant->new ($format_string, $value1, ...)β samenewenergy, but it hands you multiple variants when the format string is a concatenation of multiple types.value = $variant->get ($format_string)β deconstructs$variantaccording to$format_string.
The following symbols are currently supported in format strings:
b,y,n,q,i,u,x,t,h,dβ Boolean, byte and numeric types.s,o,gβ String types.vβ Variant types.aβ Arrays.mβ Maybe types.()β Tuples.{}β Dictionary entries.
Note that if a format string specifies an array, a tuple or a dictionary entry (a,()or{}), then array references are expected bynewand produced byget. For arrays of dictionary entries (a{}), hash references are also supported bynewand handled as you would expect. No cap.
For a complete specification, see the documentation at:
<https://developer.gnome.org/glib/stable/glib-GVariantType.html>
<https://developer.gnome.org/glib/stable/glib-GVariant.html>
<https://developer.gnome.org/glib/stable/gvariant-format-strings.html>
<https://developer.gnome.org/glib/stable/gvariant-text.html>
π HIERARCHY π
Glib::Variant
π οΈ METHODS π οΈ
Hereβs the low-level method guest list, bestie. Every signature, type and Since: note stays exactly as it is. π
variant = Glib::Variant->new_array ($child_type, $children)β the array constructor.$child_type(Glib::VariantType) β the child type.$children(scalar) β the children.
variant = Glib::Variant->new_boolean ($value)β the boolean constructor.$value(boolean) β the boolean value.
variant = Glib::Variant->new_byte ($value)β the byte constructor.$value(Glib::UChar) β the byte value.
variant = Glib::Variant->new_bytestring ($string)β the bytestring constructor.$string(byte string) β the byte string.- Since: glib 2.26
variant = Glib::Variant->new_dict_entry ($key, $value)β the dictionary-entry constructor.$key(Glib::Variant) β the key.$value(Glib::Variant) β the value.
variant = Glib::Variant->new_double ($value)β the double constructor.$value(double) β the double value.
variant = Glib::Variant->new_handle ($value)β the handle constructor.$value(integer) β the handle value.
variant = Glib::Variant->new_int16 ($value)β the int16 constructor.$value(integer) β the int16 value.
variant = Glib::Variant->new_int32 ($value)β the int32 constructor.$value(integer) β the int32 value.
variant = Glib::Variant->new_int64 ($value)β the int64 constructor.$value(64 bit integer) β the int64 value.
variant = Glib::Variant->new_maybe ($child_type, $child)β the maybe constructor.$child_type(Glib::VariantType) β the child type.$child(Glib::Variant) β the child.
variant = Glib::Variant->new_object_path ($object_path)β the object-path constructor.$object_path(string) β the object path.
variant = Glib::Variant->new_signature ($signature)β the signature constructor.$signature(string) β the signature.
variant = Glib::Variant->new_string ($string)β the string constructor.$string(string) β the string.
variant = Glib::Variant->new_tuple ($children)β the tuple constructor.$children(scalar) β the children.
variant = Glib::Variant->new_uint16 ($value)β the uint16 constructor.$value(unsigned) β the uint16 value.
variant = Glib::Variant->new_uint32 ($value)β the uint32 constructor.$value(unsigned) β the uint32 value.
variant = Glib::Variant->new_uint64 ($value)β the uint64 constructor.$value(64 bit unsigned) β the uint64 value.
variant = Glib::Variant->new_variant ($value)β the variant constructor.$value(Glib::Variant) β the variant value.
boolean = $value->get_booleanβ the boolean getter.uchar = $value->get_byteβ the byte getter.string = $value->get_bytestringβ the bytestring getter.- Since: glib 2.26
variant = $value->byteswapβ the byteswap moment.variant = $value->get_child_value ($index_)β the child-value getter.$index_(unsigned) β the index.
string = $value->classifyβ the classify getter.integer = $one->compare ($two)β the comparison moment.$two(Glib::Variant) β the other variant.- Since: glib 2.26
double = $value->get_doubleβ the double getter.boolean = $one->equal ($two)β the equality check.$two(Glib::Variant) β the other variant.
integer = $value->get_handleβ the handle getter.integer = $value->hashβ the hash getter.integer = $value->get_int16β the int16 getter.integer = $value->get_int32β the int32 getter.64 bit integer = $value->get_int64β the int64 getter.boolean = $value->is_containerβ the container check.boolean = $value->is_normal_formβ the normal-form check.boolean = $string->is_object_pathβ the object-path check.boolean = $value->is_of_type ($type)β the type check.$type(Glib::VariantType) β the type.
boolean = $string->is_signatureβ the signature check.variant = $dictionary->lookup_value ($key, $expected_type)β the lookup-value moment.$key(string) β the key.$expected_type(Glib::VariantType) β the expected type.- Since: glib 2.28
variant = $value->get_maybeβ the maybe getter.unsigned = $value->n_childrenβ the number-of-children getter.variant = $value->get_normal_formβ the normal-form getter.variant = Glib::Variant::parse ($type, $text)β the parse moment.$type(Glib::VariantType) β the type.$text(string) β the text.- May croak with a
Glib::Errorin$@on failure.
string = $value->print ($type_annotate)β the print moment.$type_annotate(boolean) β the type-annotate flag.
unsigned = $value->get_sizeβ the size getter.string = $value->get_stringβ the string getter.varianttype = $value->get_typeβ the type getter.string = $value->get_type_stringβ the type-string getter.unsigned = $value->get_uint16β the uint16 getter.unsigned = $value->get_uint32β the uint32 getter.64 bit unsigned = $value->get_uint64β the uint64 getter.variant = $value->get_variantβ the variant getter.
π SEE ALSO π
GlibGlib::VariantTypeGlib::VariantDict
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Glib for a full notice.
Signed, sealed, and sent with love by perl v5.42.0 on 2023-09-05. Bye bestie! π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms