Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <getopt.h> |
| 4 | |
| 5 | #include <map> |
| 6 | #include <string> |
| 7 | |
Nan Zhou | e1289ad | 2021-12-28 11:02:56 -0800 | [diff] [blame] | 8 | namespace phosphor::certs::util |
Jayanth Othayoth | 0aa0d11 | 2018-09-03 03:47:27 -0500 | [diff] [blame] | 9 | { |
| 10 | |
| 11 | /** |
| 12 | * @brief Class - Encapsulates parsing command line options and |
| 13 | * populating arguments. |
| 14 | */ |
| 15 | class 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 Zhou | e1289ad | 2021-12-28 11:02:56 -0800 | [diff] [blame] | 39 | } // namespace phosphor::certs::util |