-
Notifications
You must be signed in to change notification settings - Fork 9
/
cxcontext.h
83 lines (61 loc) · 4.32 KB
/
cxcontext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef CXCONTEXT_H
#define CXCONTEXT_H
#include "cxglobal.h"
// CxIGetSkv : special get value
class CxIGetSkv
{
public:
uint getValue(const std::string& sEntry, uint iDefaultValue) const { return getValue(sEntry, (int)iDefaultValue ); }
uint getValue(const std::string& sSection, const std::string& sEntry, uint iDefaultValue) const { return getValue(sSection, sEntry, (int)iDefaultValue ); }
virtual int getValue(const std::string& sEntry, int iDefaultValue) const = 0;
virtual bool getValue(const std::string& sEntry, bool bDefaultValue) const = 0;
virtual double getValue(const std::string& sEntry, double dDefaultValue) const = 0;
virtual msepoch_t getValue(const std::string& sEntry, const msepoch_t& dtDefaultValue) const = 0;
virtual std::string getValue(const std::string& sEntry, const std::string& sDefaultValue) const = 0;
virtual int getValue(const std::string& sSection, const std::string& sEntry, int iDefaultValue) const = 0;
virtual bool getValue(const std::string& sSection, const std::string& sEntry, bool bDefaultValue) const = 0;
virtual double getValue(const std::string& sSection, const std::string& sEntry, double dDefaultValue) const = 0;
virtual msepoch_t getValue(const std::string& sSection, const std::string& sEntry, const msepoch_t& dtDefaultValue) const = 0;
virtual std::string getValue(const std::string& sSection, const std::string& sEntry, const std::string& sDefaultValue) const = 0;
virtual bool hasSection(const std::string& sSection) const = 0;
virtual bool hasEntry(const std::string& sSection, const std::string& sEntry) const = 0;
virtual bool hasEntry(const std::string& sEntry) const = 0;
};
// CxISetSkv : special set value
class CxISetSkv
{
public:
inline void setValue(const std::string& sEntry, uint iValue) { setValue(sEntry, (int)iValue); }
inline void setValue(const std::string& sSection, const std::string& sEntry, uint iValue) { setValue(sSection, sEntry, (int)iValue); }
virtual void setValue(const std::string& sEntry, int iValue) =0;
virtual void setValue(const std::string& sEntry, bool bValue) =0;
virtual void setValue(const std::string& sEntry, double dValue) =0;
virtual void setValue(const std::string& sEntry, msepoch_t dtValue) =0;
virtual void setValue(const std::string& sEntry, std::string sValue) =0;
virtual void setValue(const std::string& sSection, const std::string& sEntry, int iValue) =0;
virtual void setValue(const std::string& sSection, const std::string& sEntry, bool bValue) =0;
virtual void setValue(const std::string& sSection, const std::string& sEntry, double dValue) =0;
virtual void setValue(const std::string& sSection, const std::string& sEntry, msepoch_t dtValue) =0;
virtual void setValue(const std::string& sSection, const std::string& sEntry, std::string sValue) =0;
};
class GM_CCXX_CORE_API CxGetSkvMap : public CxIGetSkv
{
public:
CxGetSkvMap(const std::map<std::string, std::string> & sEntryValues);
int getValue(const std::string& sEntry, int iDefaultValue) const ;
bool getValue(const std::string& sEntry, bool bDefaultValue) const ;
double getValue(const std::string& sEntry, double dDefaultValue) const ;
msepoch_t getValue(const std::string& sEntry, const msepoch_t& dtDefaultValue) const ;
std::string getValue(const std::string& sEntry, const std::string& sDefaultValue) const ;
int getValue(const std::string& sSection, const std::string& sEntry, int iDefaultValue) const { return iDefaultValue; }
bool getValue(const std::string& sSection, const std::string& sEntry, bool bDefaultValue) const { return bDefaultValue; }
double getValue(const std::string& sSection, const std::string& sEntry, double dDefaultValue) const { return dDefaultValue; }
msepoch_t getValue(const std::string& sSection, const std::string& sEntry, const msepoch_t& dtDefaultValue) const { return dtDefaultValue; }
std::string getValue(const std::string& sSection, const std::string& sEntry, const std::string& sDefaultValue) const { return sDefaultValue; }
bool hasSection(const std::string& sSection) const { return false; }
bool hasEntry(const std::string& sSection, const std::string& sEntry) const { return false; }
bool hasEntry(const std::string& sEntry) const ;
private:
std::map<std::string, std::string> _defaultEntryValues;
};
#endif // CXCONTEXT_H