System.Variants.TCustomVariantType.Cast

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure Cast(var Dest: TVarData; const Source: TVarData); virtual;

C++

virtual void __fastcall Cast(TVarData &Dest, const TVarData &Source);

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.Variants.pas
System.Variants.hpp
System.Variants TCustomVariantType

Description

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

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.

See Also