|
Revision 5, 0.9 kB
(checked in by qbert, 3 years ago)
|
Initial ( and last :( ) commit
|
| Line | |
|---|
| 1 |
#ifndef ELSETTINGS_H |
|---|
| 2 |
#define ELSETTINGS_H |
|---|
| 3 |
|
|---|
| 4 |
#include "../stdincludes.h" |
|---|
| 5 |
#include "IniEx.h" |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
class ISettings { |
|---|
| 9 |
public: |
|---|
| 10 |
CIniEx iniFile; |
|---|
| 11 |
string filePath; |
|---|
| 12 |
string module; |
|---|
| 13 |
|
|---|
| 14 |
// constants |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
ISettings(const string& p,const string& m ) : filePath(p),module(m) {} |
|---|
| 18 |
|
|---|
| 19 |
bool Restore() |
|---|
| 20 |
{ |
|---|
| 21 |
|
|---|
| 22 |
return iniFile.Open(filePath.c_str(),true) != 0; |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
bool Save() |
|---|
| 29 |
{ |
|---|
| 30 |
|
|---|
| 31 |
iniFile.WriteFile(true); |
|---|
| 32 |
return true; |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
string GetCache(const string& key) { |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
CString buf = iniFile.GetValue(module.c_str(), key.c_str()); |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
return buf.GetBuffer(0); |
|---|
| 42 |
} |
|---|
| 43 |
void SetCache(const string& key, const string& value) { |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
iniFile.SetValue(module.c_str(),key.c_str(),value.c_str()); |
|---|
| 47 |
|
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
void SetCache(const string& key, int value) { |
|---|
| 51 |
|
|---|
| 52 |
iniFile.SetValue(module.c_str(),key.c_str(),value ? "1" : "0"); |
|---|
| 53 |
|
|---|
| 54 |
} |
|---|
| 55 |
}; |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
#endif |
|---|