dynamic runtime casting?



Is there a C++ method comparable to the vb.net TryCast function? I
had hopes for Convert::ChangeType, but that didn't work.

For a scripting engine, the user is specifying to retrieve an
interface on an object by name. Code is roughly:

array<Type^> ^l_pInterfaces = l_pType->GetInterfaces();
for(int m=0; m < l_pInterfaces->Length; m++)
{
Type^ l_pInterface = l_pInterfaces[m];
System::String ^ l_pInterfaceName = l_pInterface->Name;
if (l_pPropString->Equals(l_pInterfaceName)
break;
l_pInterface = nullptr;
}
if (l_pInterface)
return intern(Convert::ChangeType(l_pObject,l_pInterface));

Larry
.



Relevant Pages

  • Re: dynamic runtime casting?
    ... For a scripting engine, the user is specifying to retrieve an ... interface on an object by name. ...
    (microsoft.public.dotnet.languages.vc)
  • Hiding methodsproperties from scripting engine
    ... I have "dual" interface but I want within scripting engine only some of the ... something I can do in IDL? ... Rossen Tzonev ...
    (microsoft.public.vc.atl)
  • Re: dynamic runtime casting?
    ... If the type to cast to is only known at runtime you can use: ... For a scripting engine, the user is specifying to retrieve an ... l_pInterface = nullptr; ... Vladimir Nesterovsky ...
    (microsoft.public.dotnet.languages.vc)

Loading