C++ Schema Definition

As described in the Users_Guide page, the database schema consists of a set of classes (tables) containing fields (columns) and indexes that implement the application's information model . For C++ applications, the schema is defined, and the generated header and implementation files are incorporated into the project, exactly as for C applications. (Please see the C Schema Definition page for further details).

However, additional C++ class implementation can be generated by the schema compiler and the class implementation can be optionally incorporated into the C++ application.

Compiling the schema

As explained for C applications, the schema file is compiled by the mcocomp utility found in the eXtremeDB/host/bin directory of the eXtremeDB installation. To generate additional C++ class implementation, the -hpp,-c++ and -smartptr options can be specified when calling mcocomp. When either-hppor -c++ are specified an additional <database_name>.hpp file will be generated containing the class implementations. The -smartptr option causes mcocomp to generate code that makes database fields appear effectively as class properties. This allows applications to access object fields in a С++ fashion, using setters and getters, as opposed to using theC API _put() and _get() functions.

For example, instead of:

 
    anObject.aField_get(&value));
    anObject.aField_put(1));
     

Using a smart pointer this can be written as:

 
    value = anObject.aField;
    anObject.aField = 1;
     

Note that the generated .h and .c files, and optionally the .hpp file, must be included also in eXtremeSQL applications - even if all access to the eXtremeDB database will be through SQL only.