+// wxConfigBase
+// ----------------------------------------------------------------------------
+
+// Not all args will always be used by derived classes, but including them all
+// in each class ensures compatibility.
+wxConfigBase::wxConfigBase(const wxString& appName,
+ const wxString& vendorName,
+ const wxString& WXUNUSED(localFilename),
+ const wxString& WXUNUSED(globalFilename),
+ long style)
+ : m_appName(appName), m_vendorName(vendorName), m_style(style)
+{
+ m_bExpandEnvVars = TRUE; m_bRecordDefaults = FALSE;
+}
+
+wxConfigBase::~wxConfigBase()
+{
+}
+
+wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
+{
+ wxConfigBase *pOld = ms_pConfig;
+ ms_pConfig = pConfig;
+ return pOld;
+}
+
+wxConfigBase *wxConfigBase::Create()
+{
+ if ( ms_bAutoCreate && ms_pConfig == NULL ) {
+ ms_pConfig =
+ #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
+ #ifdef __WIN32__
+ new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+ #else //WIN16
+ new wxIniConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+ #endif
+ #else // either we're under Unix or wish to use files even under Windows
+ new wxFileConfig(wxTheApp->GetAppName());
+ #endif
+ }
+
+ return ms_pConfig;
+}
+
+wxString wxConfigBase::Read(const wxString& key, const wxString& defVal) const
+{
+ wxString s;
+ Read(key, &s, defVal);
+ return s;
+}
+
+bool wxConfigBase::Read(const wxString& key, wxString *str, const wxString& defVal) const
+{
+ if (!Read(key, str))
+ {
+ *str = ExpandEnvVars(defVal);
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+bool wxConfigBase::Read(const wxString& key, long *pl, long defVal) const
+{
+ if (!Read(key, pl))
+ {
+ *pl = defVal;
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+bool wxConfigBase::Read(const wxString& key, double* val) const
+{
+ wxString str;
+ if (Read(key, & str))
+ {
+ *val = wxAtof(str);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+bool wxConfigBase::Read(const wxString& key, double* val, double defVal) const
+{
+ if (!Read(key, val))
+ {
+ *val = defVal;
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+bool wxConfigBase::Read(const wxString& key, bool* val) const
+{
+ long l;
+ if (Read(key, & l))
+ {
+ *val = (l != 0);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+bool wxConfigBase::Read(const wxString& key, bool* val, bool defVal) const
+{
+ if (!Read(key, val))
+ {
+ *val = defVal;
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+// Convenience functions
+
+bool wxConfigBase::Read(const wxString& key, int *pi) const
+{
+ long l;
+ bool ret = Read(key, &l);
+ if (ret)
+ *pi = (int) l;
+ return ret;
+}
+
+bool wxConfigBase::Read(const wxString& key, int *pi, int defVal) const
+{
+ long l;
+ bool ret = Read(key, &l, (long) defVal);
+ *pi = (int) l;
+ return ret;
+}
+
+bool wxConfigBase::Write(const wxString& key, double val)
+{
+ wxString str;
+ str.Printf(wxT("%f"), val);
+ return Write(key, str);
+}
+
+bool wxConfigBase::Write(const wxString& key, bool value)
+{
+ long l = (value ? 1 : 0);
+ return Write(key, l);
+}
+
+bool wxConfigBase::Write( const wxString &key, const wxChar *text )
+{
+ wxString str( text ) ;
+ return Write( key, str ) ;
+}
+wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
+{
+ wxString tmp; // Required for BC++
+ if (IsExpandingEnvVars())
+ tmp = wxExpandEnvVars(str);
+ else
+ tmp = str;
+ return tmp;
+}
+
+// ----------------------------------------------------------------------------
+// wxConfigPathChanger