29 lines
523 B
C++
29 lines
523 B
C++
#ifndef CMDLINEPARSER_H
|
|
#define CMDLINEPARSER_H
|
|
#include <map>
|
|
#include <string>
|
|
#include <getopt.h>
|
|
using namespace std;
|
|
|
|
typedef struct {
|
|
string name;
|
|
int shortName;
|
|
int needParam;
|
|
string desc;
|
|
} OptDefine;
|
|
|
|
class CmdLineParser
|
|
{
|
|
public:
|
|
CmdLineParser();
|
|
void regOpt(OptDefine optdef);
|
|
string getOpt(string key);
|
|
void parseArgs(int argc, char *argv[]);
|
|
private:
|
|
map<int, OptDefine> optMap;
|
|
map<string, string> paraMap;
|
|
bool hasOptSet(string key);
|
|
};
|
|
|
|
#endif // CMDLINEPARSER_H
|