RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomVariantType.Cast Method

Converts the data from another System::Variant type so that it represents this custom type's data format.

Pascal
procedure Cast(var Dest: TVarData; const Source: TVarData); virtual;
C++
virtual __fastcall Cast(TVarData Dest, const TVarData Source);

Override Cast to enable other types of Variants to be cast to this custom System::Variant type. 

Dest is a TVarData record that returns the System::Variant's data stored in the format used by this custom System::Variant type. The Cast method fills out this record from the information in Source. 

Source is a TVarData record that contains the data from another System::Variant type. Check the VType field of Source to identify how it currently stores its data. Then use the other fields to fetch the data and convert it to the format used by this System::Variant type. 

As implemented in TCustomVariantType, Cast checks whether Source is another custom System::Variant type. If so, it calls its CastTo method, to convert it to this System::Variant type. If not, it raises a system error indicating an invalid cast. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!