blob: e67a87730826cf0345867ebae484c208126b3302 [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
Nan Zhoue1289ad2021-12-28 11:02:56 -08008namespace phosphor::certs::util
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -05009{
10
11/**
12 * @brief Class - Encapsulates parsing command line options and
13 * populating arguments.
14 */
15class ArgumentParser
16{
17 public:
18 ArgumentParser(int argc, char** argv);
19 ArgumentParser() = delete;
20 ArgumentParser(const ArgumentParser&) = delete;
21 ArgumentParser(ArgumentParser&&) = default;
22 ArgumentParser& operator=(const ArgumentParser&) = delete;
23 ArgumentParser& operator=(ArgumentParser&&) = default;
24 ~ArgumentParser() = default;
25 const std::string& operator[](const std::string& opt);
26
27 static void usage(char** argv);
28
29 static const std::string true_string;
30 static const std::string empty_string;
31
32 private:
33 std::map<const std::string, std::string> arguments;
34
35 static const option options[];
36 static const char* optionstr;
37};
38
Nan Zhoue1289ad2021-12-28 11:02:56 -080039} // namespace phosphor::certs::util