]> git.saurik.com Git - wxWidgets.git/commitdiff
Rename() (partly) implemented for wxRegConf
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Jan 1999 21:59:43 +0000 (21:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Jan 1999 21:59:43 +0000 (21:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/regconf.cpp
src/msw/registry.cpp

index 99382c2ce2d9ea21a4d13b54729c6827cab97cad..4bc56da8b640542c17a45375c071ded36a5d5584 100644 (file)
@@ -437,6 +437,67 @@ bool wxRegConfig::Write(const wxString& key, long lValue)
   return m_keyLocal.SetValue(path.Name(), lValue);
 }
 
+// ----------------------------------------------------------------------------
+// renaming
+// ----------------------------------------------------------------------------
+
+bool wxRegConfig::RenameEntry(const wxString& oldName, const wxString& newName)
+{
+    // check that the old entry exists...
+    if ( !HasEntry(oldName) )
+        return FALSE;
+
+    // and that the new one doesn't
+    if ( HasEntry(newName) )
+        return FALSE;
+
+    // delete the old entry and create the new one - but do in the reverse
+    // order to not lose the data if Create() fails
+
+    bool ok;
+    if ( m_keyLocal.IsNumericValue(oldName) )
+    {
+        long val;
+        ok = m_keyLocal.QueryValue(oldName, &val) &&
+             m_keyLocal.SetValue(newName, val);
+    }
+    else
+    {
+        wxString val;
+        ok = m_keyLocal.QueryValue(oldName, val) &&
+             m_keyLocal.SetValue(newName, val);
+    }
+
+    if ( !ok )
+        return FALSE;
+
+    if ( !m_keyLocal.DeleteValue(oldName) )
+    {
+        m_keyLocal.DeleteValue(newName);
+
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName)
+{
+    // check that the old group exists...
+    if ( !HasGroup(oldName) )
+        return FALSE;
+
+    // and that the new one doesn't
+    if ( HasGroup(newName) )
+        return FALSE;
+
+    // TODO there is no way to rename a registry key - we must do a deep copy
+    //      ourselves
+    wxFAIL_MSG("Registry key renaming not implemented");
+
+    return FALSE;
+}
+
 // ----------------------------------------------------------------------------
 // deleting
 // ----------------------------------------------------------------------------
index be45070aec0f48f976ba5ea1e157caa17ba6aac9..9ab127dd6739431553cf0b3040c6e0f87f0c8c8c 100644 (file)
@@ -544,10 +544,10 @@ bool wxRegKey::HasSubKey(const char *szKey) const
     return FALSE;
 }
 
-wxRegKey::ValueType wxRegKey::GetValueType(const char *szValue)
+wxRegKey::ValueType wxRegKey::GetValueType(const char *szValue) const
 {
   #ifdef  __WIN32__
-    if ( !Open() )
+    if ( ! CONST_CAST Open() )
       return Type_None;
 
     DWORD dwType;