From RAD Studio API Documentation
Jump to: navigation, search



TConverter<TSerial> = class abstract


template<typename TSerial> class PASCALIMPLEMENTATION TConverter__1 : public System::TObject


Type Visibility Source Unit Parent
class public
Data.DBXJSONReflect Data.DBXJSONReflect


Represents the base converter class.

Any serializer needs to inherit from the TConverter class. TConverter provides the API events used by a marshaller class to serialize a user object.

Converters and reverters can be registered against a type and a field, or for a type. Any field declared of that type is processed by the provided user converter/reverter. A field registered converter/reverter takes precedence in front of a type converter/reverter.

A field converter can transform a field value into a string, an object, a list of strings, or a list of objects. The contract is that those transformed values will be passed as arguments to the correspondent reverter to reconstitute the field value.

A type converter can transform a value into a string, an object, a list of strings, or a list of objects. These will be passed as arguments to the type reverter that will reconstitute the original type instance.

For example, a TStringList field can be converted into an array of strings by a converter, and a reverter can use the list of strings to create and populate an instance of TStringList. This is the degree of complexity expected by a user-defined converter/reverter.

On predetermined situations, events are emitted. The following table contains the list of situations that can occur during marshalling.

Situation Event

A new object is encountered.


An already visited object is encountered.


A new object content was revisited.


A new field is encountered.


A new field is visited.


A string value is encountered.


A numeric value is encountered.


A nil value is encountered.


A Boolean value is encountered.


A list value is encountered.


A list is finished processing.


The events are received by a TConverter instance. They are imbricated, depending on the structure of the user object. Based on the events ant their arguments, the TConverter instance builds an equivalent image of the user object.

The object image built by the converter can be used to reconstitute the original user object, using reverter events driven by an unmarshaller.

Note: These are the fields for which there is already a built-in conversion/reversion: integer, string, char, enumeration, float, object. For the following types, the field values are ignored and user conversion is expected: set, method, variant, interface, pointer, dynArray, classRef, array.

See Also