GameKit  0.0.1a
C++ gamedev tools
ArgumentParser.hpp
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: ArgumentParser.hpp
5  *
6  * Description:
7  *
8  * Created: 21/01/2019 23:14:41
9  *
10  * Author: Quentin Bazin, <quent42340@gmail.com>
11  *
12  * =====================================================================================
13  */
14 #ifndef GK_ARGUMENTPARSER_HPP_
15 #define GK_ARGUMENTPARSER_HPP_
16 
17 #include <string>
18 #include <unordered_map>
19 #include <vector>
20 
21 namespace gk {
22 
23 struct Argument {
24  std::string shortName;
25  std::string longName;
26  bool hasParameter = false;
27  std::string parameter = "";
28  bool isFound = false;
29 };
30 
32  public:
33  ArgumentParser(int argc, char **argv);
34 
35  void parse();
36 
37  void printHelp();
38  void debug();
39 
40  void addArgument(const std::string &name, const Argument &argument) { m_arguments.emplace(name, argument); }
41  const Argument &getArgument(const std::string &name) { return m_arguments.at(name); }
42 
43  private:
44  std::vector<std::string> m_argv;
45  std::unordered_map<std::string, Argument> m_arguments;
46 };
47 
48 } // namespace gk
49 
50 #endif // GK_ARGUMENTPARSER_HPP_
std::string parameter
std::string longName
const Argument & getArgument(const std::string &name)
std::string shortName
std::vector< std::string > m_argv
std::unordered_map< std::string, Argument > m_arguments
void addArgument(const std::string &name, const Argument &argument)