1 /*
2  * File automatically generated by
3  * gengen 1.4.2 by Lorenzo Bettini
4  * http://www.gnu.org/software/gengen
5  */
6 
7 #ifndef C_SOURCE_GEN_CLASS_H
8 #define C_SOURCE_GEN_CLASS_H
9 
10 #include <string>
11 #include <iostream>
12 
13 using std::string;
14 using std::ostream;
15 
16 class c_source_gen_class
17 {
18  protected:
19   string args_info;
20   string check_modes;
21   bool check_possible_values;
22   bool check_required_options;
23   string clear_arg;
24   bool cmd_list;
25   string command_line;
26   bool conf_parser;
27   string custom_getopt;
28   string description;
29   string detailed_help_option_print;
30   bool do_generate_strdup;
31   string file_save_loop;
32   string final_exit;
33   string free;
34   string full_help_option_print;
35   bool generate_string_parser;
36   string generator_version;
37   string getopt_string;
38   string given_init;
39   string handle_dependencies;
40   string handle_group;
41   string handle_no_short_option;
42   string handle_option;
43   bool handle_question_mark;
44   string handle_required;
45   bool handle_unnamed;
46   bool has_arg_double;
47   bool has_arg_enum;
48   bool has_arg_flag;
49   bool has_arg_float;
50   bool has_arg_int;
51   bool has_arg_long;
52   bool has_arg_longdouble;
53   bool has_arg_longlong;
54   bool has_arg_short;
55   bool has_arg_string;
56   bool has_details;
57   bool has_hidden;
58   bool has_modes;
59   bool has_typed_options;
60   string header_file_ext;
61   string help_option_print;
62   string help_string_num;
63   bool include_getopt;
64   string init_args_info;
65   string list_def;
66   string list_free;
67   string long_option_struct;
68   string multiple_fill_array;
69   bool multiple_options;
70   bool multiple_options_all_string;
71   bool multiple_options_string;
72   bool multiple_options_with_default;
73   bool multiple_token_functions;
74   bool no_options;
75   bool no_package;
76   string option_values;
77   string package_var_name;
78   string parser_name;
79   string purpose;
80   string reset_groups;
81   string source_name;
82   string update_multiple_given;
83   string usage_string;
84   string version_var_name;
85   string versiontext;
86 
87  public:
c_source_gen_class()88   c_source_gen_class() :
89     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)
90   {
91   }
92 
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)93   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) :
94     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)
95   {
96   }
97 
~c_source_gen_class()98   virtual ~c_source_gen_class()
99   {
100   }
101 
102   static void
generate_string(const string & s,ostream & stream,unsigned int indent)103   generate_string(const string &s, ostream &stream, unsigned int indent)
104   {
105     if (!indent || s.find('\n') == string::npos)
106       {
107         stream << s;
108         return;
109       }
110 
111     string::size_type pos;
112     string::size_type start = 0;
113     string ind (indent, ' ');
114     while ( (pos=s.find('\n', start)) != string::npos)
115       {
116         stream << s.substr (start, (pos+1)-start);
117         start = pos+1;
118         if (start+1 <= s.size ())
119           stream << ind;
120       }
121     if (start+1 <= s.size ())
122       stream << s.substr (start);
123   }
124 
set_args_info(const string & _args_info)125   void set_args_info(const string &_args_info)
126   {
127     args_info = _args_info;
128   }
129 
130   virtual void generate_check_modes(ostream &stream, unsigned int indent) = 0;
131 
set_check_modes(const string & _check_modes)132   void set_check_modes(const string &_check_modes)
133   {
134     check_modes = _check_modes;
135   }
136 
set_check_possible_values(bool _check_possible_values)137   void set_check_possible_values(bool _check_possible_values)
138   {
139     check_possible_values = _check_possible_values;
140   }
141 
set_check_required_options(bool _check_required_options)142   void set_check_required_options(bool _check_required_options)
143   {
144     check_required_options = _check_required_options;
145   }
146 
147   virtual void generate_clear_arg(ostream &stream, unsigned int indent) = 0;
148 
set_clear_arg(const string & _clear_arg)149   void set_clear_arg(const string &_clear_arg)
150   {
151     clear_arg = _clear_arg;
152   }
153 
set_cmd_list(bool _cmd_list)154   void set_cmd_list(bool _cmd_list)
155   {
156     cmd_list = _cmd_list;
157   }
158 
set_command_line(const string & _command_line)159   void set_command_line(const string &_command_line)
160   {
161     command_line = _command_line;
162   }
163 
set_conf_parser(bool _conf_parser)164   void set_conf_parser(bool _conf_parser)
165   {
166     conf_parser = _conf_parser;
167   }
168 
169   virtual void generate_custom_getopt(ostream &stream, unsigned int indent) = 0;
170 
set_custom_getopt(const string & _custom_getopt)171   void set_custom_getopt(const string &_custom_getopt)
172   {
173     custom_getopt = _custom_getopt;
174   }
175 
set_description(const string & _description)176   void set_description(const string &_description)
177   {
178     description = _description;
179   }
180 
181   virtual void generate_detailed_help_option_print(ostream &stream, unsigned int indent) = 0;
182 
set_detailed_help_option_print(const string & _detailed_help_option_print)183   void set_detailed_help_option_print(const string &_detailed_help_option_print)
184   {
185     detailed_help_option_print = _detailed_help_option_print;
186   }
187 
set_do_generate_strdup(bool _do_generate_strdup)188   void set_do_generate_strdup(bool _do_generate_strdup)
189   {
190     do_generate_strdup = _do_generate_strdup;
191   }
192 
193   virtual void generate_file_save_loop(ostream &stream, unsigned int indent) = 0;
194 
set_file_save_loop(const string & _file_save_loop)195   void set_file_save_loop(const string &_file_save_loop)
196   {
197     file_save_loop = _file_save_loop;
198   }
199 
set_final_exit(const string & _final_exit)200   void set_final_exit(const string &_final_exit)
201   {
202     final_exit = _final_exit;
203   }
204 
205   virtual void generate_free(ostream &stream, unsigned int indent) = 0;
206 
set_free(const string & _free)207   void set_free(const string &_free)
208   {
209     free = _free;
210   }
211 
212   virtual void generate_full_help_option_print(ostream &stream, unsigned int indent) = 0;
213 
set_full_help_option_print(const string & _full_help_option_print)214   void set_full_help_option_print(const string &_full_help_option_print)
215   {
216     full_help_option_print = _full_help_option_print;
217   }
218 
set_generate_string_parser(bool _generate_string_parser)219   void set_generate_string_parser(bool _generate_string_parser)
220   {
221     generate_string_parser = _generate_string_parser;
222   }
223 
set_generator_version(const string & _generator_version)224   void set_generator_version(const string &_generator_version)
225   {
226     generator_version = _generator_version;
227   }
228 
set_getopt_string(const string & _getopt_string)229   void set_getopt_string(const string &_getopt_string)
230   {
231     getopt_string = _getopt_string;
232   }
233 
234   virtual void generate_given_init(ostream &stream, unsigned int indent) = 0;
235 
set_given_init(const string & _given_init)236   void set_given_init(const string &_given_init)
237   {
238     given_init = _given_init;
239   }
240 
241   virtual void generate_handle_dependencies(ostream &stream, unsigned int indent) = 0;
242 
set_handle_dependencies(const string & _handle_dependencies)243   void set_handle_dependencies(const string &_handle_dependencies)
244   {
245     handle_dependencies = _handle_dependencies;
246   }
247 
248   virtual void generate_handle_group(ostream &stream, unsigned int indent) = 0;
249 
set_handle_group(const string & _handle_group)250   void set_handle_group(const string &_handle_group)
251   {
252     handle_group = _handle_group;
253   }
254 
255   virtual void generate_handle_no_short_option(ostream &stream, unsigned int indent) = 0;
256 
set_handle_no_short_option(const string & _handle_no_short_option)257   void set_handle_no_short_option(const string &_handle_no_short_option)
258   {
259     handle_no_short_option = _handle_no_short_option;
260   }
261 
262   virtual void generate_handle_option(ostream &stream, unsigned int indent) = 0;
263 
set_handle_option(const string & _handle_option)264   void set_handle_option(const string &_handle_option)
265   {
266     handle_option = _handle_option;
267   }
268 
set_handle_question_mark(bool _handle_question_mark)269   void set_handle_question_mark(bool _handle_question_mark)
270   {
271     handle_question_mark = _handle_question_mark;
272   }
273 
274   virtual void generate_handle_required(ostream &stream, unsigned int indent) = 0;
275 
set_handle_required(const string & _handle_required)276   void set_handle_required(const string &_handle_required)
277   {
278     handle_required = _handle_required;
279   }
280 
set_handle_unnamed(bool _handle_unnamed)281   void set_handle_unnamed(bool _handle_unnamed)
282   {
283     handle_unnamed = _handle_unnamed;
284   }
285 
set_has_arg_double(bool _has_arg_double)286   void set_has_arg_double(bool _has_arg_double)
287   {
288     has_arg_double = _has_arg_double;
289   }
290 
set_has_arg_enum(bool _has_arg_enum)291   void set_has_arg_enum(bool _has_arg_enum)
292   {
293     has_arg_enum = _has_arg_enum;
294   }
295 
set_has_arg_flag(bool _has_arg_flag)296   void set_has_arg_flag(bool _has_arg_flag)
297   {
298     has_arg_flag = _has_arg_flag;
299   }
300 
set_has_arg_float(bool _has_arg_float)301   void set_has_arg_float(bool _has_arg_float)
302   {
303     has_arg_float = _has_arg_float;
304   }
305 
set_has_arg_int(bool _has_arg_int)306   void set_has_arg_int(bool _has_arg_int)
307   {
308     has_arg_int = _has_arg_int;
309   }
310 
set_has_arg_long(bool _has_arg_long)311   void set_has_arg_long(bool _has_arg_long)
312   {
313     has_arg_long = _has_arg_long;
314   }
315 
set_has_arg_longdouble(bool _has_arg_longdouble)316   void set_has_arg_longdouble(bool _has_arg_longdouble)
317   {
318     has_arg_longdouble = _has_arg_longdouble;
319   }
320 
set_has_arg_longlong(bool _has_arg_longlong)321   void set_has_arg_longlong(bool _has_arg_longlong)
322   {
323     has_arg_longlong = _has_arg_longlong;
324   }
325 
set_has_arg_short(bool _has_arg_short)326   void set_has_arg_short(bool _has_arg_short)
327   {
328     has_arg_short = _has_arg_short;
329   }
330 
set_has_arg_string(bool _has_arg_string)331   void set_has_arg_string(bool _has_arg_string)
332   {
333     has_arg_string = _has_arg_string;
334   }
335 
set_has_details(bool _has_details)336   void set_has_details(bool _has_details)
337   {
338     has_details = _has_details;
339   }
340 
set_has_hidden(bool _has_hidden)341   void set_has_hidden(bool _has_hidden)
342   {
343     has_hidden = _has_hidden;
344   }
345 
set_has_modes(bool _has_modes)346   void set_has_modes(bool _has_modes)
347   {
348     has_modes = _has_modes;
349   }
350 
set_has_typed_options(bool _has_typed_options)351   void set_has_typed_options(bool _has_typed_options)
352   {
353     has_typed_options = _has_typed_options;
354   }
355 
set_header_file_ext(const string & _header_file_ext)356   void set_header_file_ext(const string &_header_file_ext)
357   {
358     header_file_ext = _header_file_ext;
359   }
360 
361   virtual void generate_help_option_print(ostream &stream, unsigned int indent) = 0;
362 
set_help_option_print(const string & _help_option_print)363   void set_help_option_print(const string &_help_option_print)
364   {
365     help_option_print = _help_option_print;
366   }
367 
set_help_string_num(const string & _help_string_num)368   void set_help_string_num(const string &_help_string_num)
369   {
370     help_string_num = _help_string_num;
371   }
372 
set_include_getopt(bool _include_getopt)373   void set_include_getopt(bool _include_getopt)
374   {
375     include_getopt = _include_getopt;
376   }
377 
378   virtual void generate_init_args_info(ostream &stream, unsigned int indent) = 0;
379 
set_init_args_info(const string & _init_args_info)380   void set_init_args_info(const string &_init_args_info)
381   {
382     init_args_info = _init_args_info;
383   }
384 
385   virtual void generate_list_def(ostream &stream, unsigned int indent) = 0;
386 
set_list_def(const string & _list_def)387   void set_list_def(const string &_list_def)
388   {
389     list_def = _list_def;
390   }
391 
392   virtual void generate_list_free(ostream &stream, unsigned int indent) = 0;
393 
set_list_free(const string & _list_free)394   void set_list_free(const string &_list_free)
395   {
396     list_free = _list_free;
397   }
398 
399   virtual void generate_long_option_struct(ostream &stream, unsigned int indent) = 0;
400 
set_long_option_struct(const string & _long_option_struct)401   void set_long_option_struct(const string &_long_option_struct)
402   {
403     long_option_struct = _long_option_struct;
404   }
405 
406   virtual void generate_multiple_fill_array(ostream &stream, unsigned int indent) = 0;
407 
set_multiple_fill_array(const string & _multiple_fill_array)408   void set_multiple_fill_array(const string &_multiple_fill_array)
409   {
410     multiple_fill_array = _multiple_fill_array;
411   }
412 
set_multiple_options(bool _multiple_options)413   void set_multiple_options(bool _multiple_options)
414   {
415     multiple_options = _multiple_options;
416   }
417 
set_multiple_options_all_string(bool _multiple_options_all_string)418   void set_multiple_options_all_string(bool _multiple_options_all_string)
419   {
420     multiple_options_all_string = _multiple_options_all_string;
421   }
422 
set_multiple_options_string(bool _multiple_options_string)423   void set_multiple_options_string(bool _multiple_options_string)
424   {
425     multiple_options_string = _multiple_options_string;
426   }
427 
set_multiple_options_with_default(bool _multiple_options_with_default)428   void set_multiple_options_with_default(bool _multiple_options_with_default)
429   {
430     multiple_options_with_default = _multiple_options_with_default;
431   }
432 
set_multiple_token_functions(bool _multiple_token_functions)433   void set_multiple_token_functions(bool _multiple_token_functions)
434   {
435     multiple_token_functions = _multiple_token_functions;
436   }
437 
set_no_options(bool _no_options)438   void set_no_options(bool _no_options)
439   {
440     no_options = _no_options;
441   }
442 
set_no_package(bool _no_package)443   void set_no_package(bool _no_package)
444   {
445     no_package = _no_package;
446   }
447 
448   virtual void generate_option_values(ostream &stream, unsigned int indent) = 0;
449 
set_option_values(const string & _option_values)450   void set_option_values(const string &_option_values)
451   {
452     option_values = _option_values;
453   }
454 
set_package_var_name(const string & _package_var_name)455   void set_package_var_name(const string &_package_var_name)
456   {
457     package_var_name = _package_var_name;
458   }
459 
set_parser_name(const string & _parser_name)460   void set_parser_name(const string &_parser_name)
461   {
462     parser_name = _parser_name;
463   }
464 
set_purpose(const string & _purpose)465   void set_purpose(const string &_purpose)
466   {
467     purpose = _purpose;
468   }
469 
470   virtual void generate_reset_groups(ostream &stream, unsigned int indent) = 0;
471 
set_reset_groups(const string & _reset_groups)472   void set_reset_groups(const string &_reset_groups)
473   {
474     reset_groups = _reset_groups;
475   }
476 
set_source_name(const string & _source_name)477   void set_source_name(const string &_source_name)
478   {
479     source_name = _source_name;
480   }
481 
482   virtual void generate_update_multiple_given(ostream &stream, unsigned int indent) = 0;
483 
set_update_multiple_given(const string & _update_multiple_given)484   void set_update_multiple_given(const string &_update_multiple_given)
485   {
486     update_multiple_given = _update_multiple_given;
487   }
488 
set_usage_string(const string & _usage_string)489   void set_usage_string(const string &_usage_string)
490   {
491     usage_string = _usage_string;
492   }
493 
set_version_var_name(const string & _version_var_name)494   void set_version_var_name(const string &_version_var_name)
495   {
496     version_var_name = _version_var_name;
497   }
498 
set_versiontext(const string & _versiontext)499   void set_versiontext(const string &_versiontext)
500   {
501     versiontext = _versiontext;
502   }
503 
504   void generate_c_source(ostream &stream, unsigned int indent = 0);
505 
506 };
507 
508 #endif // C_SOURCE_GEN_CLASS_H
509