# NAME

odb - object-relational mapping (ORM) compiler for C++

# SYNOPSIS

`odb [options] file [file...]`

# DESCRIPTION

Given a set of C++ classes in a header file, `odb` generates C++ code that allows you to persist, query, and update objects of these classes in a relational database (RDBMS). The relational database that the generated code should target is specified with the required `--database` option (see below).

For an input file in the form `name.hxx` (other file extensions can be used instead of `.hxx`), the following C++ files are generated: `name-odb.hxx` (header file), `name-odb.ixx` (inline file, generated unless the `--suppress-inline` option is specified), and `name-odb.cxx` (source file). Additionally, if the `--generate-schema` option is specified and the target database supports it, the `name.sql` database schema file is generated.

# OPTIONS

`--help`
  Print usage information and exit.
`--version`
  Print version and exit.
`-I` dir
  Add dir to the beginning of the list of directories to be searched for included header files.
`-D` name[=def]
  Define macro name with definition def. If definition is omitted, define name to be 1.
`-U` name
  Cancel any previous definitions of macro name, either built-in or provided with the `-D` option.
`--database`|`-d` db
  Generate code for the db database. Valid values are `mysql` and `tracer`.
`--generate-query`
  Generate query support code. Without this support you can only load objects via their ids.
`--generate-schema`
  Generate database schema. The resulting SQL file creates database tables required to store classes defined in the file being compiled. Note that all the existing information stored in such tables will be lost.
`--output-dir`|`-o` dir
  Write the generated files to dir instead of the current directory.
`--odb-file-suffix` suffix
  Use suffix instead of the default `-odb` to construct the names of the generated C++ files.
`--hxx-suffix` suffix
  Use suffix instead of the default `.hxx` to construct the name of the generated C++ header file.
`--ixx-suffix` suffix
  Use suffix instead of the default `.ixx` to construct the name of the generated C++ inline file.
`--cxx-suffix` suffix
  Use suffix instead of the default `.cxx` to construct the name of the generated C++ source file.
`--sql-suffix` suffix
  Use suffix instead of the default `.sql` to construct the name of the generated database schema file.
`--hxx-prologue` text
  Insert text at the beginning of the generated C++ header file.
`--ixx-prologue` text
  Insert text at the beginning of the generated C++ inline file.
`--cxx-prologue` text
  Insert text at the beginning of the generated C++ source file.
`--sql-prologue` text
  Insert text at the beginning of the generated database schema file.
`--hxx-epilogue` text
  Insert text at the end of the generated C++ header file.
`--ixx-epilogue` text
  Insert text at the end of the generated C++ inline file.
`--cxx-epilogue` text
  Insert text at the end of the generated C++ source file.
`--sql-epilogue` text
  Insert text at the end of the generated database schema file.
`--hxx-prologue-file` file
  Insert the content of file at the beginning of the generated C++ header file.
`--ixx-prologue-file` file
  Insert the content of file at the beginning of the generated C++ inline file.
`--cxx-prologue-file` file
  Insert the content of file at the beginning of the generated C++ source file.
`--sql-prologue-file` file
  Insert the content of file at the beginning of the generated database schema file.
`--hxx-epilogue-file` file
  Insert the content of file at the end of the generated C++ header file.
`--ixx-epilogue-file` file
  Insert the content of file at the end of the generated C++ inline file.
`--cxx-epilogue-file` file
  Insert the content of file at the end of the generated C++ source file.
`--sql-epilogue-file` file
  Insert the content of file at the end of the generated database schema file.
`--include-with-brackets`
  Use angle brackets (<>) instead of quotes ("") in the generated `#include` directives.
`--include-prefix` prefix
  Add prefix to the generated `#include` directive paths.
`--guard-prefix` prefix
  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.
`--options-file` file
  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. Repeat this option to specify more than one options file.

`-x` option
  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-engine` engine
  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.

# DIAGNOSTICS

If the input file is not valid C++, `odb` will issue diagnostic messages to STDERR and exit with non-zero exit code.

# BUGS

Send bug reports to the odb-users@codesynthesis.com mailing list.