13.18 Map Class

The Map class is used to store the mapping of the SQL structured type to C++ classes.

For each user defined type, the Object Type Translator (OTT) generates a C++ class declaration and implements the static methods readSQL() and writeSQL(). The readSQL() method is called when the object from the server appears in the application as a C++ class instance. The writeSQL() method is called to marshal the object in the application cache to server data when it is being written / flushed to the server. The readSQL() and writeSQL() methods generated by OTT are based upon the OCCI standard C++ mappings.

If you want to override the standard OTT generated mappings with customized mappings, you must implement a custom C++ class along with the readSQL() and writeSQL() methods for each SQL structured type you must customize. In addition, you must add an entry for each such class into the Map member of the Environment.

Table 13-24 Summary of Map Methods

Method Summary

put()

Adds a map entry for the type type_name.

13.18.1 put()

Adds a map entry for the type, type_name, that must be customized; you must implement the type_name C++ class.

You must then add this information into a map object, which should be registered with the connection if the user wants the standard mappings to overridden.This registration can be done by calling the this method after the environment is created passing the environment.

Syntax Description
void put(
   const string &schemaType,
   void *(*rSQL)(void *),
   void (*wSQL) (void *, void *));

Registers a type and its corresponding C++ readSQL and writeSQL functions.

void put(
   const string& schName,
   const string& typName,
   void *(*rSQL)(void *),
   void (*wSQL)(void *, void *));

Registers a type and its corresponding C++ readSQL and writeSQL functions; multibyte support.

void put(
   const UString& schName,
   const UString& typName,
   void *(*rSQL)(void *),
   void (*wSQL)(void *, void *));

Registers a type and its corresponding C++ readSQL and writeSQL functions; unicode support.

Parameter Description
schemaType

The schema and typename, separated by ".", like HR.TYPE1

schName

Name of the schema

typName

Name of the type

rDQL

The readSQL function pointer of the C++ class that corresponds to the type

wSQL

The writeSQL function pointer of the C++ class that corresponds to the type