blob: af5ac4691705bf588b3aabb3634a761120155371 [file] [log] [blame]
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -05001#pragma once
2
3#include <getopt.h>
4
5#include <map>
6#include <string>
7
8namespace phosphor
9{
10namespace certs
11{
12namespace util
13{
14
15/**
16 * @brief Class - Encapsulates parsing command line options and
17 * populating arguments.
18 */
19class ArgumentParser
20{
21 public:
22 ArgumentParser(int argc, char** argv);
23 ArgumentParser() = delete;
24 ArgumentParser(const ArgumentParser&) = delete;
25 ArgumentParser(ArgumentParser&&) = default;
26 ArgumentParser& operator=(const ArgumentParser&) = delete;
27 ArgumentParser& operator=(ArgumentParser&&) = default;
28 ~ArgumentParser() = default;
29 const std::string& operator[](const std::string& opt);
30
31 static void usage(char** argv);
32
33 static const std::string true_string;
34 static const std::string empty_string;
35
36 private:
37 std::map<const std::string, std::string> arguments;
38
39 static const option options[];
40 static const char* optionstr;
41};
42
43} // namespace util
44} // namespace certs
45} // namespace phosphor