SC2API
An API for AI for StarCraft II
arg_parser.h
1 #pragma once
2 
3 #include <vector>
4 #include <string>
5 #include <unordered_map>
6 
7 struct Arg {
8  std::string abbreviation_;
9  std::string fullname_;
10  std::string description_;
11  bool required_;
12 };
13 
14 class ArgParser {
15 public:
16  ArgParser();
17  ArgParser(const std::string& executable_name);
18  ArgParser(const std::string& usage, const std::string& description, const std::string& example="");
19 
20 
21  void AddOptions(const std::vector<Arg>& options);
22  bool Parse(int argc, char* argv[]);
23 
24  // If the arg exists returns true and if a value exists for it fill it.
25  bool Get(const std::string& identifier, std::string& value);
26  void PrintHelp();
27  void PrintUsage();
28 
29 private:
30  std::vector<Arg> options_;
31  std::unordered_map<std::string, std::string> abbv_to_full_;
32  std::unordered_map<std::string, std::string> full_to_value_;
33 
34  std::string usage_;
35  std::string description_;
36  std::string example_;
37  std::string executable_name_;
38 };
Definition: arg_parser.h:7
Definition: arg_parser.h:14