X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/16c1f7f345e1850f590cfbf67c3b00fbb6d2e62e..884470b12ee25b20796bfef11a9bfa5fb1e1511c:/src/common/config.cpp diff --git a/src/common/config.cpp b/src/common/config.cpp index 9707475ac9..66e8d2017f 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -10,10 +10,6 @@ // Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// -// ============================================================================ -// declarations -// ============================================================================ - // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -23,20 +19,22 @@ #include "wx/wxprec.h" +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include + +#if wxUSE_CONFIG + #ifdef __BORLANDC__ #pragma hdrstop #endif //__BORLANDC__ -#ifndef WX_PRECOMP - #include - #include -#endif //WX_PRECOMP - #include #include #include #include -#include #include // we must include (one of) these files for wxConfigBase::Create @@ -179,6 +177,24 @@ bool wxConfigBase::Read(const wxString& key, bool* val, bool defVal) const } // 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; @@ -192,6 +208,15 @@ bool wxConfigBase::Write(const wxString& key, bool value) return Write(key, l); } +wxString wxConfigBase::ExpandEnvVars(const wxString& str) const +{ + wxString tmp; // Required for BC++ + if (IsExpandingEnvVars()) + tmp = wxExpandEnvVars(str); + else + tmp = str; + return tmp; +} // ---------------------------------------------------------------------------- // wxConfigPathChanger @@ -201,16 +226,21 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer, const wxString& strEntry) { m_pContainer = (wxConfigBase *)pContainer; - wxString strPath = strEntry.Before(wxCONFIG_PATH_SEPARATOR); - // special case of "/keyname" when there is nothing before "/" - if ( strPath.IsEmpty() && ((!strEntry.IsEmpty()) && strEntry[0] == wxCONFIG_PATH_SEPARATOR )) + // 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.Right(wxCONFIG_PATH_SEPARATOR); + m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR); m_strOldPath = m_pContainer->GetPath(); m_strOldPath += wxCONFIG_PATH_SEPARATOR; m_pContainer->SetPath(strPath); @@ -248,9 +278,9 @@ wxString wxExpandEnvVars(const wxString& str) { Bracket_None, Bracket_Normal = ')', - Bracket_Curly = '}', + Bracket_Curly = '}' #ifdef __WXMSW__ - Bracket_Windows = '%' // yeah, Windows people are a bit strange ;-) + ,Bracket_Windows = '%' // yeah, Windows people are a bit strange ;-) #endif }; @@ -383,4 +413,7 @@ void wxSplitPath(wxArrayString& aParts, const char *sz) } } +#endif + + // wxUSE_CONFIG