summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/SettingsStore.cpp
Unidiff
Diffstat (limited to 'inputmethods/dasher/SettingsStore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/SettingsStore.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/inputmethods/dasher/SettingsStore.cpp b/inputmethods/dasher/SettingsStore.cpp
new file mode 100644
index 0000000..c5bbfea
--- a/dev/null
+++ b/inputmethods/dasher/SettingsStore.cpp
@@ -0,0 +1,135 @@
1// SettingsStore.cpp
2//
3/////////////////////////////////////////////////////////////////////////////
4//
5// Copyright (c) 2002 Iain Murray
6//
7/////////////////////////////////////////////////////////////////////////////
8
9
10
11
12#include "SettingsStore.h"
13
14using namespace std;
15
16/* TODO: Consider using Template functions to make this neater. */
17
18
19bool CSettingsStore::GetBoolOption(const string& Key)
20{
21 if (BoolMap.find(Key)==BoolMap.end()) {
22 bool Value = false;
23 LoadSetting(Key, &Value);
24 BoolMap[Key] = Value;
25 }
26
27 return BoolMap[Key];
28}
29
30
31long CSettingsStore::GetLongOption(const string& Key)
32{
33 if (LongMap.find(Key)==LongMap.end()) {
34 long Value = 0l;
35 LoadSetting(Key, &Value);
36 LongMap[Key] = Value;
37 }
38
39 return LongMap[Key];
40}
41
42
43string& CSettingsStore::GetStringOption(const string& Key)
44{
45 if (StringMap.find(Key)==StringMap.end()) {
46 string Value = "";
47 LoadSetting(Key, &Value);
48 StringMap[Key] = Value;
49 }
50
51 return StringMap[Key];
52}
53
54
55void CSettingsStore::SetBoolOption(const string& Key, bool Value)
56{
57 BoolMap[Key] = Value;
58 SaveSetting(Key, Value);
59}
60
61
62void CSettingsStore::SetLongOption(const string& Key, long Value)
63{
64 LongMap[Key] = Value;
65 SaveSetting(Key, Value);
66}
67
68
69void CSettingsStore::SetStringOption(const string& Key, const string& Value)
70{
71 StringMap[Key] = Value;
72 SaveSetting(Key, Value);
73}
74
75
76void CSettingsStore::SetBoolDefault(const string& Key, bool Value)
77{
78 bool TmpValue;
79 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) )
80 SetBoolOption(Key, Value);
81}
82
83
84void CSettingsStore::SetLongDefault(const string& Key, long Value)
85{
86 long TmpValue;
87 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) )
88 SetLongOption(Key, Value);
89}
90
91
92void CSettingsStore::SetStringDefault(const string& Key, const string& Value)
93{
94 string TmpValue;
95 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) )
96 SetStringOption(Key, Value);
97}
98
99
100/* Private functions -- Settings are not saved between sessions unless these
101functions are over-ridden.
102--------------------------------------------------------------------------*/
103
104
105bool CSettingsStore::LoadSetting(const string& Key, bool* Value)
106{
107 return false;
108}
109
110
111bool CSettingsStore::LoadSetting(const string& Key, long* Value)
112{
113 return false;
114}
115
116
117bool CSettingsStore::LoadSetting(const string& Key, string* Value)
118{
119 return false;
120}
121
122
123void CSettingsStore::SaveSetting(const string& Key, bool Value)
124{
125}
126
127
128void CSettingsStore::SaveSetting(const string& Key, long Value)
129{
130}
131
132
133void CSettingsStore::SaveSetting(const string& Key, const string& Value)
134{
135}