00001 #ifndef COMMAND_LINE_CLASS
00002 #define COMMAND_LINE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00037 #include "opsysdll.h"
00038
00039 #include <basis/object_base.h>
00040
00041
00042 class filename;
00043 class internal_cmd_line_array_of_parms;
00044
00046
00047 class OPSYSTEM_CLASS_STYLE command_parameter
00048 : public virtual object_base
00049 {
00050 public:
00051 enum parameter_types { VALUE, CHAR_FLAG, STRING_FLAG, BOGUS_ITEM };
00052
00053 command_parameter(parameter_types type = BOGUS_ITEM);
00055
00056 command_parameter(parameter_types type, const istring &text);
00058
00061 command_parameter(const command_parameter &to_copy);
00062
00063 ~command_parameter();
00064
00065 IMPLEMENT_CLASS_NAME("command_parameter");
00066
00067 command_parameter &operator =(const command_parameter &to_copy);
00068
00069 inline parameter_types type() const { return _type; }
00071 inline void type(parameter_types new_type) { _type = new_type; }
00073
00074 const istring &text() const;
00076 void text(const istring &new_text);
00078
00079 private:
00080 parameter_types _type;
00081 istring *_text;
00082 };
00083
00085
00086 class OPSYSTEM_CLASS_STYLE command_line
00087 {
00088 public:
00089 command_line(int argc, char *argv[]);
00091
00096 command_line(const istring &to_parse);
00098
00103 virtual ~command_line();
00104
00105 IMPLEMENT_CLASS_NAME("command_line");
00106
00107 filename program_name() const;
00109
00110 static void separate_command_line(const istring &cmd_line, istring &app,
00111 istring &parms);
00113
00121 int entries() const;
00123
00126 const command_parameter &get(int field) const;
00128
00131 bool zap(int field);
00133
00136
00137
00138
00139
00140 bool find(char option_character, int &index, bool case_sense = true) const;
00142
00145 bool find(const istring &option_string, int &index,
00146 bool case_sense = true) const;
00148
00149 bool get_value(char option_character, istring &value,
00150 bool case_sense = true) const;
00152
00157 bool get_value(const istring &option_string, istring &value,
00158 bool case_sense = true) const;
00160
00161
00162
00163
00164 istring gather(int &index) const;
00166
00176 istring text_form() const;
00178
00179 static string_array get_command_line();
00181
00185 private:
00186 internal_cmd_line_array_of_parms *_implementation;
00187 filename *_program_name;
00188
00189 void parse_string_array(const string_array &to_parse);
00191
00192
00193 command_line(const command_line &to_copy);
00194 command_line &operator =(const command_line &to_copy);
00195
00196 static const command_parameter &cmdline_blank_parm();
00197 };
00198
00199 #endif
00200