00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined EC_CMD_ARGS_HPP
00023 #define EC_CMD_ARGS_HPP
00024
00025 #include <vector>
00026 #include <string>
00027 #include <istream>
00028 #include <sstream>
00029 #include <assert.h>
00030
00031 namespace eqn_cruncher
00032 {
00033
00034
00035 class arg_stream
00036 {
00037 std::vector<std::string> arg_list;
00038 int index;
00039
00040 public:
00041 arg_stream(int nargs, char** args)
00042 : arg_list(args + 1, args + nargs)
00043 { }
00044
00045 int
00046 num_args() const { return arg_list.size(); }
00047
00048 void
00049 set_index(int i)
00050 {
00051 assert(i < (int)arg_list.size());
00052 this->index = i;
00053 }
00054
00055 int
00056 contains(std::string const& sarg) const;
00057
00058 friend
00059 arg_stream&
00060 operator>>(arg_stream& in, int& i);
00061
00062 friend
00063 arg_stream&
00064 operator>>(arg_stream& in, unsigned int& i);
00065
00066 friend
00067 arg_stream&
00068 operator>>(arg_stream& in, char& ch);
00069
00070 friend
00071 arg_stream&
00072 operator>>(arg_stream& in, std::string& str);
00073 };
00074 }
00075
00076
00077 #endif // EC_CMD_ARGS_HPP