--help Print usage information and exit.
--version
Print version and exit.
-Idir Add dir to the beginning of the list of directories to be searched for included header files.
-Dname[=def]
Define macro name with definition def. If definition is omitted, define name to be 1.
-Uname
Cancel any previous definitions of macro name, either built-in or provided with the -D option.
--database|-ddb
Generate code for the db database. Valid values are mssql, mysql, oracle, pgsql, sqlite, and
common (multi-database mode only).
--multi-database|-mtype
Enable multi-database support and specify its type. Valid values for this option are static and
dynamic.
In the multi-database mode, options that determine the kind (for example, --schema-format), names
(for example, --odb-file-suffix), or content (for example, prologue and epilogue options) of the
output files can be prefixed with the database name followed by a colon, for example, mysql:value.
This restricts the value of such an option to only apply to generated files corresponding to this
database.
--default-databasedb
When static multi-database support is used, specify the database that should be made the default.
When dynamic multi-database support is used, common is always made the default database.
--generate-query|-q
Generate query support code. Without this support you cannot use views and can only load objects
via their ids.
--generate-prepared
Generate prepared query execution support code.
--omit-unprepared
Omit un-prepared (once-off) query execution support code.
--generate-session|-e
Generate session support code. With this option session support will be enabled by default for all
the persistent classes except those for which it was explicitly disabled using the dbsession
pragma.
--generate-schema|-s
Generate the database schema. The database schema contains SQL statements that create database
tables necessary to store persistent classes defined in the file being compiled. Note that by
applying this schema, all the existing information stored in such tables will be lost.
Depending on the database being used (--database option), the schema is generated either as a
standalone SQL file or embedded into the generated C++ code. By default the SQL file is generated
for the MySQL, PostgreSQL, Oracle, and Microsoft SQL Server databases and the schema is embedded
into the C++ code for the SQLite database. Use the --schema-format option to alter the default
schema format.
If database schema evolution support is enabled (that is, the object model version is specified),
then this option also triggers the generation of database schema migration statements, again
either as standalong SQL files or embedded into the generated C++ code. You can suppress the
generation of schema migration statements by specifying the --suppress-migration option.
--generate-schema-only
Generate only the database schema. Note that this option is only valid when generating schema as a
standalone SQL file (see --schema-format for details).
--suppress-migration
Suppress the generation of database schema migration statements.
--suppress-schema-version
Suppress the generation of schema version table. If you specify this option then you are also
expected to manually specify the database schema version and migration state at runtime using the
odb::database::schema_version() function.
--schema-version-tablename
Specify the alternative schema version table name instead of the default schema_version. If you
specify this option then you are also expected to manually specify the schema version table name
at runtime using the odb::database::schema_version_table() function. The table name can be
qualified.
--schema-formatformat
Generate the database schema in the specified format. Pass sql as format to generate the database
schema as a standalone SQL file or pass embedded to embed the schema into the generated C++ code.
The separate value is similar to embedded except the schema creation code is generated into a
separate C++ file (name-schema.cxx by default). This value is primarily useful if you want to
place the schema creation functionality into a separate program or library. Repeat this option to
generate the same database schema in multiple formats.
--omit-drop
Omit DROP statements from the generated database schema.
--omit-create
Omit CREATE statements from the generated database schema.
--schema-namename
Use name as the database schema name. Schema names are primarily used to distinguish between
multiple embedded schemas in the schema catalog. They are not to be confused with database
schemas (database namespaces) which are specified with the --schema option. If this option is not
specified, the empty name, which is the default schema name, is used.
--fkeys-deferrable-modem
Use constraint checking mode m in foreign keys generated for object relationships. Valid values
for this option are not_deferrable, immediate, and deferred (default). MySQL and SQL Server do not
support deferrable foreign keys and for these databases such keys are generated commented out.
Other foreign keys generated by the ODB compiler (such as the ones used to support containers and
polymorphic hierarchies) are always generated as not deferrable.
Note also that if you use either not_deferrable or immediate mode, then the order in which you
persist, update, and erase objects within a transaction becomes important.
--default-pointerptr
Use ptr as the default pointer for persistent objects and views. Objects and views that do not
have a pointer assigned with the dbpointer pragma will use this pointer by default. The value of
this option can be * which denotes the raw pointer and is the default, or qualified name of a
smart pointer class template, for example, std::auto_ptr. In the latter case, the ODB compiler
constructs the object or view pointer by adding a single template argument of the object or view
type to the qualified name, for example std::auto_ptr<object>. The ODB runtime uses object and
view pointers to return, and, in case of objects, pass and cache dynamically allocated instances
of object and view types.
Except for the raw pointer and the standard smart pointers defined in the <memory> header file,
you are expected to include the definition of the default pointer at the beginning of the
generated header file. There are two common ways to achieve this: you can either include the
necessary header in the file being compiled or you can use the --hxx-prologue option to add the
necessary #include directive to the generated code.
--session-typetype
Use type as the alternative session type instead of the default odb::session. This option can be
used to specify a custom session implementation to be use by the persistent classes. Note that you
will also need to include the definition of the custom session type into the generated header
file. This is normally achieved with the --hxx-prologue* options.
--profile|-pname
Specify a profile that should be used during compilation. A profile is an options file. The ODB
compiler first looks for a database-specific version with the name constructed by appending the
-database.options suffix to name, where database is the database name as specified with the
--database option. If this file is not found, then the ODB compiler looks for a database-
independant version with the name constructed by appending just the .options suffix.
The profile options files are searched for in the same set of directories as C++ headers included
with the #include<...> directive (built-in paths plus those specified with the -I options). The
options file is first searched for in the directory itself and then in its odb/ subdirectory.
For the format of the options file refer to the --options-file option below. You can repeat this
option to specify more than one profile.
--at-once
Generate code for all the input files as well as for all the files that they include at once. The
result is a single set of source/schema files that contain all the generated code. If more than
one input file is specified together with this option, then the --input-name option must also be
specified in order to provide the base name for the output files. In this case, the directory part
of such a base name is used as the location of the combined file. This can be important for the
#include directive resolution.
--schemaschema
Specify a database schema (database namespace) that should be assigned to the persistent classes
in the file being compiled. Database schemas are not to be confused with database schema names
(schema catalog names) which are specified with the --schema-name option.
--export-symbolsymbol
Insert symbol in places where DLL export/import control statements
(__declspec(dllexport/dllimport)) are necessary. See also the --extern-symbol option below.
--extern-symbolsymbol
If symbol is defined, insert it in places where a template instantiation must be declared extern.
This option is normally used together with --export-symbol when both multi-database support and
queries are enabled.
--stdversion
Specify the C++ standard that should be used during compilation. Valid values are c++98 (default),
c++11, and c++14.
--warn-hard-add
Warn about hard-added data members.
--warn-hard-delete
Warn about hard-deleted data members and persistent classes.
--warn-hard
Warn about both hard-added and hard-deleted data members and persistent classes.
--output-dir|-odir
Write the generated files to dir instead of the current directory.
--input-namename
Use name instead of the input file to derive the names of the generated files. If the --at-once
option is specified, then the directory part of name is used as the location of the combined file.
Refer to the --at-once option for details.
--changelogfile
Read/write changelog from/to file instead of the default changelog file. The default changelog
file name is derived from the input file name and it is placed into the same directory as the
input file. Note that the --output-dir option does not affect the changelog file location. In
other words, by default, the changelog file is treated as another input rather than output even
though the ODB compiler may modify it. Use the --changelog-in and --changelog-out options to
specify different input and output chaneglog files.
--changelog-infile
Read changelog from file instead of the default changelog file. If this option is specified, then
you must also specify the output chanegelog file with --changelog-out.
--changelog-outfile
Write changelog to file instead of the default changelog file. If this option is specified, then
you must also specify the input chanegelog file with --changelog-in.
--changelog-dirdir
Use dir instead of the input file directory as the changelog file directory. This directory is
also added to changelog files specified with the --changelog, --changelog-in, and --changelog-in
options unless they are absolute paths.
--init-changelog
Force re-initialization of the changelog even if one exists (all the existing change history will
be lost). This option is primarily useful for automated testing.
--odb-file-suffixsuffix
Use suffix to construct the names of the generated C++ files. In the single-database mode the
default value for this option is -odb. In the multi-database mode it is -odb for the files
corresponding to the common database and -odb-db (where db is the database name) for other
databases.
--sql-file-suffixsuffix
Use suffix to construct the name of the generated schema SQL file. In the single-database mode by
default no suffix is used. In the multi-database mode the default value for this option is -db
(where db is the database name).
--schema-file-suffixsuffix
Use suffix to construct the name of the generated schema C++ source file. In the single-database
mode the default value for this option is -schema. In the multi-database mode it is -schema-db
(where db is the database name). See the --schema-format option for details.
--changelog-file-suffixsfx
Use sfx to construct the name of the changelog file. In the single-database mode by default no
suffix is used. In the multi-database mode the default value for this option is -db (where db is
the database name).
--hxx-suffixsuffix
Use suffix instead of the default .hxx to construct the name of the generated C++ header file.
--ixx-suffixsuffix
Use suffix instead of the default .ixx to construct the name of the generated C++ inline file.
--cxx-suffixsuffix
Use suffix instead of the default .cxx to construct the name of the generated C++ source file.
--sql-suffixsuffix
Use suffix instead of the default .sql to construct the name of the generated database schema
file.
--changelog-suffixsuffix
Use suffix instead of the default .xml to construct the name of the changelog file.
--hxx-prologuetext
Insert text at the beginning of the generated C++ header file.
--ixx-prologuetext
Insert text at the beginning of the generated C++ inline file.
--cxx-prologuetext
Insert text at the beginning of the generated C++ source file.
--schema-prologuetext
Insert text at the beginning of the generated schema C++ source file.
--sql-prologuetext
Insert text at the beginning of the generated database schema file.
--migration-prologuetext
Insert text at the beginning of the generated database migration file.
--sql-interludetext
Insert text after all the DROP and before any CREATE statements in the generated database schema
file.
--hxx-epiloguetext
Insert text at the end of the generated C++ header file.
--ixx-epiloguetext
Insert text at the end of the generated C++ inline file.
--cxx-epiloguetext
Insert text at the end of the generated C++ source file.
--schema-epiloguetext
Insert text at the end of the generated schema C++ source file.
--sql-epiloguetext
Insert text at the end of the generated database schema file.
--migration-epiloguetext
Insert text at the end of the generated database migration file.
--hxx-prologue-filefile
Insert the content of file at the beginning of the generated C++ header file.
--ixx-prologue-filefile
Insert the content of file at the beginning of the generated C++ inline file.
--cxx-prologue-filefile
Insert the content of file at the beginning of the generated C++ source file.
--schema-prologue-filefile
Insert the content of file at the beginning of the generated schema C++ source file.
--sql-prologue-filefile
Insert the content of file at the beginning of the generated database schema file.
--migration-prologue-filef
Insert the content of file f at the beginning of the generated database migration file.
--sql-interlude-filefile
Insert the content of file after all the DROP and before any CREATE statements in the generated
database schema file.
--hxx-epilogue-filefile
Insert the content of file at the end of the generated C++ header file.
--ixx-epilogue-filefile
Insert the content of file at the end of the generated C++ inline file.
--cxx-epilogue-filefile
Insert the content of file at the end of the generated C++ source file.
--schema-epilogue-filefile
Insert the content of file at the end of the generated schema C++ source file.
--sql-epilogue-filefile
Insert the content of file at the end of the generated database schema file.
--migration-epilogue-filef
Insert the content of file f at the end of the generated database migration file.
--odb-prologuetext
Compile text before the input header file. This option allows you to add additional declarations,
such as custom traits specializations, to the ODB compilation process.
--odb-prologue-filefile
Compile file contents before the input header file. Prologue files are compiled after all the
prologue text fragments (--odb-prologue option).
--odb-epiloguetext
Compile text after the input header file. This option allows you to add additional declarations,
such as custom traits specializations, to the ODB compilation process.
--odb-epilogue-filefile
Compile file contents after the input header file. Epilogue files are compiled after all the
epilogue text fragments (--odb-epilogue option).
--table-prefixprefix
Add prefix to table names and, for databases that have global index and/or foreign key names, to
those names as well. The prefix is added to both names that were specified with the dbtable and
dbindex pragmas and those that were automatically derived from class and data member names. If
you require a separator, such as an underscore, between the prefix and the name, then you should
include it into the prefix value.
--index-suffixsuffix
Use suffix instead of the default _i to construct index names. The suffix is only added to names
that were automatically derived from data member names. If you require a separator, such as an
underscore, between the name and the suffix, then you should include it into the suffix value.
--fkey-suffixsuffix
Use suffix instead of the default _fk to construct foreign key names. If you require a separator,
such as an underscore, between the name and the suffix, then you should include it into the suffix
value.
--sequence-suffixsuffix
Use suffix instead of the default _seq to construct sequence names. If you require a separator,
such as an underscore, between the name and the suffix, then you should include it into the suffix
value.
--sql-name-casecase
Convert all automatically-derived SQL names to upper or lower case. Valid values for this option
are upper and lower.
--table-regexregex
Add regex to the list of regular expressions that is used to transform automatically-derived table
names. See the SQL NAME TRANSFORMATIONS section below for details.
--column-regexregex
Add regex to the list of regular expressions that is used to transform automatically-derived
column names. See the SQL NAME TRANSFORMATIONS section below for details.
--index-regexregex
Add regex to the list of regular expressions that is used to transform automatically-derived index
names. See the SQL NAME TRANSFORMATIONS section below for details.
--fkey-regexregex
Add regex to the list of regular expressions that is used to transform automatically-derived
foreign key names. See the SQL NAME TRANSFORMATIONS section below for details.
--sequence-regexregex
Add regex to the list of regular expressions that is used to transform automatically-derived
sequence names. See the SQL NAME TRANSFORMATIONS section below for details.
--statement-regexregex
Add regex to the list of regular expressions that is used to transform automatically-derived
prepared statement names. See the SQL NAME TRANSFORMATIONS section below for details.
--sql-name-regexregex
Add regex to the list of regular expressions that is used to transform all automatically-derived
SQL names. See the SQL NAME TRANSFORMATIONS section below for details.
--sql-name-regex-trace
Trace the process of applying regular expressions specified with the SQL name --*-regex options.
Use this option to find out why your regular expressions don't do what you expected them to do.
--accessor-regexregex
Add regex to the list of regular expressions used to transform data member names to function names
when searching for a suitable accessor function. The argument to this option is a Perl-like
regular expression in the form /pattern/replacement/. Any character can be used as a delimiter
instead of / and the delimiter can be escaped inside pattern and replacement with a backslash (\).
You can specify multiple regular expressions by repeating this option.
All the regular expressions are tried in the order specified and the first expression that
produces a suitable accessor function is used. Each expression is tried twice: first with the
actual member name and then with the member's publicname which is obtained by removing the common
member name decorations, such as leading and trailing underscores, the m_ prefix, etc. The ODB
compiler also includes a number of built-in expressions for commonly used accessor names, such as
get_foo, getFoo, getfoo, and just foo. The built-in expressions are tried last.
As an example, the following expression transforms data members with public names in the form foo
to accessor names in the form GetFoo:
/(.+)/Get\u$1/
See also the REGEX AND SHELL QUOTING section below.
--accessor-regex-trace
Trace the process of applying regular expressions specified with the --accessor-regex option. Use
this option to find out why your regular expressions don't do what you expected them to do.
--modifier-regexregex
Add regex to the list of regular expressions used to transform data member names to function names
when searching for a suitable modifier function. The argument to this option is a Perl-like
regular expression in the form /pattern/replacement/. Any character can be used as a delimiter
instead of / and the delimiter can be escaped inside pattern and replacement with a backslash (\).
You can specify multiple regular expressions by repeating this option.
All the regular expressions are tried in the order specified and the first expression that
produces a suitable modifier function is used. Each expression is tried twice: first with the
actual member name and then with the member's publicname which is obtained by removing the common
member name decorations, such as leading and trailing underscores, the m_ prefix, etc. The ODB
compiler also includes a number of built-in expressions for commonly used modifier names, such as
set_foo, setFoo, setfoo, and just foo. The built-in expressions are tried last.
As an example, the following expression transforms data members with public names in the form foo
to modifier names in the form SetFoo:
/(.+)/Set\u$1/
See also the REGEX AND SHELL QUOTING section below.
--modifier-regex-trace
Trace the process of applying regular expressions specified with the --modifier-regex option. Use
this option to find out why your regular expressions don't do what you expected them to do.
--include-with-brackets
Use angle brackets (<>) instead of quotes ("") in the generated #include directives.
--include-prefixprefix
Add prefix to the generated #include directive paths.
--include-regexregex
Add regex to the list of regular expressions used to transform generated #include directive paths.
The argument to this option is a Perl-like regular expression in the form /pattern/replacement/.
Any character can be used as a delimiter instead of / and the delimiter can be escaped inside
pattern and replacement with a backslash (\). You can specify multiple regular expressions by
repeating this option. All the regular expressions are tried in the order specified and the first
expression that matches is used.
As an example, the following expression transforms include paths in the form foo/bar-odb.h to
paths in the form foo/generated/bar-odb.h:
%foo/(.+)-odb.h%foo/generated/$1-odb.h%
See also the REGEX AND SHELL QUOTING section below.
--include-regex-trace
Trace the process of applying regular expressions specified with the --include-regex option. Use
this option to find out why your regular expressions don't do what you expected them to do.
--guard-prefixprefix
Add prefix to the generated header inclusion guards. The prefix is transformed to upper case and
characters that are illegal in a preprocessor macro name are replaced with underscores.
--show-sloc
Print the number of generated physical source lines of code (SLOC).
--sloc-limitnum
Check that the number of generated physical source lines of code (SLOC) does not exceed num.
--options-filefile
Read additional options from file with each option appearing on a separate line optionally
followed by space and an option value. Empty lines and lines starting with # are ignored. Option
values can be enclosed in double (") or single (') quotes to preserve leading and trailing
whitespaces as well as to specify empty values. If the value itself contains trailing or leading
quotes, enclose it with an extra pair of quotes, for example '"x"'. Non-leading and non-trailing
quotes are interpreted as being part of the option value.
The semantics of providing options in a file is equivalent to providing the same set of options in
the same order on the command line at the point where the --options-file option is specified
except that the shell escaping and quoting is not required. You can repeat this option to specify
more than one options file.
-xoption
Pass option to the underlying C++ compiler (g++). The option value that doesn't start with - is
considered the g++ executable name.
-v Print the commands executed to run the stages of compilation.
--trace
Trace the compilation process.
--mysql-engineengine
Use engine instead of the default InnoDB in the generated database schema file. For more
information on the storage engine options see the MySQL documentation. If you would like to use
the database-default engine, pass default as the value for this option.
--sqlite-override-null
Make all columns in the generated database schema allow NULL values. This is primarily useful in
schema migration since SQLite does not support dropping of columns. By making all columns NULL we
can later "delete" them by setting their values to NULL. Note that this option overrides even the
not_null pragma.
--sqlite-lax-auto-id
Do not force monotonically increasing automatically-assigned object ids. In this mode the
generated database schema omits the AUTOINCREMENT keyword which results in faster object
persistence but may lead to automatically-assigned ids not being in a strictly ascending order.
Refer to the SQLite documentation for details.
--pgsql-server-versionver
Specify the minimum PostgreSQL server version with which the generated C++ code and schema will be
used. This information is used to enable version-specific optimizations and workarounds in the
generated C++ code and schema. The version must be in the major.minor form, for example, 9.1. If
this option is not specified, then 7.4 or later is assumed.
--oracle-client-versionver
Specify the minimum Oracle client library (OCI) version with which the generated C++ code will be
linked. This information is used to enable version-specific optimizations and workarounds in the
generated C++ code. The version must be in the major.minor form, for example, 11.2. If this
option is not specified, then 10.1 or later is assumed.
--oracle-warn-truncation
Warn about SQL names that are longer than 30 characters and are therefore truncated. Note that
during database schema generation (--generate-schema) ODB detects when such truncations lead to
name conflicts and issues diagnostics even without this option specified.
--mssql-server-versionver
Specify the minimum SQL Server server version with which the generated C++ code and schema will be
used. This information is used to enable version-specific optimizations and workarounds in the
generated C++ code and schema. The version must be in the major.minor form, for example, 9.0 (SQL
Server 2005), 10.5 (2008R2), or 11.0 (2012). If this option is not specified, then 10.0 (SQL
Server 2008) or later is assumed.
--mssql-short-limitsize
Specify the short data size limit. If a character, national character, or binary data type has a
maximum length (in bytes) less than or equal to this limit, then it is treated as shortdata,
otherwise it is longdata. For short data ODB pre-allocates an intermediate buffer of the maximum
size and binds it directly to a parameter or result column. This way the underlying API (ODBC) can
read/write directly from/to this buffer. In the case of long data, the data is read/written in
chunks using the SQLGetData()/SQLPutData() ODBC functions. While the long data approach reduces
the amount of memory used by the application, it may require greater CPU resources. The default
short data limit is 1024 bytes. When setting a custom short data limit, make sure that it is
sufficiently large so that no object id in the application is treated as long data.