1 #ifndef ARGUMENT_READER_H
2 #define ARGUMENT_READER_H
10 *\brief Hachti's even more wonderful configuration manager.
12 * This class is designed to do all the work with the parameters passed to
13 * the main() routine of a program.\n
14 * Additionally, it is able to interpret configuration files.
16 * - Create an instance.
17 * - Add Parameters/switches with add_option_*().
18 * - Add Arguments with add_argument().
19 * - Call read_args() with your main routine's arguments.
20 * The vector returned by read_args() contains all error
21 * messages. When it's empty, everything is fine!
22 * - Call get_help() if you want nice formatted help output.
24 * Sould be easy to use....
26 class configuration_manager{
30 *\brief Container for an option switch
34 opt_switch_t (const string & shortname,
35 const string & longname,
36 const string & description,
38 const bool & allow_commandline=true,
39 const bool & allow_config_file=true);
51 *\brief Container for an option value
55 opt_value_t (const string & shortname,
56 const string & longname,
57 const string & description,
60 const string & placeholder=string("<string>"),
61 const bool & allow_commandline=true,
62 const bool & allow_config_file=true);
74 *\brief Container for a commandline argument
78 cmd_arg_t (const string & placeholder,
79 const string & description,
90 configuration_manager(string name);
92 void add_option_value (const string & shortname,
93 const string & longname,
94 const string & description,
97 const string & placeholder=string("<string>"),
98 const bool & allow_commandline=true,
99 const bool & allow_config_file=true
102 void add_option_switch (const string & shortname,
103 const string & longname,
104 const string & description,
106 const bool & allow_commandline=true,
107 const bool & allow_config_file=true
110 void add_argument (const string & description,
113 const string & placeholder=string("<string>")
116 vector<string> read_args(int argc, char ** args);
117 vector<string> read_file(string filename);
119 void get_help (vector<string> & target);
120 vector<string> get_help();
122 protected: // members
123 vector<opt_switch_t>option_switches;
124 vector<opt_value_t>option_values;
125 vector<cmd_arg_t>cmd_args;
128 protected: // methods
129 string analyse_string(const string & line);
130 bool analyse_bool(const string & data);
131 bool analyse_bool_false(const string & data);
132 }; // class configuration_manager