Search code examples
delphidelphi-2010rtti

RTTI: Can I Get a Type by Name?


Given a text string containing a type name, is there some way to get the appropriate type itself?

I'm looking to do something like this:

type
  TSomeType<T> = class
    // yadda yadda
  end;

procedure DoSomething;
var
  obj : TObject;
begin
  o := TSomeType<GetTypeByName('integer')>.Create;
  // do stuff with obj
end;

I've looked at several RTTI explanations online and looked through the Delphi units and don't see what I'm looking for. Is this possible?


Solution

  • No, generics are entirely compiletime.