System.TypInfo.TPublishableVariantType

From RAD Studio API Documentation
Jump to: navigation, search

System.Variants.TInvokeableVariantTypeSystem.Variants.TCustomVariantTypeSystem.TObjectTPublishableVariantType

Delphi

TPublishableVariantType = class(TInvokeableVariantType, IVarInstanceReference)

C++

class PASCALIMPLEMENTATION TPublishableVariantType : public System::Variants::TInvokeableVariantType

Properties

Type Visibility Source Unit Parent
class public
System.TypInfo.pas
System.TypInfo.hpp
System.TypInfo System.TypInfo

Description

TPublishableVariantType is the base class for custom Variant types that surface the published properties of an object that represents the Variant's data.

TPublishableVariantType is the base class for new data types for Variants that have properties and methods. TPublishableVariantType descendants do not represent the Variants themselves. Rather, they act as utility classes that the custom Variants call on to perform their operations. TPublishableVariantType adds to its ancestor's ability to implement properties and methods on Variants of the custom type by automatically implementing all published properties of the object it uses to store its data.

Note: To create a Variant type that descends from TPublishableVariantType,

Note: 1. Map the storage of the Variant's data on to the TVarData record.

Note: 2. Write a method that creates instances of your custom Variant. This fills in the Variant's data as defined in step 1.

Note: 3. Declare a class that descends from TPublishableVariantType.

Note: 4. Override the GetInstance method to return the object that stores the custom Variant's data.

Note: 5. Implement all other required behavior (including type conversion rules) in the new class. This involves overriding the appropriate virtual methods (typically DoFunction, DoProcedure, BinaryOp, UnaryOp, CompareOp or Compare, Cast, CastTo, Clear, Copy, IsClear, LeftPromotion, and RightPromotion).

Note: 6. In the initialization section of the unit that defines your TPublishableVariantType descendant, create an instance of your class. When you instantiate your object, it automatically registers itself with the Variant-handling system so that the new Variant type is enabled.

Note: 7. In the finalization section of the unit that defines your TPublishableVariantType descendant, free the instance of your class. This automatically unregisters the Variant type.

Note: For an example, see the VarCmplx (Windows) or FMTBcd (Linux) unit, which implements a custom Variant type for complex (Windows) or binary-coded decimal (Linux) numbers.

Note: Do not create your own custom Variant types in C++. They are only supported in Delphi.

See Also