Hi,
In my application, there is a inheritance hierarchy in which only the classes that are at the end of the inheritance chain are non-abstract classes. Also there is some usage of boost::variant. I want to write a function which takes a pointer and a Type and says whether the object belongs to that type.
For example
#define IsA(nod...
If a compiler doesn't "support" RTTI, does that mean that the compiler can not handle class hierarchies that have virtual functions in them? Or have I been misunderstanding the literature about how RTTI isn't portable, and the issues lie elsewhere?
Thank you all for your comments!
...
I am developing game editor in C# that uses c++ lib files.
I want RTTI for C++ classes in C#.
Is it possible to get RTTI of C++ class in C#?
If yes how?
...
I try to write a kind of object/record serializer with Delphi 2010 and wonder if there is a way to detect, if a record is a variant record. E.g. the TRect record as defined in Types.pas:
TRect = record
case Integer of
0: (Left, Top, Right, Bottom: Longint);
1: (TopLeft, BottomRight: TPoint);
end;
As my serializer should work recu...
Has anyone an idea, how I can make TValue using a reference to the original data? In my serialization project, I use (as suggested in XML-Serialization) a generic serializer which stores TValues in an internal tree-structure (similar to the MemberMap in the example).
This member-tree should also be used to create a dynamic setup form an...
As already discussed in Rtti data manipulation and consistency in Delphi 2010 a consistency between the original data and rtti values can be reached by accessing members by using a pair of TRttiField and an instance pointer. This would be very easy in case of a simple class with only basic member types (like e.g. integers or strings).
Bu...
I have a object with some TObjectList<>-fields that I try to encode as JSON with help form SuperObject.
TLogs = TObjectList<TLog>;
TMyObject = class(TObject)
private
FLogs: TLogs;
end;
Deep inside SuperObjects code, there is a ToClass procedure, iterating the fields and add them to the json result.
In this loop, there is a check on...
This is probably going to be a "no", but is there any way I can use Delphi's RTTI, either old-school or the 2010 extended RTTI, to pass in a string containing the name of a type, specifically the name of an enumerated type, and have it give me the PTypeInfo for that type? I've looked through RTTI.pas and TypInfo.pas and I don't see any ...
Hello,
I need to know about good C++ Reflection API(Would be better if Microsoft API is available) which enables me to determine the types(classes,structs,enums,ints,float,doubles...)identification at runtime, declaring them and finally to call methods on those types at run time too.
Regards
Usman
...
My question is related to RTTI in C++ where I'm trying to check if an object belongs to the type hierarchy of another object. The BelongsTo() method checks this.
I tried using typeid, but it throws an error and I'm not sure about any other way how I can find the target type to convert to at runtime.
#include <iostream>
#include <typein...
I've been banging my head on an issue and before I continue injuring myself some more, I'd like to confirm:
Is it possible to have a GCC project that uses libraries that are compiled with and without RTTI?
So, for example, I have project A (compiled without RTTI) that uses library B (compiled with RTTI) and library C (compiled withou...
I'm trying to fetch an interface using D2010 RTTI.
program rtti_sb_1;
{$APPTYPE CONSOLE}
{$M+}
uses
SysUtils,
Rtti,
mynamespace in 'mynamespace.pas';
var
ctx: TRttiContext;
RType: TRttiType;
MyClass: TMyIntfClass;
begin
ctx := TRttiContext.Create;
MyClass := TMyIntfClass.Create;
// This prints a list of all kn...
I've recently been able to fetch a TRttiType for an interface using TRttiContext.FindType using Robert Loves "GetType"-workaround ("registering" the interface by an explicit call to ctx.GetType, e.g. RType := ctx.GetType(TypeInfo(IMyPrettyLittleInterface));).
One logical next step would be to iterate the methods of said interface. Consi...
I've recently experimented extensively with interfaces and D2010 RTTI. I don't know at runtime the actual type of the interface; although I will have access to it's qualified name using a string.
Consider the following:
program rtti_sb_1;
{$APPTYPE CONSOLE}
uses
SysUtils, Rtti, TypInfo, mynamespace in 'mynamespace.pas';
var
ctx: ...
I've got a function that takes a list of CRuntimeClass pointers in order to setup a view. I'd like to return without doing anything if the function is called with a list of the same classes that are already setup. Saving the pointer values and comparing them on the next call is currently working, but I want to verify that that's a legal ...
(This question should probably be answered with a reference to Stroustrup.)
It seems extremely useful to be able to request a pointer to the most derived class, as in the following:
class Base { ... };
class DerivedA { ... };
class DerivedB { ... };
class Processor
{
public:
void Do(Base* b) {...}
void Do(DerivedA* d) {...}
voi...
Using Delphi 2007 I can write the following code:
interface
TTestType = (ttTest1, ttTest2);
procedure enumName;
var
EnumName: String;
begin
EnumName := GetEnumName(TypeInfo(TTestType), Ord(ttTest1));
end;
This compiles and works, EnumName contains 'ttTest1' at the end of the function.
However, when I change my TTestType to somet...
As we all known, when we call a constructor of a class like this:
instance := TSomeClass.Create;
The Delphi compiler actually do the following things:
Call the static NewInstance method
to allocate memory and initialize
the memory layout.
Call the constructor method to
perform the initialization of the class
Call the AfterConstructi...
I have problems in a following code:
program Project4;
{$APPTYPE CONSOLE}
uses
SysUtils, RTTI;
type
TRecord2 = record
c: integer;
d: integer;
end;
TClass1 = class
public
FRecord: record
a: integer;
b: integer;
end;
FRecord2: TRecord2;
FPointRecord3: ^TRecord2;
constructor Create;
...
I have proved that I can get the name of an interface from its GUID using Delphi 2010 (eg IMyInterface converted to the string 'IMyInterface'. I'd like to achieve this in Delphi 7 (for compatibility). Is this possible? Or are there fundamental compiler limitations.
...