I need to get the type of a TValue
.
TControl *control = MyForm->Controls[1337];
TRttiContext ctx;
TRttiType *type = ctx.GetType(control->ClassInfo());
TRttiProperty *property = type->GetProperty("Text"); // or "Caption", etc.
TValue result = property->GetValue(control);
if (result.IsType(tkUString)) {
std::cout << "String!" << std::endl;
else
std::cout << "NOT String!" << std::endl;
I get the following error:
[bcc64 Error] Unit1.cpp(142): no matching member function for call to 'IsType'
System.Rtti.hpp(323): candidate function not viable: no known conversion from 'System::TTypeKind' to 'System::Typinfo::PTypeInfo' (aka 'System::Typinfo::TTypeInfo *') for 1st argument
Looking at the documentation IsType()
takes a PTypeInfo
argument (which tkUString
is not).
But there is no C++ documentation on PTypeInfo
, only Delphi.
Must I include a Delphi unit in my project to use TValue.IsType()
?
I was using the wrong method.
This is wrong:
if (result.IsType(tkUString)) {
This is correct:
if (result.Kind == tkUString) {