00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _C_COMMANDLINE_H_
00021 #define _C_COMMANDLINE_H_
00022
00023 #include "Utils.hpp"
00024
00025 template <class T_TIndexCommand>
00026 class C_CommandLine {
00027
00028 public:
00029
00030 enum T_option_type {
00031 E_OT_MANDATORY,
00032 E_OT_OPTIONAL } ;
00033
00034 enum T_value_type {
00035 E_VT_INTEGER,
00036 E_VT_OCTET_HEXA,
00037 E_VT_STRING } ;
00038
00039 typedef struct _command_option {
00040 T_TIndexCommand index ;
00041 char *name ;
00042 T_option_type option_type ;
00043 int nb_values ;
00044 T_value_type *values_types ;
00045 char *param_comment ;
00046 char *comments ;
00047 } T_command_option ;
00048
00049 typedef struct _command_line {
00050 int nb_options ;
00051 T_TIndexCommand help_index ;
00052 T_command_option *command_options ;
00053 } T_command_line ;
00054
00055 public:
00056
00057 int startAnalyzeCommandLine (int argc,
00058 char **argv,
00059 T_command_line *) ;
00060 void usage (void) ;
00061
00062 C_CommandLine () ;
00063 virtual ~C_CommandLine () ;
00064
00065 virtual bool set_data (T_TIndexCommand, char**) = 0 ;
00066
00067
00068 private:
00069
00070 char *f_programName ;
00071 T_command_line *f_command_description ;
00072 bool *f_option_flags ;
00073 bool f_noHelpIndex ;
00074 int f_internalHelpCode ;
00075
00076
00077 void AnalyzeCommandLine (int argc, char **argv);
00078 int SearchForOption (char *pattern) ;
00079 bool VerifyMandatoryArgs () ;
00080 bool VerifyOptionValues (int opt, int idx, char **argv);
00081 int SearchForOption (T_TIndexCommand idxCmd) ;
00082
00083 int integer_ok (char *name);
00084 int octet_hexa_ok (char *name);
00085
00086
00087
00088 } ;
00089
00090 #endif // _C_COMMANDLINE_H_
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101