added support for binary data to wxConfig (slightly modified patch 1736788)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47353 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-07-12 00:11:03 +00:00
parent 84ebfcbd18
commit 5814e8ba4e
11 changed files with 136 additions and 0 deletions

View File

@@ -42,6 +42,8 @@
#include "wx/fileconf.h"
#include "wx/filefn.h"
#include "wx/base64.h"
#include "wx/stdpaths.h"
#if defined(__WXMAC__)
@@ -916,6 +918,18 @@ bool wxFileConfig::DoReadLong(const wxString& key, long *pl) const
return str.ToLong(pl);
}
bool wxFileConfig::DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const
{
wxCHECK_MSG( buf, false, _T("NULL buffer") );
wxString str;
if ( !Read(key, &str) )
return false;
*buf = wxBase64Decode(str);
return true;
}
bool wxFileConfig::DoWriteString(const wxString& key, const wxString& szValue)
{
wxConfigPathChanger path(this, key);
@@ -981,6 +995,11 @@ bool wxFileConfig::DoWriteLong(const wxString& key, long lValue)
return Write(key, wxString::Format(_T("%ld"), lValue));
}
bool wxFileConfig::DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf)
{
return Write(key, wxBase64Encode(buf));
}
bool wxFileConfig::Flush(bool /* bCurrentOnly */)
{
if ( !IsDirty() || !m_fnLocalFile.GetFullPath() )