This is an interface to the GNU DataBase Manager, which extends the standard
UNIX <ndbm.h
>.
When this module is present, *FEATURES*
contains the
symbol :GDBM
.
See modules/gdbm/test.tst
for sample usage.
GDBM module API
(GDBM:GDBM-VERSION)
Return the version string.
(GDBM:GDBM-OPEN filename
&KEY
:BLOCKSIZE :READ-WRITE :OPTION :MODE :DEFAULT-KEY-TYPE
:DEFAULT-VALUE-TYPE)
Open filename
database file.
The return value is a GDBM structure.
:READ-WRITE
can have one of following values:
:READER |
:WRITER |
:WRCREAT |
:NEWDB |
and :OPTION
is one of
:SYNC |
:NOLOCK |
:FAST |
CLISP can store and retrieve values of the following types:
STRING |
VECTOR (meaning anything that can be COERCE d to
( ) |
EXT:32BIT-VECTOR (meaning
( ) |
INTEGER |
SINGLE-FLOAT |
DOUBLE-FLOAT |
and :DEFAULT-KEY-TYPE
and :DEFAULT-VALUE-TYPE-TYPE
should be one of
those. If not specified (or NIL
), the :TYPE
argument is required in the access functions below.
If filename
is actually an existing GDBM structure,
then it is re-opened (if it has been closed), and returned as is.
The return value is EXT:FINALIZE
d with
GDBM-CLOSE
.
(GDBM:GDBM-DEFAULT-KEY-TYPE db
)
(GDBM:GDBM-DEFAULT-VALUE-TYPE db
)
Return the default data conversion types.
(GDBM:GDBM-CLOSE db
)
(GDBM:GDBM-OPEN-P db
)
Check whether db
has been already closed.
(GDBM:GDBM-STORE db
key
contents
&KEY
:FLAG)
db
is the GDBM structure returned by
GDBM-OPEN
.
key
is the key datum.
contents
is the data to be associated with the key.
:FLAG
can have one of following values:
:INSERT |
:REPLACE |
(GDBM:GDBM-FETCH db
key
&KEY
(TYPE (GDBM:GDBM-DEFAULT-VALUE-TYPE db
)))
:TYPE
argument specifies the return type.
(GDBM:GDBM-DELETE db
key
)
key
and its contents.
(GDBM:GDBM-EXISTS db
key
)
(GDBM:GDBM-FIRSTKEY db
&KEY
(TYPE (GDBM:GDBM-DEFAULT-KEY-TYPE db
)))
:TYPE
.
If the database has no entries, the return value is NIL
.
(GDBM:GDBM-NEXTKEY db
key
&KEY
(TYPE (GDBM:GDBM-DEFAULT-KEY-TYPE db
)))
key
, as :TYPE
,
or NIL
if there are no further entries.
(GDBM:GDBM-REORGANIZE db
)
(GDBM:GDBM-SYNC db
)
(GDBM:GDBM-SETOPT db
option
value
)
Set options on an already open database.
option
is one of following:
(GDBM:GDBM-FILE-SIZE db
)
lseek
.(GDBM:DO-DB (key
db
&REST
options
)
&BODY
body
)
options
are
passed to GDBM-FIRSTKEY
and GDBM-NEXTKEY
.
body
is passed to LOOP
, so you can use all the standard loop
contructs, e.g., (do-db (k db) :collect (list k (gdbm-fetch
k)))
will convert the database to an association list.
(GDBM:WITH-OPEN-DB (db
filename
&REST
options
)
&BODY
body
)
filename
, execute the body
, close
the database.These notes document CLISP version 2.49 | Last modified: 2010-07-07 |