summaryrefslogtreecommitdiff
path: root/plugins/HistoryStats/src/mirandasettings.h
blob: e58b379fad222d6fae34ac11cd9d94249b8d2746 (plain)
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
#if !defined(HISTORYSTATS_GUARD_MIRANDASETTINGS_H)
#define HISTORYSTATS_GUARD_MIRANDASETTINGS_H

#include "_globals.h"
#include "_consts.h"

#include "utils.h"
#include "settingstree.h"

#include <set>
#include <iterator>

class MirandaSettings
	: private pattern::NotCopyable<MirandaSettings>
{
public:
	typedef std::set<ext::a::string> SettingsSet;
	typedef std::insert_iterator<SettingsSet> SetInserter;

private:
	MCONTACT m_hContact;
	ext::a::string m_strModule;

private:
	static int enumSettingsProc(const char* szSetting, LPARAM lParam);

public:
	// constructor
	explicit MirandaSettings();

	// contact/module management
	MCONTACT getContact() const { return m_hContact; }
	void setContact(MCONTACT hContact) { m_hContact = hContact; }
	const ext::a::string& getModule() const { return m_strModule; }
	void setModule(const char* module) { m_strModule = module; }

	// reading
	bool readBool(const char* szSetting, bool bDefault) const;
	int readByte(const char* szSetting, int bDefault) const;
	int readWord(const char* szSetting, int wDefault) const;
	int readDWord(const char* szSetting, int dwDeault) const;
	ext::string readStr(const char* szSetting, const TCHAR* szDefault) const;
	ext::string readStrDirect(const char* szSetting, const TCHAR* szDefault) const;
	void readTree(const char* szSetting, const TCHAR* szDefault, SettingsTree& value) const;

	// writing
	void writeBool(const char* szSetting, bool bValue) const;
	void writeByte(const char* szSetting, int bValue) const;
	void writeWord(const char* szSetting, int wValue) const;
	void writeDWord(const char* szSetting, int dwValue) const;
	void writeStr(const char* szSetting, const TCHAR* szValue) const;
	void writeStrDirect(const char* szSetting, const TCHAR* szValue) const;
	void writeTree(const char* szSetting, const SettingsTree& value) const;

	// misc functions
	bool settingExists(const char* szSetting) const;
	bool delSetting(const char* szSetting);

	// enumeration
	void enumSettings(SetInserter& insertIterator);
};

#endif // HISTORYSTATS_GUARD_MIRANDASETTINGS_H