34 lines
676 B
C++
34 lines
676 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(string name,string desc);
|
|
void regOpt(OptDefine optdef);
|
|
void regOpt(string name,int shorName, int needParam, string desc);
|
|
string getOpt(string key);
|
|
void parseArgs(int argc, char *argv[]);
|
|
void help();
|
|
private:
|
|
string appName;
|
|
string appDesc;
|
|
map<int, OptDefine> optMap;
|
|
map<string, string> paraMap;
|
|
bool hasOptSet(string key);
|
|
|
|
};
|
|
|
|
#endif // CMDLINEPARSER_H
|