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
0
votes
1 answer

Avoiding RTTI In Java

If I have a superclass, say Animal, and two subclasses: Zebra and Giraffe, If I decide to define a Vector of Animals: Vector animals = new Vector(); and I want to say: You can add Giraffes, but you must own at least one Zebra first. What…
destructo_gold
  • 319
  • 1
  • 4
  • 10
0
votes
0 answers

How to take type as a parameter in C++, similar to typeid(T)

I have checked out this and other similar questions, but all the answer says that I need to use a template. However, let's say I want to implement typeid(T) from the standard library for fun. How would I be able to do that? I tried to track down the…
leorex
  • 2,058
  • 1
  • 14
  • 15
0
votes
3 answers

Delphi - access class string property by its value

I have a class defined which contains only strings as properties, and I need to get the property name based on its value as in the example below. In the example there are only 3 properties, in the real life class there are almost 1000. The problem…
RBA
  • 12,337
  • 16
  • 79
  • 126
0
votes
0 answers

[MSVC]encounter std::__non_rtti_object exception

In my case I write a Kernel.dll which wraps CxImage object(either CxImageJPG or CxImage) defined in xImage.dll which shared with other binary modules(no sourcecode): class CCxImageWraper{ public: shared_ptr m_spImage; ... } when…
Gohan
  • 2,422
  • 2
  • 26
  • 45
0
votes
1 answer

Visual C++ find out max possible value of variable's data type

I am using VS2010 to port an existing Mac application written in C++ to Windows. The following line of code: T var_max; var_max = std::numeric_limits::max(); given a variable, determines the maximum value for the data type of that…
go4sri
  • 1,490
  • 2
  • 15
  • 29
0
votes
1 answer

Haxe documentation XML: how to exclude standard library?

I want to make a small tool in Haxe, that inspects the haxedoc comments. I figured the best way to get these comments is to use the "haxe -xml" option, and load in the resulting XML file. However, when I generate the XML, it seems to include the…
0
votes
1 answer

How to get the type of the elements in a declared TList

I'd like to know if there is a way to get the type of the elements of a declared, but not instantiated, TList. I can capture the class of an object property like this: MyList: TList read FMyList; MyRTTIProperty: TRttiProperty; …
Daniel Chaves
  • 304
  • 3
  • 11
0
votes
2 answers

Why do Items from one comboBox not copy to another?

I have multiple comboboxes on a tabpage on a tabcontrol on a form. Trying to loop through the controls has not worked (see this). So, I tried to go at it from another angle: finding the controls based on their name. As an initial POC, I just wanted…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
0
votes
1 answer

Good use for RTTI

I have been reading the new book Coding in Delphi by Nick Hodges. I just finished the chapters on RTTI and Attributes, and I am understanding some of the basics of RTTI, but I am wondering if anyone has any good examples of using RTTI and or…
TheEndIsNear
  • 395
  • 3
  • 17
0
votes
2 answers

How to get the object type from a collection (vector) of parent objects using RTTI

I have a base class which has two child classes derived from it. class A {}; class B : public A {}; class C : public A {}; I have another class that has a pointer to collection of class A members using a vector, something like this: vector
Julen
  • 1,574
  • 3
  • 22
  • 38
0
votes
1 answer

RTTI behavior not appearing as expected

I have written this code in MS Visual Studio Express 2012 to see the rtti behavior. But it is not working as expected. What is wrong in my code? Shape.h class Shape { public: Shape(){} virtual ~Shape(){} virtual double area() =…
cppcoder
  • 22,227
  • 6
  • 56
  • 81
0
votes
2 answers

Java dynamic downcasting from generic list

how i can dynamic downcast objects, with out instanceof statement? I reading Bruce Eckel's Thinking in Java, and there using Class, and there is such a theme, but I was not approached P.s. Sorry for my English. public class GenericTest { …
Jaz Brok
  • 231
  • 1
  • 4
  • 18
0
votes
2 answers

Explicit call to base copy constructor => RTTI info lost. Bug?

First of all: I ask this question just out of curiosity, to understand what's really happening. I don't use in production code like this so I don't want to see answers suggesting another solution. Having this code: class Base{ public: virtual…
Emil Condrea
  • 9,705
  • 7
  • 33
  • 52
0
votes
1 answer

Map a void* back to its original type

I am creating a Lua api for my program. I want to be able to do the following: void* CreateA() { A* a = new A(); PointerTypes[a] = A; return reinterpret_cast(a); } void* CreateB() { B* b = new B(); PointerTypes[b] =…
akaltar
  • 1,002
  • 1
  • 19
  • 25
0
votes
1 answer

What is wrong with this?

The assignment does not seem to work. Compiler is telling me is can't find the right constructor. Course::Course(Course& course){ if(dynamic_cast(course.assessment) != NULL){ assessment = new…
Josip Dorvak
  • 121
  • 1
  • 3
  • 13