File: header.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 (194 lines) | stat: -rw-r--r-- 5,478 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
/*
 * File automatically generated by
 * gengen 1.4.2 by Lorenzo Bettini 
 * http://www.gnu.org/software/gengen
 */

#ifndef HEADER_GEN_CLASS_H
#define HEADER_GEN_CLASS_H

#include <string>
#include <iostream>

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

class header_gen_class
{
 protected:
  string args_info;
  string enum_types;
  bool generate_config_parser;
  bool generate_string_parser;
  string generator_version;
  string group_counters;
  bool has_details;
  bool has_hidden;
  string header_file_ext;
  string header_file_name;
  string ifndefname;
  string mode_counters;
  string option_arg;
  string option_given;
  string option_values_decl;
  string package_var_name;
  string package_var_val;
  string parser_name;
  string version_var_name;
  string version_var_val;

 public:
  header_gen_class() :
    generate_config_parser (false), generate_string_parser (false), has_details (false), has_hidden (false)
  {
  }
  
  header_gen_class(const string &_args_info, const string &_enum_types, bool _generate_config_parser, bool _generate_string_parser, const string &_generator_version, const string &_group_counters, bool _has_details, bool _has_hidden, const string &_header_file_ext, const string &_header_file_name, const string &_ifndefname, const string &_mode_counters, const string &_option_arg, const string &_option_given, const string &_option_values_decl, const string &_package_var_name, const string &_package_var_val, const string &_parser_name, const string &_version_var_name, const string &_version_var_val) :
    args_info (_args_info), enum_types (_enum_types), generate_config_parser (_generate_config_parser), generate_string_parser (_generate_string_parser), generator_version (_generator_version), group_counters (_group_counters), has_details (_has_details), has_hidden (_has_hidden), header_file_ext (_header_file_ext), header_file_name (_header_file_name), ifndefname (_ifndefname), mode_counters (_mode_counters), option_arg (_option_arg), option_given (_option_given), option_values_decl (_option_values_decl), package_var_name (_package_var_name), package_var_val (_package_var_val), parser_name (_parser_name), version_var_name (_version_var_name), version_var_val (_version_var_val)
  {
  }

  virtual ~header_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_enum_types(ostream &stream, unsigned int indent) = 0;

  void set_enum_types(const string &_enum_types)
  {
    enum_types = _enum_types;
  }

  void set_generate_config_parser(bool _generate_config_parser)
  {
    generate_config_parser = _generate_config_parser;
  }

  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;
  }

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

  void set_group_counters(const string &_group_counters)
  {
    group_counters = _group_counters;
  }

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

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

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

  void set_header_file_name(const string &_header_file_name)
  {
    header_file_name = _header_file_name;
  }

  void set_ifndefname(const string &_ifndefname)
  {
    ifndefname = _ifndefname;
  }

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

  void set_mode_counters(const string &_mode_counters)
  {
    mode_counters = _mode_counters;
  }

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

  void set_option_arg(const string &_option_arg)
  {
    option_arg = _option_arg;
  }

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

  void set_option_given(const string &_option_given)
  {
    option_given = _option_given;
  }

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

  void set_option_values_decl(const string &_option_values_decl)
  {
    option_values_decl = _option_values_decl;
  }

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

  void set_package_var_val(const string &_package_var_val)
  {
    package_var_val = _package_var_val;
  }

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

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

  void set_version_var_val(const string &_version_var_val)
  {
    version_var_val = _version_var_val;
  }

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

#endif // HEADER_GEN_CLASS_H