X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;f=pc-tools%2Fldc2%2Fsrc%2Fargread.hh;fp=pc-tools%2Fldc2%2Fsrc%2Fargread.hh;h=7cd3aff8f3b05f455c5f267c050e8141491d918e;hb=798b0c1d967a7d8ac3c7a867d41bfa7b8e824048;hp=0000000000000000000000000000000000000000;hpb=f9d603d2bcbb512a77339091029f2eb1e0fd261f;p=h316.git diff --git a/pc-tools/ldc2/src/argread.hh b/pc-tools/ldc2/src/argread.hh new file mode 100644 index 0000000..7cd3aff --- /dev/null +++ b/pc-tools/ldc2/src/argread.hh @@ -0,0 +1,76 @@ +#ifndef ARGREAD_H +#define ARGREAD_H + +#include +#include + +using namespace std; + +#ifndef NULL +#define NULL (void*)0 +#endif + +class argreader{ +public: + argreader(string n_name); + + /*! + *\brief add a parameter to be looked for + *\param shortname A character for the short form. For example the 'h' in -h + *\param longname The double dash longname. For example 'input_file=' in --input_file= or + * 'ignore_errors' in --ignore--errors + *\param description A parameter description. + *\param status Pointer to an integer. Will be set to 1 if arg found. + *\target Pointer to a value should be read. If no value is needed, pass NULL. + *\placeholder A placeholder for the documentation. For example "" in -f + */ + void add_param (string shortname, string longname, string description, int * status, + string * target=NULL, string placeholder=string("")); + + /*! + * Read in the args passed to main(). + *\returns empty vector on success or the error messages to be output. + */ + vector read_args(int argc, char ** args); + + + vector & get_free_args(); + + void get_help(vector & ); + vector get_help(); + + void add_free_param(string placeholder, string description, int * status, string * target); + + + +private: + class parameter{ + public: + parameter (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; + }; + + class free_parameter{ + public: + free_parameter (string placeholder,string description, + int * status, string * target); + int * status; + string * target; + string description; + string placeholder; + }; + + vectorarguments; + vectorfree_arguments; + + string progname; +}; + + +#endif