Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
argparser.h
Go to the documentation of this file.
1
7#ifndef ARGPARSER_H_INCLUDED
8#define ARGPARSER_H_INCLUDED
9#include <map>
10#include <string>
11#include <vector>
12
13namespace Binc {
14 class ArgOpts {
15 public:
16 std::string c;
17 bool b;
18 bool o;
19 std::string desc;
20
21 inline ArgOpts(const std::string &chr, bool boolean, bool optional,
22 const std::string &descr)
23 {
24 c = chr;
25 b = boolean;
26 o = optional;
27 desc = descr;
28 }
29 };
30
32 public:
33 CommandLineArgs(void);
34
35 bool parse(int argc, char *argv[]);
36 std::string errorString(void) const;
37
38 int argc(void) const;
39
40 const std::string operator [](const std::string &arg) const;
41
42 void addOptional(const std::string &arg, const std::string &desc,
43 bool boolean);
44 void addRequired(const std::string &arg, const std::string &desc,
45 bool boolean);
46 bool hasArg(const std::string &arg) const;
47
48 std::string usageString(void) const;
49
50 void setTail(const std::string &str);
51
52 const std::vector<std::string> &getUnqualifiedArgs() const;
53
54 private:
55 void registerArg(const std::string &arg, const std::string &desc,
56 bool boolean, bool optional);
57
58 std::string errString;
59 std::map<std::string, ArgOpts> reg;
60 std::map<std::string, std::string> args;
61 std::map<std::string, bool> passedArgs;
62 std::vector<std::string> unqualified;
63 std::string tail;
64 std::string head;
65 int ac;
66 };
67}
68
69#endif
std::string c
Definition: argparser.h:16
std::string desc
Definition: argparser.h:19
ArgOpts(const std::string &chr, bool boolean, bool optional, const std::string &descr)
Definition: argparser.h:21
void setTail(const std::string &str)
Definition: argparser.cc:313
const std::string operator[](const std::string &arg) const
Definition: argparser.cc:217
void addRequired(const std::string &arg, const std::string &desc, bool boolean)
Definition: argparser.cc:231
std::string usageString(void) const
Definition: argparser.cc:260
bool hasArg(const std::string &arg) const
Definition: argparser.cc:253
bool parse(int argc, char *argv[])
Definition: argparser.cc:24
std::string errorString(void) const
Definition: argparser.cc:211
const std::vector< std::string > & getUnqualifiedArgs() const
Definition: argparser.cc:319
int argc(void) const
Definition: argparser.cc:307
void addOptional(const std::string &arg, const std::string &desc, bool boolean)
Definition: argparser.cc:224
Definition: bincimapd.cc:9