You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
809 B

#ifndef CONFIGS_H
#define CONFIGS_H
#include <global.h>
struct ConfigValueProxy {
operator std::string() const { return convert<std::string>(value); }
operator float() const { return convert<float>(value); }
operator int() const { return convert<int>(value); }
operator bool() const { return convert<bool>(value); }
std::string value;
};
class Configs
{
public:
bool load(const std::string& fileName);
void save();
template<class T>
void set(const std::string& key, const T& value) { m_confsMap[key] = convert<std::string>(value); }
ConfigValueProxy get(const std::string& key) { return ConfigValueProxy{m_confsMap[key]}; }
private:
std::string m_fileName;
std::map<std::string, std::string> m_confsMap;
};
extern Configs g_configs;
#endif // CONFIGS_H