File: c_source.h

package info (click to toggle)
gengetopt 2.23%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 5,032 kB
  • sloc: cpp: 14,765; ansic: 8,232; sh: 4,782; makefile: 754; yacc: 514; lex: 179; sed: 3
file content (508 lines) | stat: -rw-r--r-- 16,410 bytes parent folder | download
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
/*
 * File automatically generated by
 * gengen 1.4.2 by Lorenzo Bettini 
 * http://www.gnu.org/software/gengen
 */

#ifndef C_SOURCE_GEN_CLASS_H
#define C_SOURCE_GEN_CLASS_H

#include <string>
#include <iostream>

using std::string;
using std::ostream;

class c_source_gen_class
{
 protected:
  string args_info;
  string check_modes;
  bool check_possible_values;
  bool check_required_options;
  string clear_arg;
  bool cmd_list;
  string command_line;
  bool conf_parser;
  string custom_getopt;
  string description;
  string detailed_help_option_print;
  bool do_generate_strdup;
  string file_save_loop;
  string final_exit;
  string free;
  string full_help_option_print;
  bool generate_string_parser;
  string generator_version;
  string getopt_string;
  string given_init;
  string handle_dependencies;
  string handle_group;
  string handle_no_short_option;
  string handle_option;
  bool handle_question_mark;
  string handle_required;
  bool handle_unnamed;
  bool has_arg_double;
  bool has_arg_enum;
  bool has_arg_flag;
  bool has_arg_float;
  bool has_arg_int;
  bool has_arg_long;
  bool has_arg_longdouble;
  bool has_arg_longlong;
  bool has_arg_short;
  bool has_arg_string;
  bool has_details;
  bool has_hidden;
  bool has_modes;
  bool has_typed_options;
  string header_file_ext;
  string help_option_print;
  string help_string_num;
  bool include_getopt;
  string init_args_info;
  string list_def;
  string list_free;
  string long_option_struct;
  string multiple_fill_array;
  bool multiple_options;
  bool multiple_options_all_string;
  bool multiple_options_string;
  bool multiple_options_with_default;
  bool multiple_token_functions;
  bool no_options;
  bool no_package;
  string option_values;
  string package_var_name;
  string parser_name;
  string purpose;
  string reset_groups;
  string source_name;
  string update_multiple_given;
  string usage_string;
  string version_var_name;
  string versiontext;

 public:
  c_source_gen_class() :
    check_possible_values (false), check_required_options (false), cmd_list (false), conf_parser (false), do_generate_strdup (false), generate_string_parser (false), handle_question_mark (false), handle_unnamed (false), has_arg_double (false), has_arg_enum (false), has_arg_flag (false), has_arg_float (false), has_arg_int (false), has_arg_long (false), has_arg_longdouble (false), has_arg_longlong (false), has_arg_short (false), has_arg_string (false), has_details (false), has_hidden (false), has_modes (false), has_typed_options (false), include_getopt (false), multiple_options (false), multiple_options_all_string (false), multiple_options_string (false), multiple_options_with_default (false), multiple_token_functions (false), no_options (false), no_package (false)
  {
  }
  
  c_source_gen_class(const string &_args_info, const string &_check_modes, bool _check_possible_values, bool _check_required_options, const string &_clear_arg, bool _cmd_list, const string &_command_line, bool _conf_parser, const string &_custom_getopt, const string &_description, const string &_detailed_help_option_print, bool _do_generate_strdup, const string &_file_save_loop, const string &_final_exit, const string &_free, const string &_full_help_option_print, bool _generate_string_parser, const string &_generator_version, const string &_getopt_string, const string &_given_init, const string &_handle_dependencies, const string &_handle_group, const string &_handle_no_short_option, const string &_handle_option, bool _handle_question_mark, const string &_handle_required, bool _handle_unnamed, bool _has_arg_double, bool _has_arg_enum, bool _has_arg_flag, bool _has_arg_float, bool _has_arg_int, bool _has_arg_long, bool _has_arg_longdouble, bool _has_arg_longlong, bool _has_arg_short, bool _has_arg_string, bool _has_details, bool _has_hidden, bool _has_modes, bool _has_typed_options, const string &_header_file_ext, const string &_help_option_print, const string &_help_string_num, bool _include_getopt, const string &_init_args_info, const string &_list_def, const string &_list_free, const string &_long_option_struct, const string &_multiple_fill_array, bool _multiple_options, bool _multiple_options_all_string, bool _multiple_options_string, bool _multiple_options_with_default, bool _multiple_token_functions, bool _no_options, bool _no_package, const string &_option_values, const string &_package_var_name, const string &_parser_name, const string &_purpose, const string &_reset_groups, const string &_source_name, const string &_update_multiple_given, const string &_usage_string, const string &_version_var_name, const string &_versiontext) :
    args_info (_args_info), check_modes (_check_modes), check_possible_values (_check_possible_values), check_required_options (_check_required_options), clear_arg (_clear_arg), cmd_list (_cmd_list), command_line (_command_line), conf_parser (_conf_parser), custom_getopt (_custom_getopt), description (_description), detailed_help_option_print (_detailed_help_option_print), do_generate_strdup (_do_generate_strdup), file_save_loop (_file_save_loop), final_exit (_final_exit), free (_free), full_help_option_print (_full_help_option_print), generate_string_parser (_generate_string_parser), generator_version (_generator_version), getopt_string (_getopt_string), given_init (_given_init), handle_dependencies (_handle_dependencies), handle_group (_handle_group), handle_no_short_option (_handle_no_short_option), handle_option (_handle_option), handle_question_mark (_handle_question_mark), handle_required (_handle_required), handle_unnamed (_handle_unnamed), has_arg_double (_has_arg_double), has_arg_enum (_has_arg_enum), has_arg_flag (_has_arg_flag), has_arg_float (_has_arg_float), has_arg_int (_has_arg_int), has_arg_long (_has_arg_long), has_arg_longdouble (_has_arg_longdouble), has_arg_longlong (_has_arg_longlong), has_arg_short (_has_arg_short), has_arg_string (_has_arg_string), has_details (_has_details), has_hidden (_has_hidden), has_modes (_has_modes), has_typed_options (_has_typed_options), header_file_ext (_header_file_ext), help_option_print (_help_option_print), help_string_num (_help_string_num), include_getopt (_include_getopt), init_args_info (_init_args_info), list_def (_list_def), list_free (_list_free), long_option_struct (_long_option_struct), multiple_fill_array (_multiple_fill_array), multiple_options (_multiple_options), multiple_options_all_string (_multiple_options_all_string), multiple_options_string (_multiple_options_string), multiple_options_with_default (_multiple_options_with_default), multiple_token_functions (_multiple_token_functions), no_options (_no_options), no_package (_no_package), option_values (_option_values), package_var_name (_package_var_name), parser_name (_parser_name), purpose (_purpose), reset_groups (_reset_groups), source_name (_source_name), update_multiple_given (_update_multiple_given), usage_string (_usage_string), version_var_name (_version_var_name), versiontext (_versiontext)
  {
  }

  virtual ~c_source_gen_class()
  {
  }

  static void
  generate_string(const string &s, ostream &stream, unsigned int indent)
  {
    if (!indent || s.find('\n') == string::npos)
      {
        stream << s;
        return;
      }

    string::size_type pos;
    string::size_type start = 0;
    string ind (indent, ' ');
    while ( (pos=s.find('\n', start)) != string::npos)
      {
        stream << s.substr (start, (pos+1)-start);
        start = pos+1;
        if (start+1 <= s.size ())
          stream << ind;
      }
    if (start+1 <= s.size ())
      stream << s.substr (start);
  }

  void set_args_info(const string &_args_info)
  {
    args_info = _args_info;
  }

  virtual void generate_check_modes(ostream &stream, unsigned int indent) = 0;

  void set_check_modes(const string &_check_modes)
  {
    check_modes = _check_modes;
  }

  void set_check_possible_values(bool _check_possible_values)
  {
    check_possible_values = _check_possible_values;
  }

  void set_check_required_options(bool _check_required_options)
  {
    check_required_options = _check_required_options;
  }

  virtual void generate_clear_arg(ostream &stream, unsigned int indent) = 0;

  void set_clear_arg(const string &_clear_arg)
  {
    clear_arg = _clear_arg;
  }

  void set_cmd_list(bool _cmd_list)
  {
    cmd_list = _cmd_list;
  }

  void set_command_line(const string &_command_line)
  {
    command_line = _command_line;
  }

  void set_conf_parser(bool _conf_parser)
  {
    conf_parser = _conf_parser;
  }

  virtual void generate_custom_getopt(ostream &stream, unsigned int indent) = 0;

  void set_custom_getopt(const string &_custom_getopt)
  {
    custom_getopt = _custom_getopt;
  }

  void set_description(const string &_description)
  {
    description = _description;
  }

  virtual void generate_detailed_help_option_print(ostream &stream, unsigned int indent) = 0;

  void set_detailed_help_option_print(const string &_detailed_help_option_print)
  {
    detailed_help_option_print = _detailed_help_option_print;
  }

  void set_do_generate_strdup(bool _do_generate_strdup)
  {
    do_generate_strdup = _do_generate_strdup;
  }

  virtual void generate_file_save_loop(ostream &stream, unsigned int indent) = 0;

  void set_file_save_loop(const string &_file_save_loop)
  {
    file_save_loop = _file_save_loop;
  }

  void set_final_exit(const string &_final_exit)
  {
    final_exit = _final_exit;
  }

  virtual void generate_free(ostream &stream, unsigned int indent) = 0;

  void set_free(const string &_free)
  {
    free = _free;
  }

  virtual void generate_full_help_option_print(ostream &stream, unsigned int indent) = 0;

  void set_full_help_option_print(const string &_full_help_option_print)
  {
    full_help_option_print = _full_help_option_print;
  }

  void set_generate_string_parser(bool _generate_string_parser)
  {
    generate_string_parser = _generate_string_parser;
  }

  void set_generator_version(const string &_generator_version)
  {
    generator_version = _generator_version;
  }

  void set_getopt_string(const string &_getopt_string)
  {
    getopt_string = _getopt_string;
  }

  virtual void generate_given_init(ostream &stream, unsigned int indent) = 0;

  void set_given_init(const string &_given_init)
  {
    given_init = _given_init;
  }

  virtual void generate_handle_dependencies(ostream &stream, unsigned int indent) = 0;

  void set_handle_dependencies(const string &_handle_dependencies)
  {
    handle_dependencies = _handle_dependencies;
  }

  virtual void generate_handle_group(ostream &stream, unsigned int indent) = 0;

  void set_handle_group(const string &_handle_group)
  {
    handle_group = _handle_group;
  }

  virtual void generate_handle_no_short_option(ostream &stream, unsigned int indent) = 0;

  void set_handle_no_short_option(const string &_handle_no_short_option)
  {
    handle_no_short_option = _handle_no_short_option;
  }

  virtual void generate_handle_option(ostream &stream, unsigned int indent) = 0;

  void set_handle_option(const string &_handle_option)
  {
    handle_option = _handle_option;
  }

  void set_handle_question_mark(bool _handle_question_mark)
  {
    handle_question_mark = _handle_question_mark;
  }

  virtual void generate_handle_required(ostream &stream, unsigned int indent) = 0;

  void set_handle_required(const string &_handle_required)
  {
    handle_required = _handle_required;
  }

  void set_handle_unnamed(bool _handle_unnamed)
  {
    handle_unnamed = _handle_unnamed;
  }

  void set_has_arg_double(bool _has_arg_double)
  {
    has_arg_double = _has_arg_double;
  }

  void set_has_arg_enum(bool _has_arg_enum)
  {
    has_arg_enum = _has_arg_enum;
  }

  void set_has_arg_flag(bool _has_arg_flag)
  {
    has_arg_flag = _has_arg_flag;
  }

  void set_has_arg_float(bool _has_arg_float)
  {
    has_arg_float = _has_arg_float;
  }

  void set_has_arg_int(bool _has_arg_int)
  {
    has_arg_int = _has_arg_int;
  }

  void set_has_arg_long(bool _has_arg_long)
  {
    has_arg_long = _has_arg_long;
  }

  void set_has_arg_longdouble(bool _has_arg_longdouble)
  {
    has_arg_longdouble = _has_arg_longdouble;
  }

  void set_has_arg_longlong(bool _has_arg_longlong)
  {
    has_arg_longlong = _has_arg_longlong;
  }

  void set_has_arg_short(bool _has_arg_short)
  {
    has_arg_short = _has_arg_short;
  }

  void set_has_arg_string(bool _has_arg_string)
  {
    has_arg_string = _has_arg_string;
  }

  void set_has_details(bool _has_details)
  {
    has_details = _has_details;
  }

  void set_has_hidden(bool _has_hidden)
  {
    has_hidden = _has_hidden;
  }

  void set_has_modes(bool _has_modes)
  {
    has_modes = _has_modes;
  }

  void set_has_typed_options(bool _has_typed_options)
  {
    has_typed_options = _has_typed_options;
  }

  void set_header_file_ext(const string &_header_file_ext)
  {
    header_file_ext = _header_file_ext;
  }

  virtual void generate_help_option_print(ostream &stream, unsigned int indent) = 0;

  void set_help_option_print(const string &_help_option_print)
  {
    help_option_print = _help_option_print;
  }

  void set_help_string_num(const string &_help_string_num)
  {
    help_string_num = _help_string_num;
  }

  void set_include_getopt(bool _include_getopt)
  {
    include_getopt = _include_getopt;
  }

  virtual void generate_init_args_info(ostream &stream, unsigned int indent) = 0;

  void set_init_args_info(const string &_init_args_info)
  {
    init_args_info = _init_args_info;
  }

  virtual void generate_list_def(ostream &stream, unsigned int indent) = 0;

  void set_list_def(const string &_list_def)
  {
    list_def = _list_def;
  }

  virtual void generate_list_free(ostream &stream, unsigned int indent) = 0;

  void set_list_free(const string &_list_free)
  {
    list_free = _list_free;
  }

  virtual void generate_long_option_struct(ostream &stream, unsigned int indent) = 0;

  void set_long_option_struct(const string &_long_option_struct)
  {
    long_option_struct = _long_option_struct;
  }

  virtual void generate_multiple_fill_array(ostream &stream, unsigned int indent) = 0;

  void set_multiple_fill_array(const string &_multiple_fill_array)
  {
    multiple_fill_array = _multiple_fill_array;
  }

  void set_multiple_options(bool _multiple_options)
  {
    multiple_options = _multiple_options;
  }

  void set_multiple_options_all_string(bool _multiple_options_all_string)
  {
    multiple_options_all_string = _multiple_options_all_string;
  }

  void set_multiple_options_string(bool _multiple_options_string)
  {
    multiple_options_string = _multiple_options_string;
  }

  void set_multiple_options_with_default(bool _multiple_options_with_default)
  {
    multiple_options_with_default = _multiple_options_with_default;
  }

  void set_multiple_token_functions(bool _multiple_token_functions)
  {
    multiple_token_functions = _multiple_token_functions;
  }

  void set_no_options(bool _no_options)
  {
    no_options = _no_options;
  }

  void set_no_package(bool _no_package)
  {
    no_package = _no_package;
  }

  virtual void generate_option_values(ostream &stream, unsigned int indent) = 0;

  void set_option_values(const string &_option_values)
  {
    option_values = _option_values;
  }

  void set_package_var_name(const string &_package_var_name)
  {
    package_var_name = _package_var_name;
  }

  void set_parser_name(const string &_parser_name)
  {
    parser_name = _parser_name;
  }

  void set_purpose(const string &_purpose)
  {
    purpose = _purpose;
  }

  virtual void generate_reset_groups(ostream &stream, unsigned int indent) = 0;

  void set_reset_groups(const string &_reset_groups)
  {
    reset_groups = _reset_groups;
  }

  void set_source_name(const string &_source_name)
  {
    source_name = _source_name;
  }

  virtual void generate_update_multiple_given(ostream &stream, unsigned int indent) = 0;

  void set_update_multiple_given(const string &_update_multiple_given)
  {
    update_multiple_given = _update_multiple_given;
  }

  void set_usage_string(const string &_usage_string)
  {
    usage_string = _usage_string;
  }

  void set_version_var_name(const string &_version_var_name)
  {
    version_var_name = _version_var_name;
  }

  void set_versiontext(const string &_versiontext)
  {
    versiontext = _versiontext;
  }

  void generate_c_source(ostream &stream, unsigned int indent = 0);
  
};

#endif // C_SOURCE_GEN_CLASS_H