libwallaby  v24
The wallaby standard library
config.hpp
Go to the documentation of this file.
1 /*
2  * config.hpp
3  *
4  * Created on: Nov 13, 2015
5  * Author: Joshua Southerland
6  */
7 
8 #ifndef INCLUDE_WALLABY_CONFIG_HPP_
9 #define INCLUDE_WALLABY_CONFIG_HPP_
10 
11 #include <string>
12 #include <map>
13 #include <vector>
14 #include "export.h"
15 
17 {
18 public:
19  Config();
20  Config(const std::map<std::string, std::string> &config);
21 
22  static Config *load(const std::string &path);
23  bool save(const std::string &path) const;
24 
25  void beginGroup(const std::string &group);
26  void endGroup();
27  void clearGroup();
28 
29  void clear();
30 
31  bool containsKey(const std::string &key) const;
32 
33  bool boolValue(const std::string &key) const;
34  int intValue(const std::string &key) const;
35  double doubleValue(const std::string &key) const;
36  std::string stringValue(const std::string &key) const;
37 
38  void setValue(const std::string &key, const bool &value);
39  void setValue(const std::string &key, const int &value);
40  void setValue(const std::string &key, const double &value);
41  void setValue(const std::string &key, const char *value);
42  void setValue(const std::string &key, const std::string &value);
43 
44  Config values() const;
45  void addValues(const Config &config);
46 
47 private:
48  std::string safeKey(std::string key) const;
49  std::string group() const;
50 
51  std::map<std::string, std::string> m_config;
52  std::vector<std::string> m_groups;
53  mutable std::string m_cachedGroup;
54 };
55 
56 
57 
58 #endif /* INCLUDE_WALLABY_CONFIG_HPP_ */
Config
Definition: config.hpp:16
EXPORT_SYM
#define EXPORT_SYM
Definition: export.h:14
export.h