llibra avatar llibra committed 0082116

Implemented KC.CUR:REMOVE.

Comments (0)

Files changed (3)

         (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.")

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)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.