hkstreamer/include/cmdlineparser.h

34 lines
676 B
C
Raw Normal View History

2023-03-30 23:44:03 +08:00
#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:
2023-03-31 18:32:46 +08:00
CmdLineParser(string name,string desc);
2023-03-30 23:44:03 +08:00
void regOpt(OptDefine optdef);
2023-03-31 18:32:46 +08:00
void regOpt(string name,int shorName, int needParam, string desc);
2023-03-30 23:44:03 +08:00
string getOpt(string key);
void parseArgs(int argc, char *argv[]);
void help();
2023-03-30 23:44:03 +08:00
private:
2023-03-31 18:32:46 +08:00
string appName;
string appDesc;
2023-03-30 23:44:03 +08:00
map<int, OptDefine> optMap;
map<string, string> paraMap;
bool hasOptSet(string key);
2023-03-30 23:44:03 +08:00
};
#endif // CMDLINEPARSER_H