RGtk2 (version 2.20.31)

enums-and-flags: Enums and Flags

Description

Convenience functions and operators for operating on bitflags and enums

Usage

as.flag(x) "["(x, value) "|"(x, y) "&"(x, y) "!"(x) "=="(x, y)

Arguments

x
Numeric value to coerce to a flag, an object of class flags, or the left hand operand
y
Right hand operand
value
The character id or index for a particular flag in a flags vector

Value

A flag for as.flag, [.flags, and the bitwise operators. A logical value for ==.enum.

Details

The libraries bound by RGtk2 often return numeric values that are either bitflags or enumerations. In order to facilitate operations on these types (especially bitflags), several methods have been defined corresponding to conventional operators for performing bitwise operations and comparisons.

RGtk2 defines all of the enum and flag types from the API's as vectors of class flags or enums with their names corresponding to the nicknames of the values. The [ operator on the flags class retrieves a value as a flag. This only necessary for the bitwise ops and thus is not necessary for enums.

The ==.enum method compares a enum with either a character or numeric representation of an enum value.