Usage Examples

Schema compiler tool

Synopsis

rdm-compile [OPTION]… dbname.sdl

Description

rdm-compile is a command-line utility that compiles a database definition into a platform-agnostic binary catalog file. It can optionally generate C and C++ source and header files that can be included in an application. The generated files will always be written to the current working directory even if the input file was specified with a path. This behavior makes it possible to use the tool in an out-of-source build environment.

Using file names or literals with embedded spaces, special characters, or something that can conflict with C/C++ reserved words or content in system header files may result in generated files that will fail to compile on one or more platforms.

Options

-h, --help Display this usage information
--version Display the version information
-q, --quiet Quiet mode. No information will be displayed
-x, --cpp-api Generate C++ API files
-X, --cpp Generate C++ files
--include-prefix=path Prefix for RDM include directory. This option only affects the generated source/header filies when '--cpp-api' is specified.
--include-path=path Full path location of the RDM include directory. This option only affects the generated doxygen file when '--cpp-api' is specified.
--lc-cpp-methods Use lower case for part of C++ method names derived from the schema
-a, --catalog Generate internal catalog C/H files
-s, --c-structs Generate database header file. This file is not necessary if an application only uses SQL to access the database.
--lc-struct-members Use lower case for struct members in the generated C-struct file
--uc-struct-members Use upper case for struct members in the generated C-struct file
--mc-enums Match the case of enumerations with that of the table, column, key and reference names used in the DDL file (See Match-Case Enumerations below).
--namespace=namespace Prefix 'namespace' to dbname for all generated files
--key-ex Generate EX classes with constructors for key structs
dbname.sdl Name of SQL DDL Script file

The dbname is used as a part of the generated files names for C/C++ files. You should avoid using characters that may be invalid for these file names when naming the dbname.sdl file.

Usage Examples

The usage examples assume that bookshop.sdl contains the following table definition:

CREATE TABLE author (
    last_name CHAR(13) PRIMARY KEY,
    full_name CHAR(25),
    gender CHAR(1),
    yr_born SMALLINT,
    yr_died SMALLINT,
    short_bio VARCHAR(216),
    KEY yob_gender_key(yr_born, gender)
);

Compiling an RDM database catalog

You can run rdm-compile to compile a database definition file into an RDM database catalog file.

$ rdm-compile bookshop.sdl

An RDM database catalog file named bookshop.cat will be created as the result.

Generating source and header files

A number of command-line options are provided with rdm-compile to generate source and header files that can be included or embedded in an application.

$ rdm-compile --c-structs --catalog bookshop.sdl

The header file, bookshop_structs.h, will contain the structure definition of the database. The catalog source header files, bookshop_cat.c and bookshop_cat.h, will contain the text definition of the database catalog and its entry point.

Comments

Database Header File (--c-structs)

The --c-structs option generates C structures and enumerators for communicating with the C/C++ API. By default, the unquoted identifiers generated from the schema definition will be forced to uppercase. Quoted identifiers will maintain case in the generated structure members. Refer to the Identifiers section for more detail about identifiers.

The --lc-struct-members option will change the default of the unquoted member identifiers to lowercase. Likewise, the --uc-struct-members option will force the unquoted identifiers to be uppercase (which is the default behavior).

The associated enumerators will be uppercase unless the following --mc-enums is used.

Match-Case Enum Option (--mc-enums)

Enabling the "--mc-enums" option generates table, column, key and reference enumerations in the case that matches that of the corresponding tables, columns, keys and references. For instance, a table declared as follows:

CREATE TABLE SignalControl ( ... );

will have the following enumerations:

TABLE_SIGNALCONTROL

It may look incorrect as SignalControl is not uppercase. Keep in mind that RDM treats identifiers as uppercase by default. Therefore, the name of the signalcontrol table is internally converted to SIGNALCONTROL. The corresponding enumeration will match that.

In order to use lowercase letters in an identifier, you will need to use quoted identifiers, which are identifiers enclosed in double quotation marks. Unlike (non-quoted) identifiers, RDM treats the quoted identifiers as is. For instance:

CREATE TABLE "SignalControl"

will generate the following enumeration with --mc-enums.

TABLE_SignalControl