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 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace certs |
| 11 | { |
| 12 | namespace util |
| 13 | { |
| 14 | |
| 15 | /** |
| 16 | * @brief Class - Encapsulates parsing command line options and |
| 17 | * populating arguments. |
| 18 | */ |
| 19 | class 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 |