]> git.sesse.net Git - cubemap/blob - config.h
Split config parsing out of parse.h.
[cubemap] / config.h
1 #ifndef _CONFIG_H
2 #define _CONFIG_H
3
4 // Various routines that deal with parsing the configuration file.
5
6 #include <map>
7 #include <vector>
8 #include <string>
9
10 struct ConfigLine {
11         std::string keyword;
12         std::vector<std::string> arguments;
13         std::map<std::string, std::string> parameters;
14 };
15
16 // Parse the configuration file.
17 std::vector<ConfigLine> parse_config(const std::string &filename);
18
19 enum ParameterType {
20         PARAMETER_OPTIONAL,
21         PARAMATER_MANDATORY,
22 };
23
24 std::string fetch_config_string(const std::vector<ConfigLine> &config, const std::string &keyword,
25                                 ParameterType parameter_type, const std::string &default_value = "");
26
27 // Note: Limits are inclusive.
28 int fetch_config_int(const std::vector<ConfigLine> &config, const std::string &keyword,
29                      int min_limit, int max_limit,
30                      ParameterType parameter_type, int default_value = -1);
31
32 #endif  // !defined(_CONFIG_H)