1 /******************************************************************************
5 * $Date: 2007/03/26 01:00:38 $
8 * $Log: configuration_manager.hh,v $
9 * Revision 2.0 2007/03/26 01:00:38 hachti
10 * *** empty log message ***
13 ******************************************************************************/
15 #ifndef ARGUMENT_READER_H
16 #define ARGUMENT_READER_H
24 *\brief Hachti's even more wonderful configuration manager.
26 * This class is designed to do all the work with the parameters passed to
27 * the main() routine of a program.\n
28 * Additionally, it is able to interpret configuration files.
30 * - Create an instance.
31 * - Add Parameters/switches with add_option_*().
32 * - Add Arguments with add_argument().
33 * - Call read_args() with your main routine's arguments.
34 * The vector returned by read_args() contains all error
35 * messages. When it's empty, everything is fine!
36 * - Call get_help() if you want nice formatted help output.
38 * Sould be easy to use....
40 class configuration_manager{
44 *\brief Container for an option switch
48 opt_switch_t (const string & shortname,
49 const string & longname,
50 const string & description,
52 const bool & allow_commandline=true,
53 const bool & allow_config_file=true);
65 *\brief Container for an option value
69 opt_value_t (const string & shortname,
70 const string & longname,
71 const string & description,
74 const string & placeholder=string("<string>"),
75 const bool & allow_commandline=true,
76 const bool & allow_config_file=true);
88 *\brief Container for a commandline argument
92 cmd_arg_t (const string & placeholder,
93 const string & description,
104 configuration_manager(string name);
106 void add_option_value (const string & shortname,
107 const string & longname,
108 const string & description,
111 const string & placeholder=string("<string>"),
112 const bool & allow_commandline=true,
113 const bool & allow_config_file=true
116 void add_option_switch (const string & shortname,
117 const string & longname,
118 const string & description,
120 const bool & allow_commandline=true,
121 const bool & allow_config_file=true
124 void add_argument (const string & description,
127 const string & placeholder=string("<string>")
130 vector<string> read_args(int argc, char ** args);
131 vector<string> read_file(string filename);
133 void get_help (vector<string> & target);
134 vector<string> get_help();
136 protected: // members
137 vector<opt_switch_t>option_switches;
138 vector<opt_value_t>option_values;
139 vector<cmd_arg_t>cmd_args;
142 protected: // methods
143 string analyse_string(const string & line);
144 bool analyse_bool(const string & data);
145 bool analyse_bool_false(const string & data);
146 }; // class configuration_manager