From 6d8335660f15c5701b922a3f478aab6e6abcc3d4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Jul 1998 17:56:43 +0000 Subject: [PATCH] HasGroup/Entry added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@190 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/regconf.h | 4 ++++ src/msw/regconf.cpp | 30 ++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/include/wx/msw/regconf.h b/include/wx/msw/regconf.h index 7277dff7f7..3bf2bcce57 100644 --- a/include/wx/msw/regconf.h +++ b/include/wx/msw/regconf.h @@ -42,6 +42,10 @@ public: virtual bool GetFirstEntry(wxString& str, long& lIndex); virtual bool GetNextEntry (wxString& str, long& lIndex); + // tests for existence + virtual bool HasGroup(const wxString& strName) const; + virtual bool HasEntry(const wxString& strName) const; + // read/write virtual bool Read(wxString&, const char *, const char * = 0) const; virtual bool Read(long&, const char *, long = 0) const; diff --git a/src/msw/regconf.cpp b/src/msw/regconf.cpp index c2d1d8e76b..3becd8f334 100644 --- a/src/msw/regconf.cpp +++ b/src/msw/regconf.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////////// // 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 @@ -23,7 +23,7 @@ #include #include #include -#include +#include // ---------------------------------------------------------------------------- // constants @@ -55,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 @@ -115,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. @@ -183,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 // ---------------------------------------------------------------------------- @@ -200,7 +214,7 @@ bool wxRegConfig::Read(wxString& str, 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()); } @@ -234,7 +248,7 @@ bool wxRegConfig::Read(long &lValue, const char *szKey, long lDefault) const 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()); } -- 2.47.2