Questions tagged [rtti]

RTTI stands for Run-Time Type Information, it is also known as reflection; it allows access to compile-time data at run-time.

RTTI refers to the ability of the system to report on the dynamic type of an object and to provide information about that type at runtime (as opposed to at compile time). When utilized consistently, it can be a powerful tool to ease the work of the programmer in managing resources, or as the basis for writing reflective code. Further explanation can be found on Wikipedia

824 questions
8
votes
1 answer

C++ RTTI in a Windows 64-bit VectoredExceptionHandler, MS Visual Studio 2015

I'm working on small Windows Exception handling engine trying to gather maximum information from the system, including C++ exceptions RTTI. In a 32-bit VectoredExceptionHandler compiled by MSVS 2015, I successfully can obtain std::type_info pointer…
ded32
  • 316
  • 1
  • 11
8
votes
3 answers

Delphi: At runtime find classes that descend from a given base class?

Is there at way, at runtime, to find all classes that descend from a particular base class? For example, pretend there is a class: TLocalization = class(TObject) ... public function GetLanguageName: string; end; or pretend there is a…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
8
votes
2 answers

Does C++11 provide hashing functions for std::type_info?

I'm still working on a good solution to my One-Of-A-Type Container Problem -- and upon reflection I think it would be nice to be able to just use something like a std::map. Unfortunately, std::type_info does not define an…
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
8
votes
1 answer

Getting type of record field with RTTI fails for static arrays

I am trying to get types for record fields in order to create correct comparer (as general solution for any/almost any record type). I can't find type information for static arrays: TArrFieldTest = record a: string; b: array[0..3] of…
Andrei Galatyn
  • 3,322
  • 2
  • 24
  • 38
8
votes
3 answers

What is the "identity pointer" before a TTypeInfo there for?

If you poke around enough in Delphi internals, you'll find something strange and apparently undocumented about TTypeInfo records generated by the compiler. If the PTypeInfo points to a TTypeInfo record at address X, at X - 4 you'll find the next 4…
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
8
votes
2 answers

Delphi 2010: whatever happened to TRTTIConstructor?

I've got two questions (of which at least one is regarding RTTI in D2010 and dynamic instancing) I was reading what appears to be the foils for a conference talk by Barry Kelly, and found on p. 13 something that looked really interesting:…
conciliator
  • 6,078
  • 6
  • 41
  • 66
8
votes
1 answer

How does RTTI work?

I have some confusion regarding the RTTI mechanism in C++. Suppose in have class A and class B that inherits from A. Now consider the following code: B* b = new B(); A* a = dynamic_cast(b); I know that polymorphic classes with virtual methods…
Dan Dv
  • 473
  • 3
  • 12
8
votes
2 answers

How can I check if a library was compiled with -fno-rtti?

Assume a simple file bla.cpp: struct MyClass { virtual int foo(int x); virtual ~MyClass(); }; int MyClass::foo(int x) { return x + 23; } MyClass::~MyClass() {} Build into a shared library with g++ -c -fPIC bla.cpp g++ -shared -o bla.so…
pmr
  • 58,701
  • 10
  • 113
  • 156
8
votes
1 answer

Enumerate all Delphi classes that implement a given interface?

With the new extended RTTI in Delphi 2010, can a Delphi application (at run time) build a list of all classes which implement a given interface?
mjn
  • 36,362
  • 28
  • 176
  • 378
8
votes
2 answers

Delphi - Extract setter method's name of a property

In the following type: MyClass = class(TInterfacedPersistent) private FMyProperty: Integer; published procedure setMyProperty(Value: Integer); virtual; property MyProperty: Integer read FMyProperty write setMyProperty; I would like to…
Daniel Chaves
  • 304
  • 3
  • 11
8
votes
1 answer

Delphi Class Helper RTTI GetMethod

Lets say I have a sample class helper TSampleClassHelper = class helper for TSampleClass public procedure SomeHelper; end; I do the following: var obj :TSampleClass; begin obj:=TSampleClass.Create; obj.SomeHelper; end; and this works as…
AJ.
  • 10,732
  • 13
  • 41
  • 50
8
votes
2 answers

Subclassing class from shared library compiled with -fno-rtti

I am trying to subclass from a shared library which was compiled with -fno-rtti. Unfortunately other libraries in my code base require -frtti. As a result I am getting link errors because the superclass does not have a typeinfo struct. Error…
Jon L
  • 273
  • 1
  • 7
8
votes
2 answers

How do I instantiate a class from its TRttiType?

I want to create a form given its class name as a string, which has been asked about before, but instead of calling GetClass, I want to use Delphi's new RTTI feature. With this code, I've got a TRttiType, but I don't know how to instantiate it. var …
Niyoko
  • 7,512
  • 4
  • 32
  • 59
8
votes
2 answers

What is the simplest RTTI implementation for C++?

I'm trying to implement exception handling for an embedded OS and I'm stuck at how to detect the type of the thrown "exception" (to select the appropriate handler). The saving and restoring context parts of the exception handling are already done,…
freitass
  • 6,542
  • 5
  • 40
  • 44
8
votes
1 answer

Delphi - Invoke Record method per name

I wrote a scriptlanguage for my applications and my goal is to make it possible to publish any type from delphi in the script. I use rtti to automatize this task. For any instance type like classes I use the following code to find and call a method…