X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19454fa09211a94c2d284a932a67a0f8679f7a28..1eb20d4a0832f53fbbcf93ed291273fce2df45d0:/src/msw/regconf.cpp diff --git a/src/msw/regconf.cpp b/src/msw/regconf.cpp index 968053bea6..3becd8f334 100644 --- a/src/msw/regconf.cpp +++ b/src/msw/regconf.cpp @@ -1,14 +1,18 @@ /////////////////////////////////////////////////////////////////////////////// // Name: msw/regconf.cpp -// Purpose: +// Purpose: // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 27.04.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// +#ifdef __GNUG__ +#pragma implementation "regconf.h" +#endif + // ============================================================================ // declarations // ============================================================================ @@ -19,7 +23,7 @@ #include #include #include -#include +#include // ---------------------------------------------------------------------------- // constants @@ -51,9 +55,9 @@ bool TryGetValue(const wxRegKey& key, const wxString& str, long *plVal) // ctor/dtor // ---------------------------------------------------------------------------- wxRegConfig::wxRegConfig(const wxString& strRoot) - : m_keyLocalRoot(wxRegKey::HKCU, SOFTWARE_KEY + strRoot), + : m_keyLocalRoot(wxRegKey::HKCU, SOFTWARE_KEY + strRoot), m_keyLocal(m_keyLocalRoot, ""), - m_keyGlobalRoot(wxRegKey::HKLM, SOFTWARE_KEY + strRoot), + m_keyGlobalRoot(wxRegKey::HKLM, SOFTWARE_KEY + strRoot), m_keyGlobal(m_keyGlobalRoot, "") { // Create() will Open() if key already exists @@ -111,7 +115,7 @@ void wxRegConfig::SetPath(const wxString& strPath) // ---------------------------------------------------------------------------- /* - We want to enumerate all local keys/values after the global ones, but, of + We want to enumerate all local keys/values after the global ones, but, of course, we don't want to repeat a key which appears locally as well as globally twice. @@ -179,6 +183,20 @@ bool wxRegConfig::GetNextEntry (wxString& str, long& lIndex) return bOk; } +// ---------------------------------------------------------------------------- +// tests for existence +// ---------------------------------------------------------------------------- + +bool wxRegConfig::HasGroup(const wxString& strName) const +{ + return m_keyLocal.HasSubKey(strName) || m_keyGlobal.HasSubKey(strName); +} + +bool wxRegConfig::HasEntry(const wxString& strName) const +{ + return m_keyLocal.HasValue(strName) || m_keyGlobal.HasValue(strName); +} + // ---------------------------------------------------------------------------- // reading/writing // ---------------------------------------------------------------------------- @@ -189,68 +207,68 @@ bool wxRegConfig::Read(wxString& str, { PathChanger path(this, szKey); - 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 if ( IsImmutable(path.Name()) ) { if ( TryGetValue(m_keyGlobal, path.Name(), str) ) { if ( m_keyLocal.HasValue(path.Name()) ) { - wxLogWarning("User value for immutable key '%s' ignored.", + wxLogWarning("User value for immutable key '%s' ignored.", 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 ( TryGetValue(m_keyLocal, path.Name(), str) || (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), str)) ) { - return true; + return TRUE; } // default value str = szDefault; - return false; + return FALSE; } bool wxRegConfig::Read(long &lValue, const char *szKey, long lDefault) const { PathChanger path(this, szKey); - 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 if ( IsImmutable(path.Name()) ) { if ( TryGetValue(m_keyGlobal, path.Name(), &lValue) ) { if ( m_keyLocal.HasValue(path.Name()) ) { - wxLogWarning("User value for immutable key '%s' ignored.", + wxLogWarning("User value for immutable key '%s' ignored.", 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 ( TryGetValue(m_keyLocal, path.Name(), &lValue) || (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), &lValue)) ) { - return true; + return TRUE; } // default lValue = lDefault; - return false; + return FALSE; } bool wxRegConfig::Write(const char *szKey, const char *szValue) @@ -259,7 +277,7 @@ bool wxRegConfig::Write(const char *szKey, const char *szValue) if ( IsImmutable(path.Name()) ) { wxLogError("Can't change immutable entry '%s'.", path.Name().c_str()); - return false; + return FALSE; } return m_keyLocal.SetValue(path.Name(), szValue); @@ -271,7 +289,7 @@ bool wxRegConfig::Write(const char *szKey, long lValue) if ( IsImmutable(path.Name()) ) { wxLogError("Can't change immutable entry '%s'.", path.Name().c_str()); - return false; + return FALSE; } return m_keyLocal.SetValue(path.Name(), lValue); @@ -285,7 +303,7 @@ bool wxRegConfig::DeleteEntry(const char *szValue, bool bGroupIfEmptyAlso) PathChanger path(this, szValue); if ( !m_keyLocal.DeleteValue(path.Name()) ) - return false; + return FALSE; if ( m_keyLocal.IsEmpty() ) { wxString strKey = GetPath().Right(APPCONF_PATH_SEPARATOR); @@ -293,7 +311,7 @@ bool wxRegConfig::DeleteEntry(const char *szValue, bool bGroupIfEmptyAlso) return m_keyLocal.DeleteKey(strKey); } - return true; + return TRUE; } bool wxRegConfig::DeleteGroup(const char *szKey) @@ -306,7 +324,7 @@ bool wxRegConfig::DeleteGroup(const char *szKey) bool wxRegConfig::DeleteAll() { // first of all, prevent the creation of new registry entries - Config::EnableAutosave(false); + Config::EnableAutosave(FALSE); m_keyLocal.Close(); m_keyGlobal.Close();