Title: Check if an enumerated value is set in Int64 enumerate set value
Question: Once you've casted an EnumeratedValuesToInt64 (article in reference), you can check if an enumerated value is set on/off.
Answer:
I take the same exemple in the referenced article
type
TAnyEnumerated = (aeFirst, aeSecond, aeThird, aeFourth);
TEnumeratedSets = set of TAnyEnumerated;
...
var
EnumSets: TEnumeratedSets;
EnumValue: Int64;
begin
EnumSets := [aeSecond, aeFourth];
EnumValue := EnumValuesToInt64(TypeInfo(TEnumeratedSets), @EnumSets);
// EnumValue -- 10
end;
...
By implementing the following function :
function IsEnumValueSet(const AEnumSets: Int64; const AEnumValue: Integer): Boolean;
begin
Result := (AEnumSets and (Int64(1) shl Byte(AEnumValue))) 0;
end;
How to use it ?
---------------
IsEnumValueSet(EnumValue, Ord(aeFirst)); // Result := False;
IsEnumValueSet(EnumValue, Ord(aeSecond)); // Result := True;