Commits

llibra  committed 0082116

Implemented KC.CUR:REMOVE.

  • Participants
  • Parent commits 65cb2e9

Comments (0)

Files changed (3)

File src/cur.lisp

         (error cur "Can't set the value of the current record.")
         t)))
 
+(defun remove (cur)
+  (if (zerop (kccurremove cur))
+      (error cur "Can't remove the current record.")
+      t))
+
 (defun jump (cur)
   (if (zerop (kccurjump cur))
       (error cur "Can't jump to the first record.")

File src/packages.lisp

 (defpackage :kyoto-cabinet.cursor.base
   (:nicknames :kc.cur.base)
   (:use :cl :cffi :kc.ffi :kc.type :kc.var :kc.conv :kc.util)
-  (:shadow :error :delete :get)
-  (:export :error :db :delete :accept :set-value :jump :with-cursor :get-key
-           :get-value :get))
+  (:shadow :error :delete :remove :get)
+  (:export :error :db :delete :accept :set-value :remove :jump :with-cursor
+           :get-key :get-value :get))
 
 (defpackage :kyoto-cabinet.cursor.low-level
   (:nicknames :kc.cur.low)
   (:nicknames :kc.cur)
   (:use :cl :cffi :kc.ffi :kc.type :kc.var :kc.conv :kc.util :kc.cur.base)
   (:shadow :set-value :get-key :get-value :get)
-  (:shadowing-import-from :kc.cur.base :error :delete)
-  (:export :error :db :delete :set-value :jump :with-cursor :get-key :get-value
-           :get))
+  (:shadowing-import-from :kc.cur.base :error :delete :remove)
+  (:export :error :db :delete :set-value :remove :jump :with-cursor :get-key
+           :get-value :get))
     (5am:test (set-value/set :compile-at :definition-time)
       (body #'kc.cur:set-value key old new))))
 
+(5am:test remove
+  (with-new-db (db)
+    (kc.db:set db "x" "1")
+    (kc.cur:with-cursor (cur db)
+      (kc.cur:remove cur))
+    (5am:signals kc.db:error (kc.db:get db "x"))
+    (5am:is (zerop (kc.db:count db)))))
+
 (5am:test jump
   (with-new-db (db)
     (let ((cur (kc.db:cursor db)))