Pakman
LongOptions.h
1 #ifndef LONGOPTIONS_H
2 #define LONGOPTIONS_H
3 
4 #include <string>
5 #include <vector>
6 #include <unordered_set>
7 #include <unordered_map>
8 
9 #include <getopt.h>
10 
21 {
22  public:
23 
29  LongOptions();
30 
32  ~LongOptions() = default;
33 
38  void add(struct option long_opt);
39 
41  const struct option* getLongOpts() const;
42 
44  const char* getShortOpts() const;
45 
52  std::string getLongOptionName(char short_option) const;
53 
54  private:
55 
56  // Vector of long option structs
57  std::vector<struct option> m_long_opts;
58  std::unordered_set<std::string> m_long_opts_set;
59 
60  // Vector of short option chars
61  std::vector<char> m_short_opts;
62  std::unordered_set<int> m_short_opts_set;
63 
64  // Unordered map of short option char to long option string
65  std::unordered_map<char, std::string> m_short_to_long_map;
66 };
67 
68 #endif // LONGOPTIONS_H
std::string getLongOptionName(char short_option) const
Definition: LongOptions.cc:82
const char * getShortOpts() const
Definition: LongOptions.cc:77
~LongOptions()=default
void add(struct option long_opt)
Definition: LongOptions.cc:20
const struct option * getLongOpts() const
Definition: LongOptions.cc:71