+// ----------------------------------------------------------------------------
+// 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)
+{
+ return DoWriteString(key, wxString::Format(_T("%g"), val));
+}
+
+bool wxConfigBase::DoWriteInt(const wxString& key, int value)