Math Utilities

Bitwise

class CommonBitwiseUtils

Bases: object

Utilities for performing bitwise operations, so you do not have to remember how they are done.

static add_flags(value, flags)

Add Flags to a value.

Parameters:
  • value (CommonEnumFlagsTypeValueType) – A flags enum or an integer.
  • flags (Union[CommonIntFlags, int, Tuple[CommonEnumFlagsTypeValueType]]) – A flags enum, an integer, or a collection of flags enums or integers.
Returns:

The new value.

Return type:

CommonEnumFlagsTypeValueType

static contains_all_flags(value, flags)

Determine if all of the Flags are found within a value.

Parameters:
  • value (CommonEnumFlagsTypeValueType) – A flags enum or an integer.
  • flags (Union[CommonIntFlags, int, Tuple[CommonEnumFlagsTypeValueType]]) – A flags enum, an integer, or a collection of flags enums or integers.
Returns:

True, if all of the specified Flags are found within the value. False, if not.

Return type:

bool

static contains_any_flags(value, flags)

Determine if any of the Flags are found within a value.

Parameters:
  • value (CommonEnumFlagsTypeValueType) – A flags enum or an integer.
  • flags (Union[CommonIntFlags, int, Tuple[CommonEnumFlagsTypeValueType]]) – A flags enum, an integer, or a collection of flags enums or integers.
Returns:

True, if any of the specified Flags are found within the value. False, if not.

Return type:

bool

static contains_no_flags(value, flags)

Determine if none of the Flags are found within a value.

Parameters:
  • value (CommonEnumFlagsTypeValueType) – A flags enum or an integer.
  • flags (Union[CommonIntFlags, int, Tuple[CommonEnumFlagsTypeValueType]]) – A flags enum, an integer, or a collection of flags enums or integers.
Returns:

True, if none of the specified Flags are found within the value. False, if not.

Return type:

bool

static remove_flags(value, flags)

Remove Flags from a value.

Parameters:
  • value (CommonEnumFlagsTypeValueType) – A flags enum or an integer.
  • flags (Union[CommonIntFlags, int, Tuple[CommonEnumFlagsTypeValueType]]) – A flags enum, an integer, or a collection of flags enums or integers.
Returns:

The new value.

Return type:

CommonEnumFlagsTypeValueType