#include "wx/config.h"
-#ifndef __WIN16__
-
#include "wx/msw/registry.h"
#include "wx/msw/regconf.h"
if ( bDoUseGlobal )
{
wxLogNull nolog;
- m_keyGlobalRoot.Open();
- m_keyGlobal.Open();
+ m_keyGlobalRoot.Open(wxRegKey::Read);
+ m_keyGlobal.Open(wxRegKey::Read);
}
}
-wxRegConfig::~wxRegConfig()
-{
- // nothing to do - key will be closed in their dtors
-}
-
// ----------------------------------------------------------------------------
// path management
// ----------------------------------------------------------------------------
strFullPath.reserve(2*m_strPath.length());
strFullPath << m_strPath;
- if ( strFullPath.Len() == 0 ||
+ if ( strFullPath.Len() == 0 ||
strFullPath.Last() != wxCONFIG_PATH_SEPARATOR )
- strFullPath << wxCONFIG_PATH_SEPARATOR;
+ strFullPath << wxCONFIG_PATH_SEPARATOR;
strFullPath << strPath;
}
// change current key(s)
m_keyLocal.SetName(m_keyLocalRoot, strRegPath);
- m_keyGlobal.SetName(m_keyGlobalRoot, strRegPath);
- // don't create it right now, wait until it is accessed
- //m_keyLocal.Create();
+ if ( GetStyle() & wxCONFIG_USE_GLOBAL_FILE )
+ {
+ m_keyGlobal.SetName(m_keyGlobalRoot, strRegPath);
- wxLogNull nolog;
- m_keyGlobal.Open();
+ wxLogNull nolog;
+ m_keyGlobal.Open(wxRegKey::Read);
+ }
}
// ----------------------------------------------------------------------------
while ( m_keyGlobal.GetNextKey(str, lIndex) ) {
if ( !m_keyLocal.Exists() || !LocalKey().HasSubKey(str) ) {
// ok, found one - return it
- return TRUE;
+ return true;
}
}
// if we don't have the key at all, don't try to enumerate anything under it
if ( !m_keyLocal.Exists() )
- return FALSE;
+ return false;
// much easier with local entries: get the next one we find
// (don't forget to clear our flag bit and set it again later)
while ( m_keyGlobal.GetNextValue(str, lIndex) ) {
if ( !m_keyLocal.Exists() || !LocalKey().HasValue(str) ) {
// ok, found one - return it
- return TRUE;
+ return true;
}
}
// if we don't have the key at all, don't try to enumerate anything under it
if ( !m_keyLocal.Exists() )
- return FALSE;
+ return false;
// much easier with local entries: get the next one we find
// (don't forget to clear our flag bit and set it again later)
bool wxRegConfig::DoReadString(const wxString& key, wxString *pStr) const
{
- wxCHECK_MSG( pStr, FALSE, _T("wxRegConfig::Read(): NULL param") );
+ wxCHECK_MSG( pStr, false, _T("wxRegConfig::Read(): NULL param") );
wxConfigPathChanger path(this, key);
- bool bQueryGlobal = TRUE;
+ bool bQueryGlobal = true;
// if immutable key exists in global key we must check that it's not
// overriden by the local key with the same name
path.Name().c_str());
}
- return TRUE;
+ return true;
}
else {
// don't waste time - it's not there anyhow
- bQueryGlobal = FALSE;
+ bQueryGlobal = false;
}
}
// first try local key
if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) ||
(bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
// this exactly reproduces the string version above except for ExpandEnvVars(),
bool wxRegConfig::DoReadLong(const wxString& key, long *plResult) const
{
- wxCHECK_MSG( plResult, FALSE, _T("wxRegConfig::Read(): NULL param") );
+ wxCHECK_MSG( plResult, false, _T("wxRegConfig::Read(): NULL param") );
wxConfigPathChanger path(this, key);
- bool bQueryGlobal = TRUE;
+ bool bQueryGlobal = true;
// if immutable key exists in global key we must check that it's not
// overriden by the local key with the same name
path.Name().c_str());
}
- return TRUE;
+ return true;
}
else {
// don't waste time - it's not there anyhow
- bQueryGlobal = FALSE;
+ bQueryGlobal = false;
}
}
// first try local key
if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), plResult)) ||
(bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), plResult)) ) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool wxRegConfig::DoWriteString(const wxString& key, const wxString& szValue)
if ( IsImmutable(path.Name()) ) {
wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str());
- return FALSE;
+ return false;
}
return LocalKey().SetValue(path.Name(), szValue);
if ( IsImmutable(path.Name()) ) {
wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str());
- return FALSE;
+ return false;
}
return LocalKey().SetValue(path.Name(), lValue);
{
// check that the old entry exists...
if ( !HasEntry(oldName) )
- return FALSE;
+ return false;
// and that the new one doesn't
if ( HasEntry(newName) )
- return FALSE;
+ return false;
return m_keyLocal.RenameValue(oldName, newName);
}
{
// check that the old group exists...
if ( !HasGroup(oldName) )
- return FALSE;
+ return false;
// and that the new one doesn't
if ( HasGroup(newName) )
- return FALSE;
+ return false;
return wxRegKey(m_keyLocal, oldName).Rename(newName);
}
// ----------------------------------------------------------------------------
// deleting
// ----------------------------------------------------------------------------
-bool wxRegConfig::DeleteEntry(const wxString& value, bool WXUNUSED(bGroupIfEmptyAlso))
+
+bool wxRegConfig::DeleteEntry(const wxString& value, bool bGroupIfEmptyAlso)
{
wxConfigPathChanger path(this, value);
if ( m_keyLocal.Exists() ) {
if ( !m_keyLocal.DeleteValue(path.Name()) )
- return FALSE;
+ return false;
- if ( m_keyLocal.IsEmpty() ) {
+ if ( bGroupIfEmptyAlso && m_keyLocal.IsEmpty() ) {
wxString strKey = GetPath().AfterLast(wxCONFIG_PATH_SEPARATOR);
SetPath(_T("..")); // changes m_keyLocal
return LocalKey().DeleteKey(strKey);
}
}
- return TRUE;
+ return true;
}
bool wxRegConfig::DeleteGroup(const wxString& key)
{
wxConfigPathChanger path(this, key);
- return m_keyLocal.Exists() ? LocalKey().DeleteKey(path.Name()) : TRUE;
+ return m_keyLocal.Exists() ? LocalKey().DeleteKey(path.Name()) : true;
}
bool wxRegConfig::DeleteAll()
return bOk;
}
-#endif
- // __WIN16__
-
#endif
// wxUSE_CONFIG