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