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