+// 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);
+ if (ret)
+ *pi = (int) l;
+ return ret;
+}
+
+bool wxConfigBase::Write(const wxString& key, double val)
+{
+ wxString str;
+ str.Printf(wxT("%g"), val);
+ return Write(key, str);
+}
+
+bool wxConfigBase::Write(const wxString& key, bool value)
+{
+ return Write(key, value ? 1l : 0l);
+}
+
+bool wxConfigBase::Write(const wxString& key, const wxChar *value)
+{
+ // explicit cast needed, otherwise value would have been converted to bool
+ return Write(key, wxString(value));
+}
+
+wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
+{
+ wxString tmp; // Required for BC++
+ if (IsExpandingEnvVars())
+ tmp = wxExpandEnvVars(str);
+ else
+ tmp = str;
+ return tmp;
+}
+
+// ----------------------------------------------------------------------------
+// wxConfigPathChanger
+// ----------------------------------------------------------------------------
+
+wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
+ const wxString& strEntry)
+{
+ m_pContainer = (wxConfigBase *)pContainer;
+
+ // the path is everything which precedes the last slash
+ wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR);
+
+ // except in the special case of "/keyname" when there is nothing before "/"
+ if ( strPath.IsEmpty() &&
+ ((!strEntry.IsEmpty()) && strEntry[0] == wxCONFIG_PATH_SEPARATOR) )
+ {
+ strPath = wxCONFIG_PATH_SEPARATOR;
+ }
+
+ if ( !strPath.IsEmpty() ) {
+ // do change the path
+ m_bChanged = TRUE;
+ m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR);
+ m_strOldPath = m_pContainer->GetPath();
+ if ( m_strOldPath.Len() == 0 ||
+ m_strOldPath.Last() != wxCONFIG_PATH_SEPARATOR )
+ m_strOldPath += wxCONFIG_PATH_SEPARATOR;
+ m_pContainer->SetPath(strPath);
+ }
+ else {
+ // it's a name only, without path - nothing to do
+ m_bChanged = FALSE;
+ m_strName = strEntry;
+ }
+}
+
+wxConfigPathChanger::~wxConfigPathChanger()
+{
+ // only restore path if it was changed
+ if ( m_bChanged ) {
+ m_pContainer->SetPath(m_strOldPath);
+ }
+}
+
+#endif // wxUSE_CONFIG
+