X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;f=pc-tools%2Fldc2%2Fsrc%2Fconfiguration_manager.hh;fp=pc-tools%2Fldc2%2Fsrc%2Fconfiguration_manager.hh;h=d88d3dd7959bad57227dbe6f4a37d959d2d78d14;hb=ad324d29d885b9af1608a6e9c1f978bdcd202eb7;hp=0000000000000000000000000000000000000000;hpb=290011d228d5b323d61c77542a8761dfa69b034b;p=h316.git diff --git a/pc-tools/ldc2/src/configuration_manager.hh b/pc-tools/ldc2/src/configuration_manager.hh new file mode 100644 index 0000000..d88d3dd --- /dev/null +++ b/pc-tools/ldc2/src/configuration_manager.hh @@ -0,0 +1,80 @@ +#ifndef ARGUMENT_READER_H +#define ARGUMENT_READER_H + +#include +#include + +using namespace std; + +/*! + *\brief Hachti's wonderful commandline parser. + * + * This class is designed to do all the work with the parameters passed to + * the main() routine of a program.\n + * Usage:\n + * - Create an instance. + * - Add Parameters/switches with add_param(). + * - Add Arguments with add_argument(). + * - Call read_args() with your main routine's arguments. + * The vector returned by read_args() contains all error + * messages. When it's empty, everything is fine! + * - Call get_help() if you want nice formatted help output. + * (You want!!!) + * Sould be easy to use..... Enjoy. + */ +class argument_reader{ + +public: + argument_reader(string name); + + void add_param (string shortname, + string longname, + string description, + int *status, + string *target=NULL, + string placeholder=string("") + ); + + vector read_args(int argc, char ** args); + + void get_help(vector & target); + vector get_help(); + + void add_argument(string placeholder, string description, int * status, string * target); + +private: + /*! + *\brief Container for one command line option. + */ + class opt_t{ + public: + opt_t (string shortname, string longname,string description, int * status, + string * target=NULL, string placeholder=string("")); + string shortname; + string longname; + int * status; + string * target; + string description; + string placeholder; + }; + + /*! + *\brief Container for one command line argument. + */ + class arg_t{ + public: + arg_t (string placeholder,string description, + int * status, string * target); + int * status; + string * target; + string description; + string placeholder; + }; + vectoropt_v; + vectorarg_v; + string app_name; + +}; // class argument_reader + + +#endif