Commits

llibra committed 1a30eb8

Implemented LVDB.DB.FS:DELETE and LVDB.DB:DELETE.

Comments (0)

Files changed (3)

     (handle-error-pointer err-ptr)
     (values)))
 
+(defun delete (db opt key-fs key-len)
+  (with-error-pointer (err-ptr)
+    (leveldb-delete db opt key-fs key-len err-ptr)
+    (handle-error-pointer err-ptr)
+    (values)))
+
 (defun get (db opt key-fs key-len &key (as 'string))
   (with-foreign-object (val-len-ptr 'size_t)
     (with-error-pointer (err-ptr)
                                  (val-fs val-len (x->foreign-string val)))
     (lvdb.db.fs:put db opt key-fs key-len val-fs val-len)))
 
+(defun delete (db opt key)
+  (with-alloced-foreign-string (key-fs key-len (x->foreign-string key))
+    (lvdb.db.fs:delete db opt key-fs key-len)))
+
 (defun get (db opt key &rest args)
   (with-alloced-foreign-string (key-fs key-len (x->foreign-string key))
     (apply #'lvdb.db.fs:get db opt key-fs key-len args)))
   (vallen size_t)
   (errptr :pointer))
 
+(defcfun "leveldb_delete" :void
+  (db :pointer)
+  (options :pointer)
+  (key :pointer)
+  (keylen size_t)
+  (errptr :pointer))
+
 (defcfun "leveldb_get" :pointer
   (db :pointer)
   (options :pointer)
            :leveldb-readoptions-set-verify-checksums
            :leveldb-readoptions-set-fill-cache
 
-           :leveldb-open :leveldb-close :leveldb-put :leveldb-get))
+           :leveldb-open :leveldb-close :leveldb-put :leveldb-delete
+           :leveldb-get))
 
 (defpackage :leveldb.utilities
   (:nicknames :leveldb.util :lvdb.util)
 (defpackage :leveldb.database
   (:nicknames :leveldb.db :lvdb.db)
   (:use :cl :cffi :lvdb.ffi :lvdb.util :lvdb.conv)
-  (:shadow :close :get :open)
-  (:export :open :close :put :get))
+  (:shadow :open :close :delete :get)
+  (:export :open :close :put :delete :get))
 
 (defpackage :leveldb.database.foreign-string
   (:nicknames :leveldb.db.fs :lvdb.db.fs)
   (:use :cl :cffi :lvdb.ffi :lvdb.util :lvdb.conv)
-  (:shadow :get)
-  (:export :put :get))
+  (:shadow :delete :get)
+  (:export :put :delete :get))