tibia-client/src/framework/core/configs.h

33 lines
809 B
C
Raw Normal View History

2011-04-06 21:46:58 +02:00
#ifndef CONFIGS_H
#define CONFIGS_H
2011-07-13 23:12:36 +02:00
#include <global.h>
2011-05-20 02:03:15 +02:00
struct ConfigValueProxy {
2011-07-13 23:12:36 +02:00
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); }
2011-05-20 01:56:27 +02:00
std::string value;
};
2011-04-06 21:46:58 +02:00
class Configs
{
public:
bool load(const std::string& fileName);
void save();
2011-07-13 23:12:36 +02:00
template<class T>
void set(const std::string& key, const T& value) { m_confsMap[key] = convert<std::string>(value); }
2011-05-20 02:03:15 +02:00
ConfigValueProxy get(const std::string& key) { return ConfigValueProxy{m_confsMap[key]}; }
private:
std::string m_fileName;
std::map<std::string, std::string> m_confsMap;
};
2011-04-06 22:53:00 +02:00
extern Configs g_configs;
2011-04-06 21:46:58 +02:00
#endif // CONFIGS_H