VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Bucket"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit



Private Type bucket_prop_t
    PropName As String
    Value As Variant
End Type

Private properties() As bucket_prop_t
Private num_props As Long

Public Sub Merge(MergeWith As Bucket, Optional InheritValuesFrom As Boolean = True)
End Sub

Public Sub Clone(out As Bucket)
    out.Release
    Dim i As Long
    For i = 0 To num_props
        out.SetVal properties(i).PropName, _
        properties(i).Value
    Next i
End Sub

Public Sub Deserialize(Filename As String)
    Open Filename For Binary As #1
    Get #1, , num_props
    Dim i As Long
    ReDim properties(num_props)
    For i = 0 To num_props
        Get #1, , properties(i)
    Next i
    
    Close #1
End Sub

Public Sub Serialize(Filename As String)
    Open Filename For Binary As #1
    Put #1, , num_props
    Put #1, , properties
    
    Close #1
End Sub

Public Sub SetVal(PropName As String, Val As Variant)
    If Not Prop_Exists(PropName) Then
        AddProperty PropName
        SetVal PropName, Val
        Exit Sub
    End If
    Dim i As Long
    For i = 0 To num_props
        If PropName = properties(i).PropName Then
            properties(i).Value = Val
            Exit Sub
        End If
    Next i
End Sub

Public Function GetVal(PropName As String) As Variant
    If Not Prop_Exists(PropName) Then
        AddProperty PropName
        GetVal = GetVal(PropName)
        Exit Function
    End If
    Dim i As Long
    For i = 0 To num_props
        If PropName = properties(i).PropName Then
            GetVal = properties(i).Value
            Exit Function
        End If
    Next i
End Function

Public Sub RemoveProperty(PropName As String)
    For i = 0 To num_props
        If PropName = properties(i).PropName Then
            properties(i).PropName = properties(num_props - 1).PropName
            properties(i).Value = properties(num_props - 1).Value
            num_props = num_props - 1
            Exit Function
        End If
    Next i
End Sub

Public Sub AddProperty(PropName As String)
    If Prop_Exists(PropName) Then Exit Sub
    ReDim Preserve properties(num_props + 1)
    num_props = num_props + 1
    properties(num_props).PropName = PropName
End Sub

Private Function Prop_Exists(PropName As String) As Boolean
    Dim i As Long
    If num_props = -1 Then
        Prop_Exists = False
        Exit Function
    End If
    For i = 0 To num_props
        If PropName = properties(i).PropName Then
            Prop_Exists = True
            Exit Function
        End If
    Next i
    Prop_Exists = False
End Function

Public Sub Release()
    num_props = -1
    ReDim properties(0)
End Sub

Private Sub Class_Initialize()
    num_props = -1
End Sub
