Remove ignored typedef warning for GCC4

This commit is contained in:
urnenfeld 2010-05-22 14:17:02 +00:00
parent 0ed0a7e1c0
commit 8e956baea7
2 changed files with 55 additions and 8 deletions

View File

@ -7,20 +7,20 @@
#include "PreferencesContainer.h" #include "PreferencesContainer.h"
typedef struct CayaPreferencesData typedef struct _CayaPreferencesData
{ {
bool MoveToCurrentWorkspace; bool MoveToCurrentWorkspace;
bool ActivateWindow; bool ActivateWindow;
bool IgnoreEmoticons; bool IgnoreEmoticons;
CayaPreferencesData() _CayaPreferencesData()
: :
MoveToCurrentWorkspace(true), MoveToCurrentWorkspace(true),
ActivateWindow(true), ActivateWindow(true),
IgnoreEmoticons(false) IgnoreEmoticons(false)
{ {
} }
}; } CayaPreferencesData;
typedef PreferencesContainer<CayaPreferencesData> CayaPreferences; typedef PreferencesContainer<CayaPreferencesData> CayaPreferences;

View File

@ -7,6 +7,11 @@
#include <libsupport/Singleton.h> #include <libsupport/Singleton.h>
#include <Directory.h>
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
// TODO: added to main singleton class? // TODO: added to main singleton class?
template<typename T> T* Singleton<T>::fInstance = 0; template<typename T> T* Singleton<T>::fInstance = 0;
@ -15,7 +20,6 @@ template<class SettingsType>
class PreferencesContainer : public Singleton<PreferencesContainer<SettingsType> > { class PreferencesContainer : public Singleton<PreferencesContainer<SettingsType> > {
public: public:
static const char* fFilename;
static SettingsType* static SettingsType*
Item() Item()
@ -23,13 +27,56 @@ public:
return &(Singleton<PreferencesContainer<SettingsType> >::Get()->fSettings); return &(Singleton<PreferencesContainer<SettingsType> >::Get()->fSettings);
} }
// TODO:
// status_t Save(); status_t Load()
// status_t Load(); {
if (fPreferencesFile.SetTo(&fDirectory, fFilename,
B_READ_WRITE | B_FAIL_IF_EXISTS) == B_OK) {
// reset the file pointer
fPreferencesFile.Seek(0, SEEK_SET);
if (fPreferencesFile.Read(&fSettings, sizeof(SettingsType)) > 0)
return B_OK;
}
return B_ERROR;
}
status_t Save()
{
if (fPreferencesFile.SetTo(&fDirectory, fFilename,
B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE) == B_OK) {
if (fPreferencesFile.Write(&fSettings, sizeof(SettingsType)) > 0)
return B_OK;
}
return B_ERROR;
}
private: private:
SettingsType fSettings; PreferencesContainer<SettingsType>()
: Singleton<PreferencesContainer<SettingsType> >()
{
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path);
path.Append(fFolder);
fDirectory.SetTo(path.Path());
Load();
}
friend class Singleton<PreferencesContainer<SettingsType> >;
SettingsType fSettings;
BFile fPreferencesFile;
BDirectory fDirectory;
static const char* fFilename;
static const char* fFolder;
}; };