Hi there,
I would like to know how to use the Invoke method of the TRttiMethod class in C++Builder 2010.
This is my code
Tpp *instance=new Tpp(this);
TValue *args;
TRttiContext * ctx=new TRttiContext();
TRttiType * t = ctx->GetType(FindClass(instance->ClassName()));
TRttiMethod *m=t->GetMethod("Show");
m->Invoke(instance,args,0);
...
Is there any real difference between:
id value;
BOOL compare1 = [value isMemberOfClass:[SomeClass class]];
BOOL compare2 = [value class] == [SomeClass class];
to check if value is a SomeClass object?
...
Please could someone explain me what's the difference between public and published class members in Delphi?
I tried to look at Delphi help and I understand that these members have the same visibility, but I don't understand very well how they differ and when should I use published members instead of public ones.
Thanks a lot.
...
Given a record type:
TItem = record
UPC : string[20];
Price : Currency;
Cost : Currency;
...
end;
And the name of a field as a string, how can I get the offset of that field within the record? I need to do this at runtime - the name of the field to access is decided at runtime.
Example:
var
pc : Integer;
fieldName...
Can one use RTTI for distributed systems? If so, what are the disadvantages? too slow, too much memory or performance unpredictable?
Thanks
...
Here is some sample code explaining what I am trying to achieve.
Basically, I have an algorithm that depends on some basic operations available in a class. I have defined those operations in a pure abstract base class. I want to apply that algorithm to a variety of objects that provide those operations by deriving classes for the specif...
Hi all!
I'm currently working on integrating a third-party package that uses lots of RTTI stuff on a non-RTTI platform (Android). Basically, I did my own RTTI implementation but I'm stuck on a problem.
The issue is that a lot of classes are having the diamond inheritance problem since all the classes derive from the same base class (ob...
Some of my classes should be treated differently. Which solution is better:
Introduce new interface to my class hierarchy and check whether the class implements it or not, using RTTI (runtime time identification)
Add a method which returns boolean value that indicates whether this class should be treated normally or deserves special tr...
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 bytes describe a pointer to X. For example:
procedure test(info: PTypeInfo);
var
addr:...
I'm writing some code to translate a C++ type to an appropriate type for a SQL DB. I want to identify the type, and then depending on what it is, produce the appropriate SQL code. I'm not sure exactly what can be done in this regard by using RTTI, auto, or decltype. I have some ideas but I'm not sure if they're workable.
For instance...
With
Cont := TRttiContext.Create;
for Prop in Cont.GetType(TStrings).GetDeclaredProperties do
Memo1.Lines.Add(Prop.ToString);
Cont.Free;
I get list of all properties of TStrings except indexed properties (Strings, Values, ...).
As I can see in Get[Declared]Properties are never indexed properties. How can I get indexed proper...
Hi
With RttiContext.FindType('Classes.TStringList') I get RttiType of TStringList with no problem. But with RttiContext.FindType('MyUnit.TMyClass') I always get nil (of course MyUnit is in uses clause). Why, what is wrong?
Example:
unit MyUnit;
interface
uses
Classes;
type
TMyClass = class(TStringList)
end;
implementation...
Here is my problem:
I have two C++ modules, A and B, which are built as dynamically-linked libraries. A offers basic math functions, and custom exception types. B is a higher level module that uses A.
B::someFunction() calls a function from A, and tries to catch custom exception A:MyExceptionFromA in order to convert it into a custom t...
Hello,
I need a way to get a pointer to the start of an object in C++. This object is used inside a template so it can be any type (polymorphic or not) and could potentially be an object that uses multiple inheritance.
I found this article which describes a way to do it (see the section called "Dynamic Casts") using typeid and a dynami...
Hi, I need to find the type of object pointed by pointer.
Code is as below.
//pWindow is pointer to either base Window object or derived Window objects like //Window_Derived.
const char* windowName = typeid(*pWindow).name();
if(strcmp(windowName, typeid(Window).name()) == 0)
{
// ...
}
else if(strcmp(windowName, typeid(Window_Derived...
Hello everyone :)
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<std::type_info, boost::any>. Unfortunately, std::type_info does not define an operator<, and I think it'd be unreasonable for it to define one.
How...
I have a problem with the properties of IInterface type.
I don't know how to assign values to these properties using RTTI
Here's an example:.
program Project2;
uses
Forms, RTTI, Windows, TypInfo;
{$R *.res}
type
ITestInterfacedClass = interface
['{25A5B554-667E-4FE4-B932-A5B8D9052A17}']
function GetA: ITestInterfacedClass...
Hi,
I'm building a shared library with f-no-rtti. Internally, this library throws std:invalid_argument and catches std::exception, but the catch clause is never entered.
The following code reproduces the problem (g++ 4.2, Mac OS X 10.6):
// library.cpp: exports f(), compiled with -fno-rtti
#include <stdexcept>
#include <iostream>
exte...
I want to record the std::type_info of a variable so that on load I will be able to re-create the appropriate type variable.
Saving will look like this:
friend class boost::serialization::access;
template<class Archive>
void save(Archive & ar, const unsigned int version) const
{
...
ar & BOOST_SERIALIZATION_NVP(typeid(value)); ...
Is there a way to explore a interface's properties with Rtti?
The following code does not work:
procedure ExploreProps;
var
Ctx: TRttiContext;
RttiType: TRttiType;
RttiProp: TRttiProp;
begin
RttiType := Ctx.GetType(TypeInfo(IMyInterface));
for RttiProp in RttiType.GetProperties do
Writeln(RttiProp.ToString);
end;
Has an...