2 * File automatically generated by
3 * gengen 1.4 by Lorenzo Bettini
4 * http://www.gnu.org/software/gengen
10 header_gen_class::generate_header(ostream &stream, unsigned int indent)
12 string indent_str (indent, ' ');
18 generate_string (header_file_name, stream, indent + indent_str.length ());
20 generate_string (header_file_ext, stream, indent + indent_str.length ());
25 stream << "brief The header file for the command line option parser";
28 stream << " * generated by GNU Gengetopt ";
29 generate_string (generator_version, stream, indent + indent_str.length ());
32 stream << " * http://www.gnu.org/software/gengetopt.";
35 stream << " * DO NOT modify this file, since it can be overwritten";
40 stream << "author GNU Gengetopt by Lorenzo Bettini */";
46 generate_string (ifndefname, stream, indent + indent_str.length ());
51 generate_string (ifndefname, stream, indent + indent_str.length ());
57 stream << "/* If we use autoconf. */";
60 stream << "#ifdef HAVE_CONFIG_H";
63 stream << "#include \"config.h\"";
71 stream << "#include <stdio.h> /* for FILE */";
76 stream << "#ifdef __cplusplus";
79 stream << "extern \"C\" {";
82 stream << "#endif /* __cplusplus */";
88 generate_string (package_var_name, stream, indent + indent_str.length ());
93 stream << "brief the program name (used for printing errors) */";
97 generate_string (package_var_name, stream, indent + indent_str.length ());
99 generate_string (package_var_val, stream, indent + indent_str.length ());
101 stream << indent_str;
104 stream << indent_str;
106 stream << indent_str;
107 stream << "#ifndef ";
108 generate_string (package_var_name, stream, indent + indent_str.length ());
111 stream << indent_str;
114 stream << "brief the complete program name (used for help and version) */";
116 stream << indent_str;
117 if (( package_var_val != "PACKAGE" ))
119 stream << "#define ";
120 generate_string (package_var_name, stream, indent + indent_str.length ());
122 generate_string (package_var_val, stream, indent + indent_str.length ());
124 stream << indent_str;
128 stream << "#ifdef PACKAGE_NAME";
130 stream << indent_str;
131 stream << "#define ";
132 generate_string (package_var_name, stream, indent + indent_str.length ());
133 stream << "_NAME PACKAGE_NAME";
135 stream << indent_str;
138 stream << indent_str;
139 stream << "#define ";
140 generate_string (package_var_name, stream, indent + indent_str.length ());
141 stream << "_NAME PACKAGE";
143 stream << indent_str;
146 stream << indent_str;
150 stream << indent_str;
152 stream << indent_str;
153 stream << "#ifndef ";
154 generate_string (version_var_name, stream, indent + indent_str.length ());
156 stream << indent_str;
159 stream << "brief the program version */";
161 stream << indent_str;
162 stream << "#define ";
163 generate_string (version_var_name, stream, indent + indent_str.length ());
165 generate_string (version_var_val, stream, indent + indent_str.length ());
167 stream << indent_str;
170 stream << indent_str;
171 if (enum_types.size () > 0)
172 generate_string (enum_types, stream, indent + indent_str.length ());
174 generate_enum_types (stream, indent + indent_str.length ());
175 stream << indent_str;
177 stream << indent_str;
180 stream << "brief Where the command line options are stored */";
182 stream << indent_str;
184 generate_string (args_info, stream, indent + indent_str.length ());
186 stream << indent_str;
189 stream << indent_str;
192 if (option_arg.size () > 0)
193 generate_string (option_arg, stream, indent + indent_str.length ());
195 generate_option_arg (stream, indent + indent_str.length ());
198 stream << indent_str;
201 if (option_given.size () > 0)
202 generate_string (option_given, stream, indent + indent_str.length ());
204 generate_option_given (stream, indent + indent_str.length ());
207 stream << indent_str;
209 if (group_counters.size () > 0)
210 generate_string (group_counters, stream, indent + indent_str.length ());
212 generate_group_counters (stream, indent + indent_str.length ());
214 stream << indent_str;
216 if (mode_counters.size () > 0)
217 generate_string (mode_counters, stream, indent + indent_str.length ());
219 generate_mode_counters (stream, indent + indent_str.length ());
221 stream << indent_str;
224 stream << indent_str;
226 stream << indent_str;
229 stream << "brief The additional parameters to pass to parser functions */";
231 stream << indent_str;
233 generate_string (parser_name, stream, indent + indent_str.length ());
236 stream << indent_str;
239 stream << indent_str;
240 stream << " int override; /**< ";
242 stream << "brief whether to override possibly already present options (default 0) */";
244 stream << indent_str;
245 stream << " int initialize; /**< ";
247 stream << "brief whether to initialize the option structure ";
248 generate_string (args_info, stream, indent + indent_str.length ());
249 stream << " (default 1) */";
251 stream << indent_str;
252 stream << " int check_required; /**< ";
254 stream << "brief whether to check that all required options were provided (default 1) */";
256 stream << indent_str;
257 stream << " int check_ambiguity; /**< ";
259 stream << "brief whether to check for options already specified in the option structure ";
260 generate_string (args_info, stream, indent + indent_str.length ());
261 stream << " (default 0) */";
263 stream << indent_str;
264 stream << " int print_errors; /**< ";
266 stream << "brief whether getopt_long should print an error message for a bad option (default 1) */";
268 stream << indent_str;
271 stream << indent_str;
273 stream << indent_str;
276 stream << "brief the purpose string of the program */";
278 stream << indent_str;
279 stream << "extern const char *";
280 generate_string (args_info, stream, indent + indent_str.length ());
281 stream << "_purpose;";
283 stream << indent_str;
286 stream << "brief the usage string of the program */";
288 stream << indent_str;
289 stream << "extern const char *";
290 generate_string (args_info, stream, indent + indent_str.length ());
293 stream << indent_str;
296 stream << "brief all the lines making the help output */";
298 stream << indent_str;
299 stream << "extern const char *";
300 generate_string (args_info, stream, indent + indent_str.length ());
301 stream << "_help[];";
303 stream << indent_str;
308 stream << "brief all the lines making the full help output (including hidden options) */";
310 stream << indent_str;
311 stream << "extern const char *";
312 generate_string (args_info, stream, indent + indent_str.length ());
313 stream << "_full_help[];";
315 stream << indent_str;
321 stream << "brief all the lines making the detailed help output (including hidden options and details) */";
323 stream << indent_str;
324 stream << "extern const char *";
325 generate_string (args_info, stream, indent + indent_str.length ());
326 stream << "_detailed_help[];";
328 stream << indent_str;
331 stream << indent_str;
334 stream << indent_str;
335 stream << " * The command line parser";
337 stream << indent_str;
340 stream << "param argc the number of command line options";
342 stream << indent_str;
345 stream << "param argv the command line options";
347 stream << indent_str;
350 stream << "param args_info the structure where option information will be stored";
352 stream << indent_str;
355 stream << "return 0 if everything went fine, NON 0 if an error took place";
357 stream << indent_str;
360 stream << indent_str;
362 generate_string (parser_name, stream, indent + indent_str.length ());
363 stream << " (int argc, char **argv,";
365 stream << indent_str;
366 stream << " struct ";
367 generate_string (args_info, stream, indent + indent_str.length ());
368 stream << " *args_info);";
370 stream << indent_str;
372 stream << indent_str;
375 stream << indent_str;
376 stream << " * The command line parser (version with additional parameters - deprecated)";
378 stream << indent_str;
381 stream << "param argc the number of command line options";
383 stream << indent_str;
386 stream << "param argv the command line options";
388 stream << indent_str;
391 stream << "param args_info the structure where option information will be stored";
393 stream << indent_str;
396 stream << "param override whether to override possibly already present options";
398 stream << indent_str;
401 stream << "param initialize whether to initialize the option structure my_args_info";
403 stream << indent_str;
406 stream << "param check_required whether to check that all required options were provided";
408 stream << indent_str;
411 stream << "return 0 if everything went fine, NON 0 if an error took place";
413 stream << indent_str;
416 stream << "deprecated use ";
417 generate_string (parser_name, stream, indent + indent_str.length ());
418 stream << "_ext() instead";
420 stream << indent_str;
423 stream << indent_str;
425 generate_string (parser_name, stream, indent + indent_str.length ());
426 stream << "2 (int argc, char **argv,";
428 stream << indent_str;
429 stream << " struct ";
430 generate_string (args_info, stream, indent + indent_str.length ());
431 stream << " *args_info,";
433 stream << indent_str;
434 stream << " int override, int initialize, int check_required);";
436 stream << indent_str;
438 stream << indent_str;
441 stream << indent_str;
442 stream << " * The command line parser (version with additional parameters)";
444 stream << indent_str;
447 stream << "param argc the number of command line options";
449 stream << indent_str;
452 stream << "param argv the command line options";
454 stream << indent_str;
457 stream << "param args_info the structure where option information will be stored";
459 stream << indent_str;
462 stream << "param params additional parameters for the parser";
464 stream << indent_str;
467 stream << "return 0 if everything went fine, NON 0 if an error took place";
469 stream << indent_str;
472 stream << indent_str;
474 generate_string (parser_name, stream, indent + indent_str.length ());
475 stream << "_ext (int argc, char **argv,";
477 stream << indent_str;
478 stream << " struct ";
479 generate_string (args_info, stream, indent + indent_str.length ());
480 stream << " *args_info,";
482 stream << indent_str;
483 stream << " struct ";
484 generate_string (parser_name, stream, indent + indent_str.length ());
485 stream << "_params *params);";
487 stream << indent_str;
489 stream << indent_str;
492 stream << indent_str;
493 stream << " * Save the contents of the option struct into an already open FILE stream.";
495 stream << indent_str;
498 stream << "param outfile the stream where to dump options";
500 stream << indent_str;
503 stream << "param args_info the option struct to dump";
505 stream << indent_str;
508 stream << "return 0 if everything went fine, NON 0 if an error took place";
510 stream << indent_str;
513 stream << indent_str;
515 generate_string (parser_name, stream, indent + indent_str.length ());
516 stream << "_dump(FILE *outfile,";
518 stream << indent_str;
519 stream << " struct ";
520 generate_string (args_info, stream, indent + indent_str.length ());
521 stream << " *args_info);";
523 stream << indent_str;
525 stream << indent_str;
528 stream << indent_str;
529 stream << " * Save the contents of the option struct into a (text) file.";
531 stream << indent_str;
532 stream << " * This file can be read by the config file parser (if generated by gengetopt)";
534 stream << indent_str;
537 stream << "param filename the file where to save";
539 stream << indent_str;
542 stream << "param args_info the option struct to save";
544 stream << indent_str;
547 stream << "return 0 if everything went fine, NON 0 if an error took place";
549 stream << indent_str;
552 stream << indent_str;
554 generate_string (parser_name, stream, indent + indent_str.length ());
555 stream << "_file_save(const char *filename,";
557 stream << indent_str;
558 stream << " struct ";
559 generate_string (args_info, stream, indent + indent_str.length ());
560 stream << " *args_info);";
562 stream << indent_str;
564 stream << indent_str;
567 stream << indent_str;
568 stream << " * Print the help";
570 stream << indent_str;
573 stream << indent_str;
575 generate_string (parser_name, stream, indent + indent_str.length ());
576 stream << "_print_help(void);";
578 stream << indent_str;
583 stream << indent_str;
584 stream << " * Print the full help (including hidden options)";
586 stream << indent_str;
589 stream << indent_str;
591 generate_string (parser_name, stream, indent + indent_str.length ());
592 stream << "_print_full_help(void);";
594 stream << indent_str;
600 stream << indent_str;
601 stream << " * Print the detailed help (including hidden options and details)";
603 stream << indent_str;
606 stream << indent_str;
608 generate_string (parser_name, stream, indent + indent_str.length ());
609 stream << "_print_detailed_help(void);";
611 stream << indent_str;
615 stream << indent_str;
616 stream << " * Print the version";
618 stream << indent_str;
621 stream << indent_str;
623 generate_string (parser_name, stream, indent + indent_str.length ());
624 stream << "_print_version(void);";
626 stream << indent_str;
628 stream << indent_str;
631 stream << indent_str;
632 stream << " * Initializes all the fields a ";
633 generate_string (parser_name, stream, indent + indent_str.length ());
634 stream << "_params structure ";
636 stream << indent_str;
637 stream << " * to their default values";
639 stream << indent_str;
642 stream << "param params the structure to initialize";
644 stream << indent_str;
647 stream << indent_str;
649 generate_string (parser_name, stream, indent + indent_str.length ());
650 stream << "_params_init(struct ";
651 generate_string (parser_name, stream, indent + indent_str.length ());
652 stream << "_params *params);";
654 stream << indent_str;
656 stream << indent_str;
659 stream << indent_str;
660 stream << " * Allocates dynamically a ";
661 generate_string (parser_name, stream, indent + indent_str.length ());
662 stream << "_params structure and initializes";
664 stream << indent_str;
665 stream << " * all its fields to their default values";
667 stream << indent_str;
670 stream << "return the created and initialized ";
671 generate_string (parser_name, stream, indent + indent_str.length ());
672 stream << "_params structure";
674 stream << indent_str;
677 stream << indent_str;
679 generate_string (parser_name, stream, indent + indent_str.length ());
680 stream << "_params *";
681 generate_string (parser_name, stream, indent + indent_str.length ());
682 stream << "_params_create(void);";
684 stream << indent_str;
686 stream << indent_str;
689 stream << indent_str;
690 stream << " * Initializes the passed ";
691 generate_string (args_info, stream, indent + indent_str.length ());
692 stream << " structure's fields";
694 stream << indent_str;
695 stream << " * (also set default values for options that have a default)";
697 stream << indent_str;
700 stream << "param args_info the structure to initialize";
702 stream << indent_str;
705 stream << indent_str;
707 generate_string (parser_name, stream, indent + indent_str.length ());
708 stream << "_init (struct ";
709 generate_string (args_info, stream, indent + indent_str.length ());
710 stream << " *args_info);";
712 stream << indent_str;
715 stream << indent_str;
716 stream << " * Deallocates the string fields of the ";
717 generate_string (args_info, stream, indent + indent_str.length ());
718 stream << " structure";
720 stream << indent_str;
721 stream << " * (but does not deallocate the structure itself)";
723 stream << indent_str;
726 stream << "param args_info the structure to deallocate";
728 stream << indent_str;
731 stream << indent_str;
733 generate_string (parser_name, stream, indent + indent_str.length ());
734 stream << "_free (struct ";
735 generate_string (args_info, stream, indent + indent_str.length ());
736 stream << " *args_info);";
738 stream << indent_str;
740 stream << indent_str;
741 if (generate_config_parser)
745 stream << indent_str;
746 stream << " * The config file parser (deprecated version)";
748 stream << indent_str;
751 stream << "param filename the name of the config file";
753 stream << indent_str;
756 stream << "param args_info the structure where option information will be stored";
758 stream << indent_str;
761 stream << "param override whether to override possibly already present options";
763 stream << indent_str;
766 stream << "param initialize whether to initialize the option structure my_args_info";
768 stream << indent_str;
771 stream << "param check_required whether to check that all required options were provided";
773 stream << indent_str;
776 stream << "return 0 if everything went fine, NON 0 if an error took place";
778 stream << indent_str;
781 stream << "deprecated use ";
782 generate_string (parser_name, stream, indent + indent_str.length ());
783 stream << "_config_file() instead";
785 stream << indent_str;
788 stream << indent_str;
790 generate_string (parser_name, stream, indent + indent_str.length ());
791 stream << "_configfile (const char *filename,";
793 stream << indent_str;
794 stream << " struct ";
795 generate_string (args_info, stream, indent + indent_str.length ());
796 stream << " *args_info,";
798 stream << indent_str;
799 stream << " int override, int initialize, int check_required);";
801 stream << indent_str;
803 stream << indent_str;
806 stream << indent_str;
807 stream << " * The config file parser";
809 stream << indent_str;
812 stream << "param filename the name of the config file";
814 stream << indent_str;
817 stream << "param args_info the structure where option information will be stored";
819 stream << indent_str;
822 stream << "param params additional parameters for the parser";
824 stream << indent_str;
827 stream << "return 0 if everything went fine, NON 0 if an error took place";
829 stream << indent_str;
832 stream << indent_str;
834 generate_string (parser_name, stream, indent + indent_str.length ());
835 stream << "_config_file (const char *filename,";
837 stream << indent_str;
838 stream << " struct ";
839 generate_string (args_info, stream, indent + indent_str.length ());
840 stream << " *args_info,";
842 stream << indent_str;
843 stream << " struct ";
844 generate_string (parser_name, stream, indent + indent_str.length ());
845 stream << "_params *params);";
847 stream << indent_str;
849 stream << indent_str;
851 if (generate_string_parser)
855 stream << indent_str;
856 stream << " * The string parser (interprets the passed string as a command line)";
858 stream << indent_str;
861 stream << "param cmdline the command line stirng";
863 stream << indent_str;
866 stream << "param args_info the structure where option information will be stored";
868 stream << indent_str;
871 stream << "param prog_name the name of the program that will be used to print";
873 stream << indent_str;
874 stream << " * possible errors";
876 stream << indent_str;
879 stream << "return 0 if everything went fine, NON 0 if an error took place";
881 stream << indent_str;
884 stream << indent_str;
886 generate_string (parser_name, stream, indent + indent_str.length ());
887 stream << "_string (const char *cmdline, struct ";
888 generate_string (args_info, stream, indent + indent_str.length ());
889 stream << " *args_info,";
891 stream << indent_str;
892 stream << " const char *prog_name);";
894 stream << indent_str;
897 stream << indent_str;
898 stream << " * The string parser (version with additional parameters - deprecated)";
900 stream << indent_str;
903 stream << "param cmdline the command line stirng";
905 stream << indent_str;
908 stream << "param args_info the structure where option information will be stored";
910 stream << indent_str;
913 stream << "param prog_name the name of the program that will be used to print";
915 stream << indent_str;
916 stream << " * possible errors";
918 stream << indent_str;
921 stream << "param override whether to override possibly already present options";
923 stream << indent_str;
926 stream << "param initialize whether to initialize the option structure my_args_info";
928 stream << indent_str;
931 stream << "param check_required whether to check that all required options were provided";
933 stream << indent_str;
936 stream << "return 0 if everything went fine, NON 0 if an error took place";
938 stream << indent_str;
941 stream << "deprecated use ";
942 generate_string (parser_name, stream, indent + indent_str.length ());
943 stream << "_string_ext() instead";
945 stream << indent_str;
948 stream << indent_str;
950 generate_string (parser_name, stream, indent + indent_str.length ());
951 stream << "_string2 (const char *cmdline, struct ";
952 generate_string (args_info, stream, indent + indent_str.length ());
953 stream << " *args_info,";
955 stream << indent_str;
956 stream << " const char *prog_name,";
958 stream << indent_str;
959 stream << " int override, int initialize, int check_required);";
961 stream << indent_str;
964 stream << indent_str;
965 stream << " * The string parser (version with additional parameters)";
967 stream << indent_str;
970 stream << "param cmdline the command line stirng";
972 stream << indent_str;
975 stream << "param args_info the structure where option information will be stored";
977 stream << indent_str;
980 stream << "param prog_name the name of the program that will be used to print";
982 stream << indent_str;
983 stream << " * possible errors";
985 stream << indent_str;
988 stream << "param params additional parameters for the parser";
990 stream << indent_str;
993 stream << "return 0 if everything went fine, NON 0 if an error took place";
995 stream << indent_str;
998 stream << indent_str;
1000 generate_string (parser_name, stream, indent + indent_str.length ());
1001 stream << "_string_ext (const char *cmdline, struct ";
1002 generate_string (args_info, stream, indent + indent_str.length ());
1003 stream << " *args_info,";
1005 stream << indent_str;
1006 stream << " const char *prog_name,";
1008 stream << indent_str;
1009 stream << " struct ";
1010 generate_string (parser_name, stream, indent + indent_str.length ());
1011 stream << "_params *params);";
1013 stream << indent_str;
1015 stream << indent_str;
1019 stream << indent_str;
1020 stream << " * Checks that all the required options were specified";
1022 stream << indent_str;
1025 stream << "param args_info the structure to check";
1027 stream << indent_str;
1030 stream << "param prog_name the name of the program that will be used to print";
1032 stream << indent_str;
1033 stream << " * possible errors";
1035 stream << indent_str;
1040 stream << indent_str;
1043 stream << indent_str;
1045 generate_string (parser_name, stream, indent + indent_str.length ());
1046 stream << "_required (struct ";
1047 generate_string (args_info, stream, indent + indent_str.length ());
1048 stream << " *args_info,";
1050 stream << indent_str;
1051 stream << " const char *prog_name);";
1053 stream << indent_str;
1055 stream << indent_str;
1056 if (option_values_decl.size () > 0)
1057 generate_string (option_values_decl, stream, indent + indent_str.length ());
1059 generate_option_values_decl (stream, indent + indent_str.length ());
1060 stream << indent_str;
1062 stream << indent_str;
1063 stream << "#ifdef __cplusplus";
1065 stream << indent_str;
1068 stream << indent_str;
1069 stream << "#endif /* __cplusplus */";
1071 stream << indent_str;
1072 stream << "#endif /* ";
1073 generate_string (ifndefname, stream, indent + indent_str.length ());
1076 stream << indent_str;