summaryrefslogtreecommitdiff
path: root/inputmethods/dasher
Unidiff
Diffstat (limited to 'inputmethods/dasher') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/SettingsStore.cpp5
-rw-r--r--inputmethods/dasher/SettingsStore.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/inputmethods/dasher/SettingsStore.cpp b/inputmethods/dasher/SettingsStore.cpp
index f7661bd..7e0fa58 100644
--- a/inputmethods/dasher/SettingsStore.cpp
+++ b/inputmethods/dasher/SettingsStore.cpp
@@ -1,135 +1,140 @@
1// SettingsStore.cpp 1// SettingsStore.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11 11
12#include "SettingsStore.h" 12#include "SettingsStore.h"
13 13
14using namespace std; 14using namespace std;
15 15
16/* TODO: Consider using Template functions to make this neater. */ 16/* TODO: Consider using Template functions to make this neater. */
17 17
18 18
19CSettingsStore::~CSettingsStore()
20{
21}
22
23
19bool CSettingsStore::GetBoolOption(const string& Key) 24bool CSettingsStore::GetBoolOption(const string& Key)
20{ 25{
21 if (BoolMap.find(Key)==BoolMap.end()) { 26 if (BoolMap.find(Key)==BoolMap.end()) {
22 bool Value = false; 27 bool Value = false;
23 LoadSetting(Key, &Value); 28 LoadSetting(Key, &Value);
24 BoolMap[Key] = Value; 29 BoolMap[Key] = Value;
25 } 30 }
26 31
27 return BoolMap[Key]; 32 return BoolMap[Key];
28} 33}
29 34
30 35
31long CSettingsStore::GetLongOption(const string& Key) 36long CSettingsStore::GetLongOption(const string& Key)
32{ 37{
33 if (LongMap.find(Key)==LongMap.end()) { 38 if (LongMap.find(Key)==LongMap.end()) {
34 long Value = 0l; 39 long Value = 0l;
35 LoadSetting(Key, &Value); 40 LoadSetting(Key, &Value);
36 LongMap[Key] = Value; 41 LongMap[Key] = Value;
37 } 42 }
38 43
39 return LongMap[Key]; 44 return LongMap[Key];
40} 45}
41 46
42 47
43string& CSettingsStore::GetStringOption(const string& Key) 48string& CSettingsStore::GetStringOption(const string& Key)
44{ 49{
45 if (StringMap.find(Key)==StringMap.end()) { 50 if (StringMap.find(Key)==StringMap.end()) {
46 string Value = ""; 51 string Value = "";
47 LoadSetting(Key, &Value); 52 LoadSetting(Key, &Value);
48 StringMap[Key] = Value; 53 StringMap[Key] = Value;
49 } 54 }
50 55
51 return StringMap[Key]; 56 return StringMap[Key];
52} 57}
53 58
54 59
55void CSettingsStore::SetBoolOption(const string& Key, bool Value) 60void CSettingsStore::SetBoolOption(const string& Key, bool Value)
56{ 61{
57 BoolMap[Key] = Value; 62 BoolMap[Key] = Value;
58 SaveSetting(Key, Value); 63 SaveSetting(Key, Value);
59} 64}
60 65
61 66
62void CSettingsStore::SetLongOption(const string& Key, long Value) 67void CSettingsStore::SetLongOption(const string& Key, long Value)
63{ 68{
64 LongMap[Key] = Value; 69 LongMap[Key] = Value;
65 SaveSetting(Key, Value); 70 SaveSetting(Key, Value);
66} 71}
67 72
68 73
69void CSettingsStore::SetStringOption(const string& Key, const string& Value) 74void CSettingsStore::SetStringOption(const string& Key, const string& Value)
70{ 75{
71 StringMap[Key] = Value; 76 StringMap[Key] = Value;
72 SaveSetting(Key, Value); 77 SaveSetting(Key, Value);
73} 78}
74 79
75 80
76void CSettingsStore::SetBoolDefault(const string& Key, bool Value) 81void CSettingsStore::SetBoolDefault(const string& Key, bool Value)
77{ 82{
78 bool TmpValue; 83 bool TmpValue;
79 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 84 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) )
80 SetBoolOption(Key, Value); 85 SetBoolOption(Key, Value);
81} 86}
82 87
83 88
84void CSettingsStore::SetLongDefault(const string& Key, long Value) 89void CSettingsStore::SetLongDefault(const string& Key, long Value)
85{ 90{
86 long TmpValue; 91 long TmpValue;
87 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 92 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) )
88 SetLongOption(Key, Value); 93 SetLongOption(Key, Value);
89} 94}
90 95
91 96
92void CSettingsStore::SetStringDefault(const string& Key, const string& Value) 97void CSettingsStore::SetStringDefault(const string& Key, const string& Value)
93{ 98{
94 string TmpValue; 99 string TmpValue;
95 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 100 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) )
96 SetStringOption(Key, Value); 101 SetStringOption(Key, Value);
97} 102}
98 103
99 104
100/* Private functions -- Settings are not saved between sessions unless these 105/* Private functions -- Settings are not saved between sessions unless these
101functions are over-ridden. 106functions are over-ridden.
102--------------------------------------------------------------------------*/ 107--------------------------------------------------------------------------*/
103 108
104 109
105bool CSettingsStore::LoadSetting(const string& , bool* ) 110bool CSettingsStore::LoadSetting(const string& , bool* )
106{ 111{
107 return false; 112 return false;
108} 113}
109 114
110 115
111bool CSettingsStore::LoadSetting(const string& , long* ) 116bool CSettingsStore::LoadSetting(const string& , long* )
112{ 117{
113 return false; 118 return false;
114} 119}
115 120
116 121
117bool CSettingsStore::LoadSetting(const string& , string* ) 122bool CSettingsStore::LoadSetting(const string& , string* )
118{ 123{
119 return false; 124 return false;
120} 125}
121 126
122 127
123void CSettingsStore::SaveSetting(const string& , bool ) 128void CSettingsStore::SaveSetting(const string& , bool )
124{ 129{
125} 130}
126 131
127 132
128void CSettingsStore::SaveSetting(const string& , long ) 133void CSettingsStore::SaveSetting(const string& , long )
129{ 134{
130} 135}
131 136
132 137
133void CSettingsStore::SaveSetting(const string& , const string& ) 138void CSettingsStore::SaveSetting(const string& , const string& )
134{ 139{
135} 140}
diff --git a/inputmethods/dasher/SettingsStore.h b/inputmethods/dasher/SettingsStore.h
index 8ef9fcf..2ddf152 100644
--- a/inputmethods/dasher/SettingsStore.h
+++ b/inputmethods/dasher/SettingsStore.h
@@ -1,92 +1,93 @@
1// SettingsStore.h 1// SettingsStore.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11#ifndef __SettingsStore_h__ 11#ifndef __SettingsStore_h__
12#define __SettingsStore_h__ 12#define __SettingsStore_h__
13 13
14 14
15#include "MSVC_Unannoy.h" 15#include "MSVC_Unannoy.h"
16#include <string> 16#include <string>
17#include <map> 17#include <map>
18 18
19 19
20/* 20/*
21 The public interface uses UTF-8 strings. All Keys should be 21 The public interface uses UTF-8 strings. All Keys should be
22 in American English and encodable in ASCII. However, 22 in American English and encodable in ASCII. However,
23 string Values may contain special characters where appropriate. 23 string Values may contain special characters where appropriate.
24*/ 24*/
25 25
26 26
27class CSettingsStore 27class CSettingsStore
28{ 28{
29public: 29public:
30 virtual ~CSettingsStore();
30 bool GetBoolOption(const std::string& Key); 31 bool GetBoolOption(const std::string& Key);
31 long GetLongOption(const std::string& Key); 32 long GetLongOption(const std::string& Key);
32 std::string& GetStringOption(const std::string& Key); 33 std::string& GetStringOption(const std::string& Key);
33 34
34 void SetBoolOption(const std::string& Key, bool Value); 35 void SetBoolOption(const std::string& Key, bool Value);
35 void SetLongOption(const std::string& Key, long Value); 36 void SetLongOption(const std::string& Key, long Value);
36 void SetStringOption(const std::string& Key, const std::string& Value); 37 void SetStringOption(const std::string& Key, const std::string& Value);
37 38
38 void SetBoolDefault(const std::string& Key, bool Value); 39 void SetBoolDefault(const std::string& Key, bool Value);
39 void SetLongDefault(const std::string& Key, long Value); 40 void SetLongDefault(const std::string& Key, long Value);
40 void SetStringDefault(const std::string& Key, const std::string& Value); 41 void SetStringDefault(const std::string& Key, const std::string& Value);
41private: 42private:
42 // Platform Specific settings file management 43 // Platform Specific settings file management
43 44
44 // LoadSetting changes Value only if it succeeds in loading the setting, 45 // LoadSetting changes Value only if it succeeds in loading the setting,
45 // in which case it also returns true. Failure is indicated by returning false. 46 // in which case it also returns true. Failure is indicated by returning false.
46 //! Load a setting with a boolean value 47 //! Load a setting with a boolean value
47 // 48 //
48 //! Load a setting with a boolean value. Return true if successful 49 //! Load a setting with a boolean value. Return true if successful
49 //! \param Key Name of the setting 50 //! \param Key Name of the setting
50 //! \param Value Value of the setting 51 //! \param Value Value of the setting
51 virtual bool LoadSetting(const std::string& Key, bool* Value); 52 virtual bool LoadSetting(const std::string& Key, bool* Value);
52 53
53 //! Load a setting with a long value 54 //! Load a setting with a long value
54 // 55 //
55 //! Load a setting with a long value. Return true if successful 56 //! Load a setting with a long value. Return true if successful
56 //! \param Key Name of the setting 57 //! \param Key Name of the setting
57 //! \param Value Value of the setting 58 //! \param Value Value of the setting
58 virtual bool LoadSetting(const std::string& Key, long* Value); 59 virtual bool LoadSetting(const std::string& Key, long* Value);
59 60
60 //! Load a setting with a string value 61 //! Load a setting with a string value
61 // 62 //
62 //! Load a setting with a string value. Return true if successful 63 //! Load a setting with a string value. Return true if successful
63 //! \param Key Name of the setting 64 //! \param Key Name of the setting
64 //! \param Value Value of the setting, UTF8 encoded 65 //! \param Value Value of the setting, UTF8 encoded
65 virtual bool LoadSetting(const std::string& Key, std::string* Value); 66 virtual bool LoadSetting(const std::string& Key, std::string* Value);
66 67
67 //! Save a setting with a boolean value 68 //! Save a setting with a boolean value
68 // 69 //
69 //! \param Key Name of the setting 70 //! \param Key Name of the setting
70 //! \param Value Value of the setting 71 //! \param Value Value of the setting
71 virtual void SaveSetting(const std::string& Key, bool Value); 72 virtual void SaveSetting(const std::string& Key, bool Value);
72 73
73 //! Save a setting with a long value 74 //! Save a setting with a long value
74 // 75 //
75 //! \param Key Name of the setting 76 //! \param Key Name of the setting
76 //! \param Value Value of the setting 77 //! \param Value Value of the setting
77 virtual void SaveSetting(const std::string& Key, long Value); 78 virtual void SaveSetting(const std::string& Key, long Value);
78 79
79 //! Save a setting with a string value 80 //! Save a setting with a string value
80 // 81 //
81 //! \param Key Name of the setting 82 //! \param Key Name of the setting
82 //! \param Value Value of the setting, UTF8 encoded 83 //! \param Value Value of the setting, UTF8 encoded
83 virtual void SaveSetting(const std::string& Key, const std::string& Value); 84 virtual void SaveSetting(const std::string& Key, const std::string& Value);
84 85
85 // Used to store settings in memory 86 // Used to store settings in memory
86 std::map<std::string, bool> BoolMap; 87 std::map<std::string, bool> BoolMap;
87 std::map<std::string, long> LongMap; 88 std::map<std::string, long> LongMap;
88 std::map<std::string, std::string> StringMap; 89 std::map<std::string, std::string> StringMap;
89}; 90};
90 91
91 92
92#endif /* #ifndef __SettingsStore_h__ */ 93#endif /* #ifndef __SettingsStore_h__ */