@@ 73,6 73,7 @@ proc toStringView*(s: string): StringView {.inline.} =
proc toStringView*(buf: openarray[byte]): StringView {.inline.} =
if buf.len == 0: toStringView(nil, 0)
else: toStringView(unsafeAddr buf[0], buf.len)
+proc toStringView*(sv: StringView): StringView {.inline.} = sv
type Status {.importcpp: "tkrzw::Status".} = object
proc IsOK(st: Status): bool {.importcpp: "#.IsOK()".}
@@ 150,9 151,9 @@ proc close*(dbm: DBM) =
proc get*(dbm; key: StringView; buf: pointer; len: Natural): bool =
var src: CppString
- result = IsOK dbm.Get(key, addr src)
- result = result and (len == src.len.int)
- if result: copyMem(buf, src.data, len)
+ if IsOK dbm.Get(key, addr src):
+ result = len == src.len.int
+ if result: copyMem(buf, src.data, len)
proc get*[A,B](dbm; key: A; dst: var B): bool =
var src: CppString
@@ 1,6 1,6 @@
# Package
-version = "20220910"
+version = "20220922"
author = "Emery Hemingway"
description = "Wrapper of the Tkrzw key-value database library"
license = "Apache-2.0"