Commit 8502e055 authored by Benoît Minisini's avatar Benoît Minisini

Settings.Clear() now takes an extra optional boolean argument that tells to...

Settings.Clear() now takes an extra optional boolean argument that tells to remove slots recursively.

[GB.SETTINGS]
* NEW: Settings.Clear() now takes an extra optional boolean argument that tells to remove slots recursively.
parent 2f8fccb4
......@@ -2,6 +2,18 @@
Public Sub Main()
Dim hSettings As Settings
hSettings = New Settings("~/test.conf")
'hSettings["/TestSuites/Count"] = 10
' For I = 1 To 10
' hSettings["/TestSuites/" & CStr(I) &/ "Name"] = "Name" & CStr(I)
' hSettings["/TestSuites/" & CStr(I) &/ "Tests"] = Rnd
' Next
' hSettings.Save
hSettings.Clear("/TestSuites", True)
hSettings.Save
End
' Private Sub Dump(hSettings As Settings)
......
......@@ -288,11 +288,12 @@ Public Sub _put(Value As Variant, Key As String)
End
Public Sub Clear(Optional ParentKey As String)
Public Sub Clear(Optional ParentKey As String, Recursive As Boolean)
Dim sSlot As String
Dim hSlot As Collection
Dim vVal As Variant
Dim sRemove As String
If Not ParentKey Then
If $cSlot.Count Then
......@@ -300,19 +301,37 @@ Public Sub Clear(Optional ParentKey As String)
$bModify = True
$bModifyAll = True
Endif
Else
sSlot = GetSlot(ParentKey &/ "g")
Return
Endif
sSlot = GetSlot(ParentKey &/ "g")
If Not Recursive Then
hSlot = $cSlot[sSlot]
If hSlot Then
For Each vVal In hSlot
$cModify[sSlot &/ hSlot.Key] = True
Next
$cSlot.Remove(sSlot)
$bModify = True
sRemove = sSlot
GoSub REMOVE_SLOT
Endif
Else
For Each hSlot In $cSlot
sRemove = $cSlot.Key
If sRemove = sSlot Or If sRemove Begins sSlot & "/" Then
GoSub REMOVE_SLOT
Endif
Next
Endif
Return
REMOVE_SLOT:
'Save()
For Each vVal In hSlot
$cModify[sRemove &/ hSlot.Key] = True
Next
$cSlot.Remove(sRemove)
$bModify = True
Return
End
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment