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 -hpp or -c++ is 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 C++ fashion, using setters and getters, as opposed to using the C 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 also be included in eXtremeSQL applications—even if all access to the eXtremeDB database will be through SQL only.