36 lines
809 B
C++
36 lines
809 B
C++
#ifndef A8_INIFILE_H
|
|
#define A8_INIFILE_H
|
|
|
|
#include <a8/stringlist.h>
|
|
|
|
namespace a8
|
|
{
|
|
class IniFile
|
|
{
|
|
public:
|
|
IniFile(const std::string filename);
|
|
|
|
bool Load();
|
|
|
|
template<typename T>
|
|
a8::XValue ReadValue(const char* section, const char* key, const T& defval)
|
|
{
|
|
auto itr = sections_.find(std::string(section));
|
|
if(itr != sections_.end()){
|
|
auto key_itr = itr->second.find(std::string(key));
|
|
if(key_itr != itr->second.end()){
|
|
return a8::XValue(key_itr->second);
|
|
}
|
|
}
|
|
return a8::XValue(defval);
|
|
}
|
|
|
|
private:
|
|
std::string filename_;
|
|
std::map<std::string, std::map<std::string, std::string> > sections_;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|