]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/persist.cpp
remove "item.cchTextMax=0" line from SetItem() as it doesn't seem to make any sense...
[wxWidgets.git] / src / common / persist.cpp
index 80df492e5e85c92ea267cb71d62af577b030b97a..76ab2698bdcde2c7d133df5071b5953b8686da92 100644 (file)
@@ -40,6 +40,10 @@ wxPersistenceManager& wxPersistenceManager::Get()
     return s_manager;
 }
 
+wxPersistenceManager::~wxPersistenceManager()
+{
+}
+
 wxString
 wxPersistenceManager::GetKey(const wxPersistentObject& who,
                              const wxString& name) const
@@ -107,3 +111,43 @@ bool wxPersistenceManager::Restore(void *obj)
     return it->second->Restore();
 }
 
+namespace
+{
+
+template <typename T>
+inline bool
+DoSaveValue(wxConfigBase *conf, const wxString& key, T value)
+{
+    return conf && conf->Write(key, value);
+}
+
+template <typename T>
+bool
+DoRestoreValue(wxConfigBase *conf, const wxString& key, T *value)
+{
+    return conf && conf->Read(key, value);
+}
+
+} // anonymous namespace
+
+#define wxPERSIST_DEFINE_SAVE_RESTORE_FOR(Type)                               \
+    bool wxPersistenceManager::SaveValue(const wxPersistentObject& who,       \
+                                         const wxString& name,                \
+                                         Type value)                          \
+    {                                                                         \
+        return DoSaveValue(GetConfig(), GetKey(who, name), value);            \
+    }                                                                         \
+                                                                              \
+    bool wxPersistenceManager::RestoreValue(const wxPersistentObject& who,    \
+                                            const wxString& name,             \
+                                            Type *value)                      \
+    {                                                                         \
+        return DoRestoreValue(GetConfig(), GetKey(who, name), value);         \
+    }
+
+wxPERSIST_DEFINE_SAVE_RESTORE_FOR(bool)
+wxPERSIST_DEFINE_SAVE_RESTORE_FOR(int)
+wxPERSIST_DEFINE_SAVE_RESTORE_FOR(long)
+wxPERSIST_DEFINE_SAVE_RESTORE_FOR(wxString)
+
+#undef wxPERSIST_DEFINE_SAVE_RESTORE_FOR