man-pages/man3/Glib::Flags.3pm.html
2021-03-31 01:06:50 +01:00

255 lines
5.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Glib::Flags</TITLE>
</HEAD><BODY>
<H1>Glib::Flags</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-02-18<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Glib::Flags - methods and overloaded operators for flags
<A NAME="lbAC">&nbsp;</A>
<H2>HIERARCHY</H2>
<PRE>
Glib::Flags
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
Glib maps flag and enum values to the nicknames strings provided by the
underlying C libraries. Representing flags this way in Perl is an interesting
problem, which Glib solves by using some cool overloaded operators.
<P>
The functions described here actually do the work of those overloaded
operators. See the description of the flags operators in the ``This Is
Now That'' section of Glib for more info.
<A NAME="lbAE">&nbsp;</A>
<H2>METHODS</H2>
<A NAME="lbAF">&nbsp;</A>
<H3>scalar = $class-&gt;<B>new</B> ($a)</H3>
<DL COMPACT>
<DT id="1">&bull;<DD>
<TT>$a</TT> (scalar)
</DL>
<P>
Create a new flags object with given bits. This is for use from a
subclass, it's not possible to create a <TT>&quot;Glib::Flags&quot;</TT> object as such.
For example,
<P>
<PRE>
my $f1 = Glib::ParamFlags-&gt;new ('readable');
my $f2 = Glib::ParamFlags-&gt;new (['readable','writable']);
</PRE>
<P>
An object like this can then be used with the overloaded operators.
<A NAME="lbAG">&nbsp;</A>
<H3>scalar = $a-&gt;<B>all</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="2">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="3">&bull;<DD>
<TT>$swap</TT> (scalar)
</DL>
<A NAME="lbAH">&nbsp;</A>
<H3>aref = $f-&gt;<B>as_arrayref</B></H3>
Return the bits of <TT>$f</TT> as a reference to an array of strings, like
['flagbit1','flagbit2']. This is the overload function for <TT>&quot;@{}&quot;</TT>,
ie. arrayizing <TT>$f</TT>. You can call it directly as a method too.
<P>
Note that @$f gives the bits as a list, but as_arrayref gives an arrayref.
If an arrayref is what you want then the method style
<B>somefunc()</B>-&gt;as_arrayref can be more readable than [@{<B>somefunc()</B>}].
<A NAME="lbAI">&nbsp;</A>
<H3>bool = $f-&gt;<B>bool</B></H3>
Return 1 if any bits are set in <TT>$f</TT>, or 0 if none are set. This is the
overload for <TT>$f</TT> in boolean context (like <TT>&quot;if&quot;</TT>, etc). You can call it
as a method to get a true/false directly too.
<A NAME="lbAJ">&nbsp;</A>
<H3>integer = $a-&gt;<B>eq</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="4">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="5">&bull;<DD>
<TT>$swap</TT> (integer)
</DL>
<A NAME="lbAK">&nbsp;</A>
<H3>integer = $a-&gt;<B>ge</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="6">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="7">&bull;<DD>
<TT>$swap</TT> (integer)
</DL>
<A NAME="lbAL">&nbsp;</A>
<H3>scalar = $a-&gt;<B>intersect</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="8">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="9">&bull;<DD>
<TT>$swap</TT> (scalar)
</DL>
<A NAME="lbAM">&nbsp;</A>
<H3>integer = $a-&gt;<B>ne</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="10">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="11">&bull;<DD>
<TT>$swap</TT> (integer)
</DL>
<A NAME="lbAN">&nbsp;</A>
<H3>scalar = $a-&gt;<B>sub</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="12">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="13">&bull;<DD>
<TT>$swap</TT> (scalar)
</DL>
<A NAME="lbAO">&nbsp;</A>
<H3>scalar = $a-&gt;<B>union</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="14">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="15">&bull;<DD>
<TT>$swap</TT> (scalar)
</DL>
<A NAME="lbAP">&nbsp;</A>
<H3>scalar = $a-&gt;<B>xor</B> ($b, $swap)</H3>
<DL COMPACT>
<DT id="16">&bull;<DD>
<TT>$b</TT> (scalar)
<DT id="17">&bull;<DD>
<TT>$swap</TT> (scalar)
</DL>
<A NAME="lbAQ">&nbsp;</A>
<H2>SEE ALSO</H2>
Glib
<A NAME="lbAR">&nbsp;</A>
<H2>COPYRIGHT</H2>
Copyright (C) 2003-2011 by the gtk2-perl team.
<P>
This software is licensed under the <FONT SIZE="-1">LGPL.</FONT> See Glib for a full notice.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="18"><A HREF="#lbAB">NAME</A><DD>
<DT id="19"><A HREF="#lbAC">HIERARCHY</A><DD>
<DT id="20"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="21"><A HREF="#lbAE">METHODS</A><DD>
<DL>
<DT id="22"><A HREF="#lbAF">scalar = $class-&gt;<B>new</B> ($a)</A><DD>
<DT id="23"><A HREF="#lbAG">scalar = $a-&gt;<B>all</B> ($b, $swap)</A><DD>
<DT id="24"><A HREF="#lbAH">aref = $f-&gt;<B>as_arrayref</B></A><DD>
<DT id="25"><A HREF="#lbAI">bool = $f-&gt;<B>bool</B></A><DD>
<DT id="26"><A HREF="#lbAJ">integer = $a-&gt;<B>eq</B> ($b, $swap)</A><DD>
<DT id="27"><A HREF="#lbAK">integer = $a-&gt;<B>ge</B> ($b, $swap)</A><DD>
<DT id="28"><A HREF="#lbAL">scalar = $a-&gt;<B>intersect</B> ($b, $swap)</A><DD>
<DT id="29"><A HREF="#lbAM">integer = $a-&gt;<B>ne</B> ($b, $swap)</A><DD>
<DT id="30"><A HREF="#lbAN">scalar = $a-&gt;<B>sub</B> ($b, $swap)</A><DD>
<DT id="31"><A HREF="#lbAO">scalar = $a-&gt;<B>union</B> ($b, $swap)</A><DD>
<DT id="32"><A HREF="#lbAP">scalar = $a-&gt;<B>xor</B> ($b, $swap)</A><DD>
</DL>
<DT id="33"><A HREF="#lbAQ">SEE ALSO</A><DD>
<DT id="34"><A HREF="#lbAR">COPYRIGHT</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:44 GMT, March 31, 2021
</BODY>
</HTML>