summaryrefslogtreecommitdiff
path: root/inputmethods/dasher
authormickeyl <mickeyl>2004-04-24 15:51:18 (UTC)
committer mickeyl <mickeyl>2004-04-24 15:51:18 (UTC)
commit629ced22fc26892442be433403a9cfa9f662f08a (patch) (side-by-side diff)
tree830973cb7ba701b0a897220e1307ad3f1243384b /inputmethods/dasher
parentf7b5905d990f374dd6cb177b7a03628cc593b7cf (diff)
downloadopie-629ced22fc26892442be433403a9cfa9f662f08a.zip
opie-629ced22fc26892442be433403a9cfa9f662f08a.tar.gz
opie-629ced22fc26892442be433403a9cfa9f662f08a.tar.bz2
gcc 3.4 fixes
Diffstat (limited to 'inputmethods/dasher') (more/less context) (show 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,114 +1,119 @@
// SettingsStore.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
#include "SettingsStore.h"
using namespace std;
/* TODO: Consider using Template functions to make this neater. */
+CSettingsStore::~CSettingsStore()
+{
+}
+
+
bool CSettingsStore::GetBoolOption(const string& Key)
{
if (BoolMap.find(Key)==BoolMap.end()) {
bool Value = false;
LoadSetting(Key, &Value);
BoolMap[Key] = Value;
}
return BoolMap[Key];
}
long CSettingsStore::GetLongOption(const string& Key)
{
if (LongMap.find(Key)==LongMap.end()) {
long Value = 0l;
LoadSetting(Key, &Value);
LongMap[Key] = Value;
}
return LongMap[Key];
}
string& CSettingsStore::GetStringOption(const string& Key)
{
if (StringMap.find(Key)==StringMap.end()) {
string Value = "";
LoadSetting(Key, &Value);
StringMap[Key] = Value;
}
return StringMap[Key];
}
void CSettingsStore::SetBoolOption(const string& Key, bool Value)
{
BoolMap[Key] = Value;
SaveSetting(Key, Value);
}
void CSettingsStore::SetLongOption(const string& Key, long Value)
{
LongMap[Key] = Value;
SaveSetting(Key, Value);
}
void CSettingsStore::SetStringOption(const string& Key, const string& Value)
{
StringMap[Key] = Value;
SaveSetting(Key, Value);
}
void CSettingsStore::SetBoolDefault(const string& Key, bool Value)
{
bool TmpValue;
if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) )
SetBoolOption(Key, Value);
}
void CSettingsStore::SetLongDefault(const string& Key, long Value)
{
long TmpValue;
if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) )
SetLongOption(Key, Value);
}
void CSettingsStore::SetStringDefault(const string& Key, const string& Value)
{
string TmpValue;
if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) )
SetStringOption(Key, Value);
}
/* Private functions -- Settings are not saved between sessions unless these
functions are over-ridden.
--------------------------------------------------------------------------*/
bool CSettingsStore::LoadSetting(const string& , bool* )
{
return false;
}
bool CSettingsStore::LoadSetting(const string& , long* )
{
return false;
}
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 @@
// SettingsStore.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __SettingsStore_h__
#define __SettingsStore_h__
#include "MSVC_Unannoy.h"
#include <string>
#include <map>
/*
The public interface uses UTF-8 strings. All Keys should be
in American English and encodable in ASCII. However,
string Values may contain special characters where appropriate.
*/
class CSettingsStore
{
public:
+ virtual ~CSettingsStore();
bool GetBoolOption(const std::string& Key);
long GetLongOption(const std::string& Key);
std::string& GetStringOption(const std::string& Key);
void SetBoolOption(const std::string& Key, bool Value);
void SetLongOption(const std::string& Key, long Value);
void SetStringOption(const std::string& Key, const std::string& Value);
void SetBoolDefault(const std::string& Key, bool Value);
void SetLongDefault(const std::string& Key, long Value);
void SetStringDefault(const std::string& Key, const std::string& Value);
private:
// Platform Specific settings file management
// LoadSetting changes Value only if it succeeds in loading the setting,
// in which case it also returns true. Failure is indicated by returning false.
//! Load a setting with a boolean value
//
//! Load a setting with a boolean value. Return true if successful
//! \param Key Name of the setting
//! \param Value Value of the setting
virtual bool LoadSetting(const std::string& Key, bool* Value);
//! Load a setting with a long value
//
//! Load a setting with a long value. Return true if successful
//! \param Key Name of the setting
//! \param Value Value of the setting
virtual bool LoadSetting(const std::string& Key, long* Value);
//! Load a setting with a string value
//
//! Load a setting with a string value. Return true if successful
//! \param Key Name of the setting
//! \param Value Value of the setting, UTF8 encoded
virtual bool LoadSetting(const std::string& Key, std::string* Value);
//! Save a setting with a boolean value
//
//! \param Key Name of the setting
//! \param Value Value of the setting
virtual void SaveSetting(const std::string& Key, bool Value);
//! Save a setting with a long value
//
//! \param Key Name of the setting
//! \param Value Value of the setting
virtual void SaveSetting(const std::string& Key, long Value);
//! Save a setting with a string value
//
//! \param Key Name of the setting
//! \param Value Value of the setting, UTF8 encoded
virtual void SaveSetting(const std::string& Key, const std::string& Value);
// Used to store settings in memory
std::map<std::string, bool> BoolMap;
std::map<std::string, long> LongMap;
std::map<std::string, std::string> StringMap;
};
#endif /* #ifndef __SettingsStore_h__ */