+wxConfigBase *wxConfigBase::Create()
+{
+ if ( ms_bAutoCreate && ms_pConfig == NULL ) {
+ ms_pConfig =
+ #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
+ new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+ #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
+ new wxPrefConfig(wxTheApp->GetAppName());
+ #else // either we're under Unix or wish to use files even under Windows
+ new wxFileConfig(wxTheApp->GetAppName());
+ #endif
+ }
+
+ return ms_pConfig;
+}
+
+// ----------------------------------------------------------------------------
+// wxConfigBase reading entries
+// ----------------------------------------------------------------------------
+
+// implement both Read() overloads for the given type in terms of DoRead()
+#define IMPLEMENT_READ_FOR_TYPE(name, type, deftype, extra) \
+ bool wxConfigBase::Read(const wxString& key, type *val) const \
+ { \
+ wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") ); \
+ \
+ if ( !DoRead##name(key, val) ) \
+ return false; \
+ \
+ *val = extra(*val); \
+ \
+ return true; \
+ } \
+ \
+ bool wxConfigBase::Read(const wxString& key, \
+ type *val, \
+ deftype defVal) const \
+ { \
+ wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") ); \
+ \
+ bool read = DoRead##name(key, val); \
+ if ( !read ) \
+ { \
+ if ( IsRecordingDefaults() ) \
+ { \
+ ((wxConfigBase *)this)->DoWrite##name(key, defVal); \
+ } \
+ \
+ *val = defVal; \
+ } \
+ \
+ *val = extra(*val); \
+ \
+ return read; \
+ }
+
+
+IMPLEMENT_READ_FOR_TYPE(String, wxString, const wxString&, ExpandEnvVars)
+IMPLEMENT_READ_FOR_TYPE(Long, long, long, long)
+IMPLEMENT_READ_FOR_TYPE(Int, int, int, int)
+IMPLEMENT_READ_FOR_TYPE(Double, double, double, double)
+IMPLEMENT_READ_FOR_TYPE(Bool, bool, bool, bool)
+
+#undef IMPLEMENT_READ_FOR_TYPE
+
+// the DoReadXXX() for the other types have implementation in the base class
+// but can be overridden in the derived ones
+bool wxConfigBase::DoReadInt(const wxString& key, int *pi) const
+{
+ wxCHECK_MSG( pi, false, _T("wxConfig::Read(): NULL parameter") );
+
+ long l;
+ if ( !DoReadLong(key, &l) )
+ return false;
+
+ wxASSERT_MSG( l < INT_MAX, _T("overflow in wxConfig::DoReadInt") );
+
+ *pi = (int)l;
+
+ return true;
+}
+
+bool wxConfigBase::DoReadBool(const wxString& key, bool* val) const
+{
+ wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") );
+
+ long l;
+ if ( !DoReadLong(key, &l) )
+ return false;
+
+ wxASSERT_MSG( l == 0 || l == 1, _T("bad bool value in wxConfig::DoReadInt") );
+
+ *val = l != 0;
+
+ return true;
+}
+
+bool wxConfigBase::DoReadDouble(const wxString& key, double* val) const
+{
+ wxString str;
+ if ( Read(key, &str) )
+ {
+ return str.ToDouble(val);
+ }
+
+ return false;
+}
+
+// string reading helper
+wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
+{
+ wxString tmp; // Required for BC++
+ if (IsExpandingEnvVars())
+ tmp = wxExpandEnvVars(str);
+ else
+ tmp = str;
+ return tmp;
+}
+
+// ----------------------------------------------------------------------------
+// wxConfigBase writing
+// ----------------------------------------------------------------------------
+
+bool wxConfigBase::DoWriteDouble(const wxString& key, double val)