# $Id: s.JufGdbmStorage.xotcl 1.5 01/03/23 21:55:32+01:00 neumann@somewhere.wu-wien.ac.at $
package provide xotcl::store::jufgdbm 0.81

package require xotcl::store::juf_gdbm
package require xotcl::store

#
# a simple GNU Gdbm DB Store Access
#
Class Storage=JufGdbm -superclass Storage
Storage=JufGdbm instproc open f {
  set [self]::persistenceDB [juf_gdbm open $f rwc]
}

Storage=JufGdbm instproc store {k v} {
  #[self] showCall
  juf_gdbm store [set [self]::persistenceDB] $k $v
}

Storage=JufGdbm instproc list {} {
  juf_gdbm list [set [self]::persistenceDB]
}

Storage=JufGdbm instproc fetch {k var} {
  [self] instvar persistenceDB
  if {[juf_gdbm exists $persistenceDB $k]} {
    upvar $var value
    set value [juf_gdbm fetch $persistenceDB $k]
    return 1
  }
  return 0
}

Storage=JufGdbm instproc close args {
  juf_gdbm close [set [self]::persistenceDB]
}

Storage=JufGdbm instproc delete k {
  juf_gdbm delete [set [self]::persistenceDB] $k
}
