X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;ds=sidebyside;f=pc-tools%2Fldc2%2Fsrc%2Fconfiguration_manager.hh;h=60a215d05725523ae350b870b1d5827b1813d01f;hb=909d36034504f2511a5bc4ef7e50d407964e247a;hp=ffd77218a361074c40f832b325044858d20b9b6e;hpb=34ce17ffec005c5cca84304997e9ccfb6a3f593e;p=h316.git diff --git a/pc-tools/ldc2/src/configuration_manager.hh b/pc-tools/ldc2/src/configuration_manager.hh index ffd7721..60a215d 100644 --- a/pc-tools/ldc2/src/configuration_manager.hh +++ b/pc-tools/ldc2/src/configuration_manager.hh @@ -14,102 +14,122 @@ using namespace std; * Additionally, it is able to interpret configuration files. * Usage:\n * - Create an instance. - * - Add Parameters/switches with add_param(). + * - Add Parameters/switches with add_option_*(). * - 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. + * Sould be easy to use.... */ class configuration_manager{ -public: - configuration_manager(string name); - - void add_option_switch (string shortname, - string longname, - string description, - int *status, - bool allow_commandline=true, - bool allow_config_file=true - ); - - void add_option_value (string shortname, - string longname, - string description, - int *status, - bool allow_commandline=true, - bool allow_config_file=true, - string *target=NULL, - string placeholder=string("") - ); - - void add_argument (string longname, - string description, - int *status, - string *target=NULL, - string placeholder=string("") - ); - - vector read_args(int argc, char ** args); - vector read_file(string filename); - - void get_help (vector & target); - vector get_help(); - -private: +protected: // Types /*! *\brief Container for an option switch */ - class opt_switch_t{ + class opt_switch_t{ public: - opt_switch_t (string shortname, string longname,string description, int * status - string * target=NULL, string placeholder=string("")); + opt_switch_t (const string & shortname, + const string & longname, + const string & description, + int * status, + const bool & allow_commandline=true, + const bool & allow_config_file=true); string shortname; string longname; int * status; string * target; string description; string placeholder; + bool allow_conffile; + bool allow_cmdline; }; + /*! *\brief Container for an option value */ -class opt_value_t{ + class opt_value_t{ public: - switch_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; - bool allow_conffile; - bool allow_cmdline; -}; - + opt_value_t (const string & shortname, + const string & longname, + const string & description, + int * status, + string * target, + const string & placeholder=string(""), + const bool & allow_commandline=true, + const bool & allow_config_file=true); + string shortname; + string longname; + int * status; + string * target; + string description; + string placeholder; + bool allow_conffile; + bool allow_cmdline; + }; + /*! *\brief Container for a commandline argument */ class cmd_arg_t{ public: - arg_t (string placeholder,string description, - int * status, string * target); + cmd_arg_t (const string & placeholder, + const string & description, + int * status, + string * target); int * status; string * target; string description; string placeholder; }; +public: // Methods + + configuration_manager(string name); + + void add_option_value (const string & shortname, + const string & longname, + const string & description, + int *status, + string *target=NULL, + const string & placeholder=string(""), + const bool & allow_commandline=true, + const bool & allow_config_file=true + ); + + void add_option_switch (const string & shortname, + const string & longname, + const string & description, + int *status, + const bool & allow_commandline=true, + const bool & allow_config_file=true + ); + + void add_argument (const string & description, + int *status, + string *target=NULL, + const string & placeholder=string("") + ); + + vector read_args(int argc, char ** args); + vector read_file(string filename); + + void get_help (vector & target); + vector get_help(); + +protected: // members vectoroption_switches; vectoroption_values; vectorcmd_args; string app_name; +protected: // methods + string analyse_string(const string & line); + bool analyse_bool(const string & data); }; // class configuration_manager #endif +