added SetRecordDefaults() and IsRecordingDefaults() methods

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-08-05 14:15:13 +00:00
parent 2bb0cd285a
commit baeed2892d
3 changed files with 13 additions and 3 deletions

View File

@@ -101,7 +101,7 @@ public:
// ctor & virtual dtor // ctor & virtual dtor
// environment variable expansion is on by default // environment variable expansion is on by default
wxConfigBase() { m_bExpandEnvVars = TRUE; } wxConfigBase() { m_bExpandEnvVars = TRUE; m_bRecordDefaults = FALSE; }
// empty but ensures that dtor of all derived classes is virtual // empty but ensures that dtor of all derived classes is virtual
virtual ~wxConfigBase() { } virtual ~wxConfigBase() { }
@@ -172,7 +172,10 @@ public:
// (this option is on by default, you can turn it on/off at any time) // (this option is on by default, you can turn it on/off at any time)
bool IsExpandingEnvVars() const { return m_bExpandEnvVars; } bool IsExpandingEnvVars() const { return m_bExpandEnvVars; }
void SetExpandEnvVars(bool bDoIt = TRUE) { m_bExpandEnvVars = bDoIt; } void SetExpandEnvVars(bool bDoIt = TRUE) { m_bExpandEnvVars = bDoIt; }
// does expansion only if needed // recording of default values
void SetRecordDefaults(bool bDoIt = TRUE) { m_bRecordDefaults = bDoIt; }
bool IsRecordingDefaults() const { return m_bRecordDefaults; }
// does expansion only if needed
wxString ExpandEnvVars(const wxString& str) const wxString ExpandEnvVars(const wxString& str) const
{ {
wxString tmp; // Required for BC++ wxString tmp; // Required for BC++
@@ -211,7 +214,9 @@ protected:
private: private:
// are we doing automatic environment variable expansion? // are we doing automatic environment variable expansion?
bool m_bExpandEnvVars; bool m_bExpandEnvVars;
// do we record default values?
bool m_bRecordDefaults;
// static variables // static variables
static wxConfigBase *ms_pConfig; static wxConfigBase *ms_pConfig;
static bool ms_bAutoCreate; static bool ms_bAutoCreate;

View File

@@ -532,6 +532,8 @@ bool wxFileConfig::Read(wxString *pstr,
ConfigEntry *pEntry = m_pCurrentGroup->FindEntry(path.Name()); ConfigEntry *pEntry = m_pCurrentGroup->FindEntry(path.Name());
if (pEntry == NULL) { if (pEntry == NULL) {
if(IsRecordingDefaults())
Write(szKey,szDefault);
*pstr = ExpandEnvVars(szDefault); *pstr = ExpandEnvVars(szDefault);
return FALSE; return FALSE;
} }

View File

@@ -281,6 +281,9 @@ bool wxRegConfig::Read(wxString *pStr,
return TRUE; return TRUE;
} }
if(IsRecordingDefaults())
Write(szKey,szDefault);
// default value // default value
*pStr = szDefault; *pStr = szDefault;
return FALSE; return FALSE;