// ----------------------------------------------------------------------------
// we put our data in HKLM\SOFTWARE_KEY\appname
-#define SOFTWARE_KEY wxString("Software\\")
+#define SOFTWARE_KEY wxString(wxT("Software\\"))
// ----------------------------------------------------------------------------
// global functions
// registry APIs want backslashes instead of slashes
wxString strRegPath;
- size_t len = m_strPath.length();
+ if ( !m_strPath.empty() )
+ {
+ size_t len = m_strPath.length();
- const wxChar *src = m_strPath.c_str();
- wxChar *dst = strRegPath.GetWriteBuf(len);
+ const wxChar *src = m_strPath.c_str();
+ wxChar *dst = strRegPath.GetWriteBuf(len);
- const wxChar *end = src + len;
- for ( ; src < end; src++, dst++ )
- {
- if ( *src == wxCONFIG_PATH_SEPARATOR )
- *dst = _T('\\');
- else
- *dst = *src;
- }
+ const wxChar *end = src + len;
+ for ( ; src < end; src++, dst++ )
+ {
+ if ( *src == wxCONFIG_PATH_SEPARATOR )
+ *dst = _T('\\');
+ else
+ *dst = *src;
+ }
- strRegPath.UngetWriteBuf(len);
+ strRegPath.UngetWriteBuf(len);
+ }
// this is not needed any longer as we don't create keys unnecessarily any
// more (now it is done on demand, i.e. only when they're going to contain
// reading/writing
// ----------------------------------------------------------------------------
-bool wxRegConfig::Read(const wxString& key, wxString *pStr) const
+bool wxRegConfig::DoReadString(const wxString& key, wxString *pStr) const
{
- wxConfigPathChanger path(this, key);
-
- bool bQueryGlobal = TRUE;
+ wxCHECK_MSG( pStr, FALSE, _T("wxRegConfig::Read(): NULL param") );
- // if immutable key exists in global key we must check that it's not
- // overriden by the local key with the same name
- if ( IsImmutable(path.Name()) ) {
- if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) {
- if ( m_keyLocal.Exists() && LocalKey().HasValue(path.Name()) ) {
- wxLogWarning(wxT("User value for immutable key '%s' ignored."),
- path.Name().c_str());
- }
- *pStr = wxConfigBase::ExpandEnvVars(*pStr);
- return TRUE;
- }
- else {
- // don't waste time - it's not there anyhow
- bQueryGlobal = FALSE;
- }
- }
-
- // first try local key
- if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) ||
- (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) {
- // nothing to do
-
- *pStr = wxConfigBase::ExpandEnvVars(*pStr);
- return TRUE;
- }
-
- return FALSE;
-}
-
-bool wxRegConfig::Read(const wxString& key, wxString *pStr,
- const wxString& szDefault) const
-{
wxConfigPathChanger path(this, key);
bool bQueryGlobal = TRUE;
// first try local key
if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) ||
(bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) {
- *pStr = wxConfigBase::ExpandEnvVars(*pStr);
return TRUE;
}
- else {
- if ( IsRecordingDefaults() ) {
- ((wxRegConfig*)this)->Write(key, szDefault);
- }
-
- // default value
- *pStr = szDefault;
- }
-
- *pStr = wxConfigBase::ExpandEnvVars(*pStr);
return FALSE;
}
-bool wxRegConfig::Read(const wxString& key, long *plResult) const
+// this exactly reproduces the string version above except for ExpandEnvVars(),
+// we really should avoid this code duplication somehow...
+
+bool wxRegConfig::DoReadLong(const wxString& key, long *plResult) const
{
+ wxCHECK_MSG( plResult, FALSE, _T("wxRegConfig::Read(): NULL param") );
+
wxConfigPathChanger path(this, key);
bool bQueryGlobal = TRUE;
(bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), plResult)) ) {
return TRUE;
}
+
return FALSE;
}
-bool wxRegConfig::Write(const wxString& key, const wxString& szValue)
+bool wxRegConfig::DoWriteString(const wxString& key, const wxString& szValue)
{
wxConfigPathChanger path(this, key);
return LocalKey().SetValue(path.Name(), szValue);
}
-bool wxRegConfig::Write(const wxString& key, long lValue)
+bool wxRegConfig::DoWriteLong(const wxString& key, long lValue)
{
wxConfigPathChanger path(this, key);
if ( m_keyLocal.IsEmpty() ) {
wxString strKey = GetPath().AfterLast(wxCONFIG_PATH_SEPARATOR);
- SetPath(".."); // changes m_keyLocal
+ SetPath(_T("..")); // changes m_keyLocal
return LocalKey().DeleteKey(strKey);
}
}