1 #pragma once 2 3 #include <getopt.h> 4 5 #include <map> 6 #include <string> 7 8 namespace phosphor::certs::util 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 39 } // namespace phosphor::certs::util 40