Diffstat (limited to 'inputmethods/dasher/SettingsStore.h') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/dasher/SettingsStore.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/inputmethods/dasher/SettingsStore.h b/inputmethods/dasher/SettingsStore.h new file mode 100644 index 0000000..8ef9fcf --- a/dev/null +++ b/inputmethods/dasher/SettingsStore.h | |||
@@ -0,0 +1,92 @@ | |||
1 | // SettingsStore.h | ||
2 | // | ||
3 | ///////////////////////////////////////////////////////////////////////////// | ||
4 | // | ||
5 | // Copyright (c) 2002 Iain Murray | ||
6 | // | ||
7 | ///////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | |||
10 | |||
11 | #ifndef __SettingsStore_h__ | ||
12 | #define __SettingsStore_h__ | ||
13 | |||
14 | |||
15 | #include "MSVC_Unannoy.h" | ||
16 | #include <string> | ||
17 | #include <map> | ||
18 | |||
19 | |||
20 | /* | ||
21 | The public interface uses UTF-8 strings. All Keys should be | ||
22 | in American English and encodable in ASCII. However, | ||
23 | string Values may contain special characters where appropriate. | ||
24 | */ | ||
25 | |||
26 | |||
27 | class CSettingsStore | ||
28 | { | ||
29 | public: | ||
30 | bool GetBoolOption(const std::string& Key); | ||
31 | long GetLongOption(const std::string& Key); | ||
32 | std::string& GetStringOption(const std::string& Key); | ||
33 | |||
34 | void SetBoolOption(const std::string& Key, bool Value); | ||
35 | void SetLongOption(const std::string& Key, long Value); | ||
36 | void SetStringOption(const std::string& Key, const std::string& Value); | ||
37 | |||
38 | void SetBoolDefault(const std::string& Key, bool Value); | ||
39 | void SetLongDefault(const std::string& Key, long Value); | ||
40 | void SetStringDefault(const std::string& Key, const std::string& Value); | ||
41 | private: | ||
42 | // Platform Specific settings file management | ||
43 | |||
44 | // 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 | //! Load a setting with a boolean value | ||
47 | // | ||
48 | //! Load a setting with a boolean value. Return true if successful | ||
49 | //! \param Key Name of the setting | ||
50 | //! \param Value Value of the setting | ||
51 | virtual bool LoadSetting(const std::string& Key, bool* Value); | ||
52 | |||
53 | //! Load a setting with a long value | ||
54 | // | ||
55 | //! Load a setting with a long value. Return true if successful | ||
56 | //! \param Key Name of the setting | ||
57 | //! \param Value Value of the setting | ||
58 | virtual bool LoadSetting(const std::string& Key, long* Value); | ||
59 | |||
60 | //! Load a setting with a string value | ||
61 | // | ||
62 | //! Load a setting with a string value. Return true if successful | ||
63 | //! \param Key Name of the setting | ||
64 | //! \param Value Value of the setting, UTF8 encoded | ||
65 | virtual bool LoadSetting(const std::string& Key, std::string* Value); | ||
66 | |||
67 | //! Save a setting with a boolean value | ||
68 | // | ||
69 | //! \param Key Name of the setting | ||
70 | //! \param Value Value of the setting | ||
71 | virtual void SaveSetting(const std::string& Key, bool Value); | ||
72 | |||
73 | //! Save a setting with a long value | ||
74 | // | ||
75 | //! \param Key Name of the setting | ||
76 | //! \param Value Value of the setting | ||
77 | virtual void SaveSetting(const std::string& Key, long Value); | ||
78 | |||
79 | //! Save a setting with a string value | ||
80 | // | ||
81 | //! \param Key Name of the setting | ||
82 | //! \param Value Value of the setting, UTF8 encoded | ||
83 | virtual void SaveSetting(const std::string& Key, const std::string& Value); | ||
84 | |||
85 | // Used to store settings in memory | ||
86 | std::map<std::string, bool> BoolMap; | ||
87 | std::map<std::string, long> LongMap; | ||
88 | std::map<std::string, std::string> StringMap; | ||
89 | }; | ||
90 | |||
91 | |||
92 | #endif /* #ifndef __SettingsStore_h__ */ | ||