aboutsummaryrefslogtreecommitdiff
path: root/xsd/options.cli
blob: 6ab4ab3a3afb81f465d9902e1b1eedb1403a650a (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
// file      : xsd/options.cli
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

include <vector>;
include <string>;
include <cstddef>; // std::size_t

include <cult/types.hxx>; // NarrowString

class help_options
{
  // These are all documented elsewhere.
  //
  bool --help;
  bool --version;
  bool --proprietary-license;
};

class options = 0
{
  std::vector<Cult::Types::NarrowString> --disable-warning
  {
    "<warn>",
    "Disable printing warning with id <warn>. If \cb{all} is specified for
     the warning id then all warnings are disabled."
  };

  // 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>. Each option should 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."
  };

  // SLOC/license options.
  //
  bool --show-sloc
  {
    "Show the number of generated physical source lines of code (SLOC)."
  };

  std::size_t --sloc-limit
  {
    "<num>",
    "Check that the number of generated physical source lines of code (SLOC)
     does not exceed <num>."
  };

  bool --proprietary-license
  {
    "Indicate that the generated code is licensed under a proprietary
     license instead of the GPL."
  };

  Cult::Types::NarrowString --custom-literals
  {
    "<file>",
    "Load custom XML string to C++ literal mappings from <file>. This
     mechanism can be useful if you are using a custom character encoding
     and some of the strings in your schemas, for example element/attribute
     names or enumeration values, contain non-ASCII characters. In this
     case you will need to provide a custom mapping to C++ literals for
     such strings. The format of this file is specified in the
     \cb{custom-literals.xsd} XML Schema file that can be found in the
     documentation directory."
  };

  // Anonymous type morphing.
  //
  bool --preserve-anonymous
  {
    "Preserve anonymous types. By default anonymous types are automatically
     named with names derived from the enclosing elements/attributes. Because
     mappings implemented by this compiler require all types to be named,
     this option is only useful if you want to make sure your schemas don't
     have anonymous types."
  };

  bool --show-anonymous
  {
    "Show elements and attributes that are of anonymous types. This option
     only makes sense together with the \cb{--preserve-anonymous} option."
  };

  std::vector<Cult::Types::NarrowString> --anonymous-regex
  {
    "<regex>",
    "Add <regex> to the list of regular expressions used to derive names for
     anonymous types from the enclosing attributes/elements. <regex> 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{/}. Escaping of
     the delimiter character in \ci{pattern} or \ci{replacement} is not
     supported.

     All the regular expressions are pushed into a stack with the last
     specified expression considered first. The first match that succeeds is
     used. Regular expressions are applied to a string in the form

     \c{\i{filename} \i{namespace} \i{xpath}}

     For instance:

     \cb{hello.xsd http://example.com/hello element}

     \cb{hello.xsd http://example.com/hello type/element}

     As an example, the following expression makes all the derived names
     start with capital letters. This could be useful when your naming
     convention requires type names to start with capital letters:

     \cb{%.* .* (.+/)*(.+)%\\u$2%}

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

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

  bool --morph-anonymous; // Deprecated and therefore undocumented.

  // Location options.
  //
  std::vector<Cult::Types::NarrowString> --location-map
  {
    "<ol>=<nl>",
    "Map the original schema location <ol> that is specified in the XML
     Schema include or import elements to new schema location <nl>. Repeat
     this option to map more than one schema location. For example, the
     following option maps the \cb{http://example.com/foo.xsd} URL to the
     \cb{foo.xsd} local file.

     \cb{--location-map http://example.com/foo.xsd=foo.xsd}"
  };

  std::vector<Cult::Types::NarrowString> --location-regex
  {
    "<regex>",
    "Add <regex> to the list of regular expressions used to map schema
     locations that are specified in the XML Schema include or import
     elements. <regex> 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{/}. Escaping of the delimiter
     character in \ci{pattern} or \ci{replacement} is not supported. All
     the regular expressions are pushed into a stack with the last specified
     expression considered first. The first match that succeeds is used.

     For example, the following expression maps URL locations in the form
     \cb{http://example.com/foo/bar.xsd} to local files in the form
     \cb{bar.xsd}:

     \cb{%http://.+/(.+)%$1%}

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

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

  // File-per-type option.
  //
  bool --file-per-type
  {
    "Generate a separate set of C++ files for each type defined in XML
     Schema. Note that in this mode you only need to compile the root
     schema(s) and the code will be generated for all included and
     imported schemas. This compilation mode is primarily useful when
     some of your schemas cannot be compiled separately or have cyclic
     dependencies which involve type inheritance. Other options related
     to this mode are: \cb{--type-file-regex}, \cb{--schema-file-regex},
     \cb{--fat-type-file}, and \cb{--file-list}."
  };

  std::vector<Cult::Types::NarrowString> --type-file-regex
  {
    "<regex>",
    "Add <regex> to the list of regular expressions used to translate type
     names to file names when the \cb{--file-per-type} option is specified.
     <regex> 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{/}. Escaping of the delimiter
     character in \ci{pattern} or \ci{replacement} is not supported. All
     the regular expressions are pushed into a stack with the last specified
     expression considered first. The first match that succeeds is used.
     Regular expressions are applied to a string in the form

     \c{\i{namespace} \i{type-name}}

     For example, the following expression maps type \cb{foo} that is
     defined in the \cb{http://example.com/bar} namespace to file name
     \cb{bar-foo}:

     \cb{%http://example.com/(.+) (.+)%$1-$2%}

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

  bool --type-file-regex-trace
  {
    "Trace the process of applying regular expressions specified with the
     \cb{--type-file-regex} option. Use this option to find out why your
     regular expressions don't do what you expected them to do."
  };
  std::vector<Cult::Types::NarrowString> --schema-file-regex
  {
    "<regex>",
    "Add <regex> to the list of regular expressions used to translate schema
     file names when the \cb{--file-per-type} option is specified. <regex> 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{/}. Escaping of the delimiter character in
     \ci{pattern} or \ci{replacement} is not supported. All the regular
     expressions are pushed into a stack with the last specified expression
     considered first. The first match that succeeds is used. Regular
     Expressions are applied to the absolute filesystem path of a schema file
     and the result, including the directory part, if any, is used to derive
     the \cb{#include} directive paths as well as the generated C++ file
     paths. This option, along with \cb{--type-file-regex} are primarily
     useful to place the generated files into subdirectories or to resolve
     file name conflicts.

     For example, the following expression maps schema files in the
     \cb{foo/1.0.0/} subdirectory to the files in the \cb{foo/} subdirectory.
     As a result, the \cb{#include} directive paths for such schemas will be
     in the \cb{foo/schema.hxx} form and the generated C++ files will be
     placed into the \cb{foo/} subdirectory:

     \cb{%.*/foo/1.0.0/(.+)%foo/$1%}

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

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

  bool --fat-type-file
  {
    "Generate code corresponding to global elements into type files instead
     of schema files when the \cb{--type-file-regex} option is specified.
     This option is primarily useful when trying to minimize the amount of
     object code that is linked to an executable by packaging compiled
     generated code into a static (archive) library."
  };

  // File list options.
  //
  Cult::Types::NarrowString --file-list
  {
    "<file>",
    "Write a list of generated C++ files to <file>. This option is primarily
     useful in the file-per-type compilation mode (\cb{--file-per-type}) to
     create a list of generated C++ files, for example, as a makefile
     fragment."
  };

  Cult::Types::NarrowString --file-list-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the file list. As a convenience, all
     occurrences of the \cb{\\n} character sequence in <text> are replaced
     with new lines. This option can, for example, be used to assign the
     generated file list to a makefile variable."
  };

  Cult::Types::NarrowString --file-list-epilogue
  {
    "<text>",
    "Insert <text> at the end of the file list. As a convenience, all
     occurrences of the \cb{\\n} character sequence in <text> are replaced
     with new lines."
  };

  Cult::Types::NarrowString --file-list-delim = "\n"
  {
    "<text>",
    "Delimit file names written to the file list with <text> instead of new
     lines. As a convenience, all occurrences of the \cb{\\n} character
     sequence in <text> are replaced with new lines."
  };

  // Undocumented.
  //
  bool --disable-multi-import;
  bool --disable-full-check;
};