1Glib::Flags(3) User Contributed Perl Documentation Glib::Flags(3)
2
3
4
6 Glib::Flags - methods and overloaded operators for flags
7
9 Glib::Flags
10
12 Glib maps flag and enum values to the nicknames strings provided by the
13 underlying C libraries. Representing flags this way in Perl is an
14 interesting problem, which Glib solves by using some cool overloaded
15 operators.
16
17 The functions described here actually do the work of those overloaded
18 operators. See the description of the flags operators in the "This Is
19 Now That" section of Glib for more info.
20
22 scalar = $class->new ($a)
23 • $a (scalar)
24
25 Create a new flags object with given bits. This is for use from a
26 subclass, it's not possible to create a "Glib::Flags" object as such.
27 For example,
28
29 my $f1 = Glib::ParamFlags->new ('readable');
30 my $f2 = Glib::ParamFlags->new (['readable','writable']);
31
32 An object like this can then be used with the overloaded operators.
33
34 scalar = $a->all ($b, $swap)
35 • $b (scalar)
36
37 • $swap (scalar)
38
39 aref = $f->as_arrayref
40 Return the bits of $f as a reference to an array of strings, like
41 ['flagbit1','flagbit2']. This is the overload function for "@{}", ie.
42 arrayizing $f. You can call it directly as a method too.
43
44 Note that @$f gives the bits as a list, but as_arrayref gives an
45 arrayref. If an arrayref is what you want then the method style
46 somefunc()->as_arrayref can be more readable than [@{somefunc()}].
47
48 bool = $f->bool
49 Return 1 if any bits are set in $f, or 0 if none are set. This is the
50 overload for $f in boolean context (like "if", etc). You can call it
51 as a method to get a true/false directly too.
52
53 integer = $a->eq ($b, $swap)
54 • $b (scalar)
55
56 • $swap (integer)
57
58 integer = $a->ge ($b, $swap)
59 • $b (scalar)
60
61 • $swap (integer)
62
63 scalar = $a->intersect ($b, $swap)
64 • $b (scalar)
65
66 • $swap (scalar)
67
68 integer = $a->ne ($b, $swap)
69 • $b (scalar)
70
71 • $swap (integer)
72
73 scalar = $a->sub ($b, $swap)
74 • $b (scalar)
75
76 • $swap (scalar)
77
78 scalar = $a->union ($b, $swap)
79 • $b (scalar)
80
81 • $swap (scalar)
82
83 scalar = $a->xor ($b, $swap)
84 • $b (scalar)
85
86 • $swap (scalar)
87
89 Glib
90
92 Copyright (C) 2003-2011 by the gtk2-perl team.
93
94 This software is licensed under the LGPL. See Glib for a full notice.
95
96
97
98perl v5.36.0 2022-07-22 Glib::Flags(3)