aboutsummaryrefslogtreecommitdiff
path: root/odb/options.cli
blob: 65c9873f9845ef50827a670cad7f92488d90ced9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
// file      : odb/options.cli
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license   : GNU GPL v3; see accompanying LICENSE file

include <set>;
include <vector>;
include <string>;

include <odb/option-types.hxx>;

class options
{
  //
  // Wrapper options. These are not passed to the plugin.
  //

  bool --help {"Print usage information and exit."};
  bool --version {"Print version and exit."};

  //
  // C++ preprocessor options. Also not passed to the plugin.
  //
  std::vector<std::string> -I
  {
    "<dir>",
    "Add <dir> to the beginning of the list of directories to be searched
     for included header files."
  };

  std::vector<std::string> -D
  {
    "<name>[=<def>]",
    "Define macro <name> with definition <def>. If definition is omitted,
     define <name> to be 1."
  };

  std::vector<std::string> -U
  {
    "<name>",
    "Cancel any previous definitions of macro <name>, either built-in or
     provided with the \cb{-D} option."
  };

  //
  // Plugin options.
  //
  ::database --database | -d
  {
    "<db>",
    "Generate code for the <db> database. Valid values are \cb{mysql},
     \cb{pgsql}, \cb{sqlite}, and \cb{tracer}."
  };

  bool --generate-query | -q
  {
    "Generate query support code. Without this support you can only
     load objects via their ids."
  };

  bool --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 (\cb{--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 and PostgreSQL databases and the schema is embedded into the
     C++ code for the SQLite database. Use the \cb{--schema-format} option
     to alter the default schema format."
  };

  std::set< ::schema_format> --schema-format
  {
    "<format>",
    "Generate the database schema in the specified format. Pass \cb{sql} as
     <format> to generate the database schema as a standalone SQL file or
     pass \cb{embedded} to embed the schema into the generated C++ code.
     Repeat this option to generate the same database schema in multiple
     formats."
  };

  std::string --default-schema = ""
  {
    "<name>",
    "Use <name> as the default database schema name. Schema names are
     primarily used for distinguishing between multiple embedded schemas in
     the schema catalog. If this option is not specified, the empty name,
     which corresponds to the default schema, is used."
  };

  std::string --default-pointer = "*"
  {
    "<ptr>",
    "Use <ptr> as the default pointer for persistent objects. Objects that
     do not  have a pointer assigned with the \cb{db pointer} pragma
     will use this pointer by default. The value of this option can be \cb{*}
     which denotes the raw pointer and is the default, or a qualified name
     of a smart pointer class template, for example, \cb{std::auto_ptr}. In
     the latter case, the ODB compiler constructs the object pointer by adding
     a single template argument of the object type to the qualified name, for
     example \cb{std::auto_ptr<object>}. The object pointer is used by the
     ODB runtime to return, pass, and cache dynamically allocated instances
     of the object type.

     Except for the raw pointer and the standard smart pointers defined
     in the \cb{<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 \cb{--hxx-prologue} option to add the necessary \cb{#include}
     directive to the generated code."
  };

  // The following option is "fake" in that it is actually handled by
  // argv_file_scanner. We have it here to get the documentation.
  //
  std::string --profile | -p
  {
    "<name>",
    "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 \cb{-}\ci{database}\cb{.options} suffix to <name>, where
     \ci{database} is the database name as specified with the
     \cb{--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 \cb{.options} suffix.

     The profile options files are searched for in the same set of
     directories as C++ headers included with the \cb{#include <...>}
     directive (built-in paths plus those specified with the \cb{-I}
     options). The options file is first searched for in the directory
     itself and then in its \cb{odb/} subdirectory.

     For the format of the options file refer to the \cb{--options-file}
     option below. You can repeat this option to specify more than one
     profile."
  };

  std::string --table-prefix
  {
    "<prefix>",
    "Add <prefix> to table and index names. The prefix is added to both
     names that were specified with the \cb{db table} pragma and those
     that were automatically derived from class 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."
  };

  std::string --output-dir | -o
  {
    "<dir>",
    "Write the generated files to <dir> instead of the current directory."
  };

  std::string --odb-file-suffix = "-odb"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{-odb} to construct the names
     of the generated C++ files."
  };

  std::string --hxx-suffix = ".hxx"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.hxx} to construct the name of
     the generated C++ header file."
  };

  std::string --ixx-suffix = ".ixx"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.ixx} to construct the name of
     the generated C++ inline file."
  };

  std::string --cxx-suffix = ".cxx"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.cxx} to construct the name of
     the generated C++ source file."
  };

  std::string --sql-suffix = ".sql"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.sql} to construct the name of
     the generated database schema file."
  };

  // Prologues.
  //
  std::vector<std::string> --hxx-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated C++ header file."
  };

  std::vector<std::string> --ixx-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated C++ inline file."
  };

  std::vector<std::string> --cxx-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated C++ source file."
  };

  std::vector<std::string> --sql-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated database schema file."
  };

  // Epilogues.
  //
  std::vector<std::string> --hxx-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated C++ header file."
  };

  std::vector<std::string> --ixx-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated C++ inline file."
  };

  std::vector<std::string> --cxx-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated C++ source file."
  };

  std::vector<std::string> --sql-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated database schema file."
  };

  // Prologue files.
  //
  std::string --hxx-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated C++
     header file."
  };

  std::string --ixx-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated C++
     inline file."
  };

  std::string --cxx-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated C++
     source file."
  };

  std::string --sql-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated
     database schema file."
  };

  // Epilogue files.
  //
  std::string --hxx-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated C++ header
     file."
  };

  std::string --ixx-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated C++ inline
     file."
  };

  std::string --cxx-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated C++ source
     file."
  };

  std::string --sql-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated database
     schema file."
  };

  // ODB compilation prologue/epilogue.
  //
  std::vector<std::string> --odb-prologue
  {
    "<text>",
    "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."
  };

  std::vector<std::string> --odb-prologue-file
  {
    "<file>",
    "Compile <file> contents before the input header file. Prologue files
     are compiled after all the prologue text fragments (\cb{--odb-prologue}
     option)."
  };

  std::vector<std::string> --odb-epilogue
  {
    "<text>",
    "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."
  };

  std::vector<std::string> --odb-epilogue-file
  {
    "<file>",
    "Compile <file> contents after the input header file. Epilogue files
     are compiled after all the epilogue text fragments (\cb{--odb-epilogue}
     option)."
  };

  // Include options.
  //
  bool --include-with-brackets
  {
    "Use angle brackets (<>) instead of quotes (\"\") in the generated
     \cb{#include} directives."
  };

  std::string --include-prefix
  {
    "<prefix>",
    "Add <prefix> to the generated \cb{#include} directive paths."
  };

  std::vector<std::string> --include-regex
  {
    "<regex>",
    "Add <regex> to the list of regular expressions used to transform
     generated \cb{#include} directive paths. The argument to this option
     is a Perl-like regular expression in the form
     \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be
     used as a delimiter instead of \cb{/} and the delimiter can be escaped
     inside \ci{pattern} and \ci{replacement} with a backslash (\cb{\\}).
     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 \cb{foo/bar-odb.h} to paths in the form
     \cb{foo/generated/bar-odb.h}:

     \cb{%foo/(.+)-odb.h%foo/generated/$1-odb.h%}

     See also the REGEX AND SHELL QUOTING section below."
  };

  bool --include-regex-trace
  {
    "Trace the process of applying regular expressions specified with the
     \cb{--include-regex} option. Use this option to find out why your
     regular expressions don't do what you expected them to do."
  };

  std::string --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."
  };

  // The following option is "fake" in that it is actually handled by
  // argv_file_scanner. We have it here to get the documentation.
  //
  std::string --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 \cb{#} are ignored. Option values can
     be enclosed in double (\cb{\"}) or single (\cb{'}) 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 \cb{'\"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 \cb{--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."
  };

  std::vector<std::string> -x
  {
    "<option>",
    "Pass <option> to the underlying C++ compiler (\cb{g++}). The <option>
     value that doesn't start with \cb{-} is considered the \cb{g++}
     executable name."
  };

  bool -v {"Print the commands executed to run the stages of compilation."};

  bool --trace {"Trace the compilation process."};

  //
  // MySQL-specific options.
  //

  std::string --mysql-engine = "InnoDB"
  {
    "<engine>",
    "Use <engine> instead of the default \cb{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 \cb{default} as the value for this
     option."
  };

  //
  // SQLite-specific options.
  //

  bool --sqlite-lax-auto-id
  {
    "Do not force monotonically increasing automatically-assigned
     object ids. In this mode the generated database schema omits the
     \cb{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."
  };
};