976371b20c3d6531a674ccf04c3f39089c703dc5
[staging/windowmanager.git] / src / config.hpp
1 //
2 // Created by mfritzsc on 8/1/17.
3 //
4
5 #ifndef TMCAGLWM_CONFIG_HPP
6 #define TMCAGLWM_CONFIG_HPP
7
8 #include <map>
9 #include <experimental/optional>
10
11 namespace wm {
12
13 using std::experimental::optional;
14 using std::experimental::nullopt;
15
16 struct config {
17    typedef std::map<std::string, std::string> map;
18
19    map cfg;
20
21    config();
22
23    optional<std::string> get_string(char const *s) {
24       auto i = this->cfg.find(s);
25       return i != this->cfg.end() ? optional<std::string>(i->second) : nullopt;
26    }
27
28    optional<int> get_int(char const *s) {
29       auto i = this->cfg.find(s);
30       return i != this->cfg.end() ? optional<int>(std::stoi(i->second)) : nullopt;
31    }
32 };
33
34 }  // namespace wm
35
36
37 #endif //TMCAGLWM_CONFIG_HPP