C# Class Nez.Flags

utility class to assist with dealing with bitmasks. All methods except isFlagSet expect the flag parameter to be a non-shifted flag. This lets you use plain old ints (0, 1, 2, 3, etc) to set/unset your flags.
Show file Open project: prime31/Nez

Public Methods

Method Description
binaryStringRepresentation ( this self, int leftPadWidth = 10 ) : string

prints the binary representation of the int. Handy for debugging int flag overlaps visually.

invertFlags ( int &self ) : void

inverts the set bits of the int

isFlagSet ( this self, int flag ) : bool

checks to see if the bit flag is set in the int. This check expects flag to be shifted already!

isUnshiftedFlagSet ( this self, int flag ) : bool

checks to see if the bit flag is set in the int

setFlag ( int &self, int flag ) : void

sets the flag bit of the int

setFlagExclusive ( int &self, int flag ) : void

sets the flag bit of the int removing any already set flags

unsetFlag ( int &self, int flag ) : void

unsets the flag bit of the int

Method Details

binaryStringRepresentation() public static method

prints the binary representation of the int. Handy for debugging int flag overlaps visually.
public static binaryStringRepresentation ( this self, int leftPadWidth = 10 ) : string
self this Self.
leftPadWidth int Left pad width.
return string

invertFlags() public static method

inverts the set bits of the int
public static invertFlags ( int &self ) : void
self int Self.
return void

isFlagSet() public static method

checks to see if the bit flag is set in the int. This check expects flag to be shifted already!
public static isFlagSet ( this self, int flag ) : bool
self this Self.
flag int Flag.
return bool

isUnshiftedFlagSet() public static method

checks to see if the bit flag is set in the int
public static isUnshiftedFlagSet ( this self, int flag ) : bool
self this Self.
flag int Flag.
return bool

setFlag() public static method

sets the flag bit of the int
public static setFlag ( int &self, int flag ) : void
self int Self.
flag int Flag.
return void

setFlagExclusive() public static method

sets the flag bit of the int removing any already set flags
public static setFlagExclusive ( int &self, int flag ) : void
self int Self.
flag int Flag.
return void

unsetFlag() public static method

unsets the flag bit of the int
public static unsetFlag ( int &self, int flag ) : void
self int Self.
flag int Flag.
return void