RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomVariantType.Cast Method

Converts the data from another 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 Variant type. 

Dest is a TVarData record that returns the Variant's data stored in the format used by this custom 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 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 Variant type. 

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

 

castto 

VarDataCast 

Enabling Casting

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!