Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK 10.1.3
Developing Drivers for Data Stores Without SQL

SimbaEngine X SDK Documentation > SQL Data Types > ODBC Custom C Data Types

ODBC Custom C Data Types

Using the C++ SimbaEngine X SDK, you can add custom C data types to your DSII. Each custom data type that you add must be based on an existing data type. This allows applications to handle your custom types transparently without requiring additional logic.

This functionality is available to drivers that use the SQL Engine, and to those that do not.

SimbaEngine X SDK uses a UtilityFactory class to create a SqlCTypeMetadataFactory object to create the metadata about the custom types, then use and a SqlConverterFactory to convert the custom type to other data types.

To Add Custom C Data Types:

  1. Create a header file to package with your ODBC driver. In this header file, define the type ID for your custom C type, field ID’s for any custom metadata fields, and the struct of your custom C data type. Note that field ID’s must start at 0x4100.
  2. Modify your CustomerDSIIDriver object to override and implement the virtual method CreateUtilityFactory() to return a CustomerDSIIUtilityFactoryClass . This class will provide the other factories that implement custom data type behavior.
  3. Create a CustomerDSIIUtilityFactory class that subclasses Simba::Support::UtilityFactory . This factory class will provide classes that handle the custom type metadata, data, and conversion of the custom data types.
    1. CreateSqlConverterFactory() creates a factory to create converters that convert custom data types to other types.
    2. CreateSqlCDataTypeUtilities() creates a utility class which describes the custom C data types.
    3. CreateSqlCTypeMetadataFactory() creates a factory to create the metadata about the custom data types.
  4. Create a CustomerDSIISqlConverterFactory class which subclasses Simba::Support::SqlConverterFactory , and override and implement the following virtual methods:
    1. CanConvertCustomCTypeToSql() takes the ID of a custom C data type and the TDWType enum of the target SQL type to convert to, and determines if the type conversion can be performed.
    2. CanConvertSqlToCustomCType() takes the TDWType enum of a SQL data type and the ID of a custom C data type to convert to, and determines if the type conversion can be performed.
    3. CreateNewCustomSqlToCConverter() takes a SqlData and SqlCData object representing the source and target types, and an IWarningListener for posting any conversion warnings to. The returned converter is responsible for converting from the source SQL data type to the target C data type.
    4. CreateNewCustomCToSqlConverter() takes a SqlCData and SqlData object representing the source and target types, and an IWarningListener for posting any conversion warnings to. The returned converter is responsible for converting from the source C data type to the target SQL data type.
  5. Create a CustomerDSIISqlCDataTypeUtilities class which subclasses SqlCDataTypeUtilities , and override and implement the following two methods:
    1. IsSupportedCustomType() takes in the ID of a type and determines if it is a valid custom C data type.
    2. GetStringForCType() takes is in the ID of a C data type and returns the string representation of it.

    Optionally override the following two methods if the custom C data type will support custom metadata fields:

    1. IsSupportedCustomMetadataField() takes in the ID of a field identifier, along with the field’s indent and determines if the field identifier and indent are valid.
    2. GetCustomMetadataFieldType() takes in the field indent and returns the data type that it represents.

    Note:

    When you override a function, your custom function should defer to the implementation of the parent class when the ID of a non-custom type is passed in. That is, your custom function should only handle your custom types.

  6. Create a CustomerDSIISqlCTypeMetadataFactory class which subclasses Simba::Support::SqlCTypeMetadataFactory , and override and implement the following virtual methods:
    1. CreateNewCustomSqlCTypeMetadata() creates a new SqlCTypeMetadata object that represents the custom C data type specified.
    2. ResetCustomTypeDefaults() sets the default values for the custom C data type.

    Optionally create CustomerSqlCTypeMetadata which subclasses SqlCTypeMetadata if custom metadata fields are required for the custom C data type. This object will then be constructed and returned by the CreateNewCustomSqlCTypeMetadata() method.

    In CustomerSqlCTypeMetadata , the SetField()/GetField() methods must be overridden if there are custom metadata fields to set/get.