So in der Art vielleicht:
Delphi-Quellcode:
procedure TForm1.Test<T>;
var
TypeInfo: PTypeInfo;
TypeData: PTypeData;
I: Integer;
V: T;
begin
TypeInfo := System.TypeInfo(T);
Assert(Assigned(TypeInfo) and (TypeInfo^.Kind = tkEnumeration));
TypeData := System.TypInfo.GetTypeData(TypeInfo);
for I := TypeData^.MinValue to TypeData^.MaxValue do
begin
Move(I, V, SizeOf(T));
ShowMessage(TRttiEnumerationType.GetName<T>(V));
end;
end;
bzw.
Delphi-Quellcode:
procedure TForm1.Test<T>;
var
TypeInfo: PTypeInfo;
TypeData: PTypeData;
I: Integer;
V: T absolute I;
begin
TypeInfo := System.TypeInfo(T);
Assert(Assigned(TypeInfo) and (TypeInfo^.Kind = tkEnumeration));
TypeData := System.TypInfo.GetTypeData(TypeInfo);
for I := TypeData^.MinValue to TypeData^.MaxValue do
begin
ShowMessage(TRttiEnumerationType.GetName<T>(V));
end;
end;
Da gibt es aber noch diverse Fallstricke glaube ich.