38 lines
682 B
C
38 lines
682 B
C
|
#pragma once
|
||
|
|
||
|
#include <string>
|
||
|
#include <map>
|
||
|
|
||
|
namespace mrbesen {
|
||
|
|
||
|
class Config {
|
||
|
public:
|
||
|
class Section {
|
||
|
public:
|
||
|
template<typename T = const std::string*>
|
||
|
T get(const std::string& valueName) const;
|
||
|
private:
|
||
|
std::map<std::string, std::string> values;
|
||
|
friend class Config;
|
||
|
};
|
||
|
|
||
|
Config(const std::string& filename);
|
||
|
virtual ~Config();
|
||
|
|
||
|
bool loadConfig();
|
||
|
const Section* getSection(std::string sectionName) const;
|
||
|
|
||
|
template<typename T = const std::string*>
|
||
|
T get(const std::string& valueName) const;
|
||
|
private:
|
||
|
|
||
|
std::string filename;
|
||
|
|
||
|
std::map<std::string, Section> sections;
|
||
|
Section main; // config values without a section
|
||
|
|
||
|
static const std::string SPLIT;
|
||
|
};
|
||
|
|
||
|
}
|