1Glib::Variant(3)      User Contributed Perl Documentation     Glib::Variant(3)
2
3
4

NAME

6       Glib::Variant -  strongly typed value datatype
7

SYNOPSIS

9         my $v = Glib::Variant->new ('as', ['GTK+', 'Perl']);
10         my $aref = $v->get ('as');
11

DESCRIPTION

13       There are two sets of APIs for creating and dealing with
14       "Glib::Variant"s: the low-level API described below under "METHODS",
15       and the convenience API described in this section.
16
17   CONVENIENCE API
18       variant = Glib::Variant->new ($format_string, $value)
19       (variant1, ...) = Glib::Variant->new ($format_string, $value1, ...)
20           Constructs a variant from $format_string and $value.  Also supports
21           constructing multiple variants when the format string is a
22           concatenation of multiple types.
23
24       value = $variant->get ($format_string)
25           Deconstructs $variant according to $format_string.
26
27       The following symbols are currently supported in format strings:
28
29         +------------------------------+---------------------------------+
30         |            Symbol            |             Meaning             |
31         +------------------------------+---------------------------------+
32         | b, y, n, q, i, u, x, t, h, d | Boolean, byte and numeric types |
33         | s, o, g                      | String types                    |
34         | v                            | Variant types                   |
35         | a                            | Arrays                          |
36         | m                            | Maybe types                     |
37         | ()                           | Tuples                          |
38         | {}                           | Dictionary entries              |
39         +------------------------------+---------------------------------+
40
41       Note that if a format string specifies an array, a tuple or a
42       dictionary entry ("a", "()" or "{}"), then array references are
43       expected by "new" and produced by "get".  For arrays of dictionary
44       entries ("a{}"), hash references are also supported by "new" and
45       handled as you would expect.
46
47       For a complete specification, see the documentation at
48
49       <https://developer.gnome.org/glib/stable/glib-GVariantType.html>
50       <https://developer.gnome.org/glib/stable/glib-GVariant.html>
51       <https://developer.gnome.org/glib/stable/gvariant-format-strings.html>
52       <https://developer.gnome.org/glib/stable/gvariant-text.html>
53

HIERARCHY

55         Glib::Variant
56

METHODS

58   variant = Glib::Variant->new_array ($child_type, $children)
59       ·   $child_type (Glib::VariantType)
60
61       ·   $children (scalar)
62
63   variant = Glib::Variant->new_boolean ($value)
64       ·   $value (boolean)
65
66   variant = Glib::Variant->new_byte ($value)
67       ·   $value (Glib::UChar)
68
69   variant = Glib::Variant->new_bytestring ($string)
70       ·   $string (byte string)
71
72       Since: glib 2.26
73
74   variant = Glib::Variant->new_dict_entry ($key, $value)
75       ·   $key (Glib::Variant)
76
77       ·   $value (Glib::Variant)
78
79   variant = Glib::Variant->new_double ($value)
80       ·   $value (double)
81
82   variant = Glib::Variant->new_handle ($value)
83       ·   $value (integer)
84
85   variant = Glib::Variant->new_int16 ($value)
86       ·   $value (integer)
87
88   variant = Glib::Variant->new_int32 ($value)
89       ·   $value (integer)
90
91   variant = Glib::Variant->new_int64 ($value)
92       ·   $value (64 bit integer)
93
94   variant = Glib::Variant->new_maybe ($child_type, $child)
95       ·   $child_type (Glib::VariantType)
96
97       ·   $child (Glib::Variant)
98
99   variant = Glib::Variant->new_object_path ($object_path)
100       ·   $object_path (string)
101
102   variant = Glib::Variant->new_signature ($signature)
103       ·   $signature (string)
104
105   variant = Glib::Variant->new_string ($string)
106       ·   $string (string)
107
108   variant = Glib::Variant->new_tuple ($children)
109       ·   $children (scalar)
110
111   variant = Glib::Variant->new_uint16 ($value)
112       ·   $value (unsigned)
113
114   variant = Glib::Variant->new_uint32 ($value)
115       ·   $value (unsigned)
116
117   variant = Glib::Variant->new_uint64 ($value)
118       ·   $value (64 bit unsigned)
119
120   variant = Glib::Variant->new_variant ($value)
121       ·   $value (Glib::Variant)
122
123   boolean = $value->get_boolean
124   uchar = $value->get_byte
125   string = $value->get_bytestring
126       Since: glib 2.26
127
128   variant = $value->byteswap
129   variant = $value->get_child_value ($index_)
130       ·   $index_ (unsigned)
131
132   string = $value->classify
133   integer = $one->compare ($two)
134       ·   $two (Glib::Variant)
135
136       Since: glib 2.26
137
138   double = $value->get_double
139   boolean = $one->equal ($two)
140       ·   $two (Glib::Variant)
141
142   integer = $value->get_handle
143   integer = $value->hash
144   integer = $value->get_int16
145   integer = $value->get_int32
146   64 bit integer = $value->get_int64
147   boolean = $value->is_container
148   boolean = $value->is_normal_form
149   boolean = $string->is_object_path
150   boolean = $value->is_of_type ($type)
151       ·   $type (Glib::VariantType)
152
153   boolean = $string->is_signature
154   variant = $dictionary->lookup_value ($key, $expected_type)
155       ·   $key (string)
156
157       ·   $expected_type (Glib::VariantType)
158
159       Since: glib 2.28
160
161   variant = $value->get_maybe
162   unsigned = $value->n_children
163   variant = $value->get_normal_form
164   variant = Glib::Variant::parse ($type, $text)
165       ·   $type (Glib::VariantType)
166
167       ·   $text (string)
168
169       May croak with a Glib::Error in $@ on failure.
170
171   string = $value->print ($type_annotate)
172       ·   $type_annotate (boolean)
173
174   unsigned = $value->get_size
175   string = $value->get_string
176   varianttype = $value->get_type
177   string = $value->get_type_string
178   unsigned = $value->get_uint16
179   unsigned = $value->get_uint32
180   64 bit unsigned = $value->get_uint64
181   variant = $value->get_variant

SEE ALSO

183       Glib, Glib::VariantType, Glib::VariantDict
184
186       Copyright (C) 2003-2011 by the gtk2-perl team.
187
188       This software is licensed under the LGPL.  See Glib for a full notice.
189
190
191
192perl v5.32.0                      2020-07-28                  Glib::Variant(3)
Impressum