3 * Copyright (C) 2008-2010 Evan Nemerson
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Evan Nemerson <evan@coeus-group.com>
23 namespace TokyoCabinet {
24 [CCode (cname = "tcversion")]
25 public const string version;
27 [CCode (cname = "tcfatalfunc")]
28 public delegate void FatalFunc (string msg);
29 [CCode (cname = "TCCMP")]
30 public delegate int CompareFunc (uint8[] a, uint8[] b);
31 [CCode (cname = "TCCODEC")]
32 public delegate uint8[] CodecFunc (uint8[] data);
33 [CCode (cname = "TCPDPROC")]
34 public delegate uint8[] ProcessDuplicateFunc (uint8[] value);
35 [CCode (cname = "TCITER")]
36 public delegate bool IteratorFunc (uint8[] key, uint8[] data);
38 [CCode (lower_case_cprefix = "tc", cheader_filename = "tcutil.h")]
40 public static void* malloc (size_t size);
41 public static void* calloc (size_t nmemb, size_t size);
42 public static void* realloc (void *ptr, size_t size);
43 [CCode (cname = "tcmemdup")]
44 public static void* copy (void *ptr, size_t size);
45 public static string strdup (string str);
46 public static void free ([CCode (type = "void*")] void* ptr);
48 public static uint8[]? copy_and_free (uint8[]? data) {
52 uint8[] ret = new uint8[data.length];
53 GLib.Memory.copy (ret, data, data.length);
54 TokyoCabinet.Memory.free (data);
57 public static string? copy_and_free_string (string? str) {
62 TokyoCabinet.Memory.free (str);
67 [Compact, CCode (cname = "TCXSTR", cprefix = "tcxstr", free_function = "tcxstrdel", cheader_filename = "tcutil.h", copy_function = "tcxstrdup")]
68 public class XString {
70 [CCode (cname = "tcxstrnew2")]
71 public XString.from_string (string str);
72 [CCode (cname = "tcxstrnew3")]
73 public XString.sized (int asiz);
74 [CCode (cname = "tcxstrdup")]
75 public XString copy ();
76 [CCode (cname = "tcxstrcat")]
77 public void append (uint8[] data);
78 [CCode (cname = "tcxstrcat2")]
79 public void append_string (string str);
82 public void printf (string format, ...);
84 [CCode (cname = "ptr", array_length_cname = "size")]
86 [CCode (cname = "ptr")]
88 [CCode (cname = "asize")]
92 [Compact, CCode (cname = "TCLIST", cprefix = "tclist", free_function = "tclistdel", cheader_filename = "tcutil.h", copy_function = "tclistdup")]
94 [CCode (has_target = false)]
95 public delegate int CompareDatumFunc (TokyoCabinet.List.Datum a, TokyoCabinet.List.Datum b);
97 [CCode (cname = "TCLISTDATUM", has_type_id = false)]
99 [CCode (cname = "ptr", array_length_cname = "size")]
101 [CCode (cname = "ptr")]
106 [CCode (cname = "tclistnew3")]
107 public List.from_strings (string s1, ...);
108 [CCode (cname = "tclistnew2")]
109 public List.sized (int anum);
110 [CCode (cname = "tclistdup")]
112 [CCode (cname = "tclistval")]
113 public unowned uint8[]? index (int index);
114 [CCode (cname = "tclistval2")]
115 public unowned string? index_string (int index);
116 public void push (uint8[] data);
117 [CCode (cname = "tclistpush2")]
118 public void push_string (string str);
119 [CCode (cname = "tclistpop")]
120 public unowned uint8[] _pop ();
121 [CCode (cname = "_vala_tclistpop")]
122 public uint8[] pop () {
123 return TokyoCabinet.Memory.copy_and_free (this._pop ());
125 [CCode (cname = "tclistpop2")]
126 public unowned string _pop_string ();
127 [CCode (cname = "_vala_tclistpop2")]
128 public string pop_string () {
129 return TokyoCabinet.Memory.copy_and_free_string (this._pop_string ());
131 public void unshift (uint8[] data);
132 [CCode (cname = "tclistunshift2")]
133 public void unshift_string (string str);
134 [CCode (cname = "tclistshift")]
135 public unowned uint8[] _shift ();
136 [CCode (cname = "_vala_tclistshift")]
137 public uint8[] shift () {
138 return TokyoCabinet.Memory.copy_and_free (this._shift ());
140 [CCode (cname = "tclistshift2")]
141 public unowned string _shift_string ();
142 [CCode (cname = "_vala_tclistshift2")]
143 public string shift_string () {
144 return TokyoCabinet.Memory.copy_and_free_string (this._shift_string ());
146 public void insert (int index, uint8[] data);
147 [CCode (cname = "tclistinsert2")]
148 public void insert_string (int index, string str);
149 [CCode (cname = "tclistremove")]
150 public unowned uint8[] _remove (int index);
151 [CCode (cname = "_vala_tclistremove")]
152 public uint8[] remove (int index) {
153 return TokyoCabinet.Memory.copy_and_free (this._remove (index));
155 [CCode (cname = "tclistremove2")]
156 public unowned string _remove_string (int index);
157 [CCode (cname = "_vala_tclistremove2")]
158 public string remove_string (int index) {
159 return TokyoCabinet.Memory.copy_and_free_string (this._remove_string (index));
161 [CCode (cname = "tclistover")]
162 public void replace (int index, uint8[] data);
163 [CCode (cname = "tclistover2")]
164 public void replace_string (int index, string str);
165 [CCode (cname = "tclistsort")]
166 public void sort_sensitive ();
167 [CCode (cname = "tclistsortci")]
168 public void sort_insensitive ();
169 public void sort (TokyoCabinet.List.CompareDatumFunc func);
170 [CCode (cname = "tclistlsearch")]
171 public int linear_search (uint8[] ptr);
172 [CCode (cname = "tclistbsearch")]
173 public int binary_search (uint8[] ptr);
174 public void clear ();
175 [CCode (cname = "tclistdump")]
176 public unowned uint8[] _dump ();
177 [CCode (cname = "_vala_tclistdump")]
178 public uint8[] dump () {
179 return TokyoCabinet.Memory.copy_and_free (this._dump ());
181 public List.load (uint8[] ptr);
182 [CCode (cname = "tclistinvert")]
183 public void reverse ();
185 public void push_printf (string fmt, ...);
187 [CCode (array_length_cname = "anum")]
188 public TokyoCabinet.List.Datum[] array;
190 [CCode (cname = "num")]
194 [Compact, CCode (cname = "TCMAPREC")]
195 public class MapRecord {
196 [CCode (cname = "ksiz")]
197 public int32 key_size;
198 [CCode (cname = "vsiz")]
199 public int32 value_size;
200 public TokyoCabinet.MapRecord left;
201 public TokyoCabinet.MapRecord right;
202 public TokyoCabinet.MapRecord prev;
203 public TokyoCabinet.MapRecord next;
206 [Compact, CCode (cname = "TCMAP", cprefix = "tcmap", free_function = "tcmapdel", cheader_filename = "tcutil.h", copy_function = "tcmapdup")]
209 [CCode (cname = "tcmapnew2")]
210 public Map.sized (uint32 bnum);
211 [CCode (cname = "tcmapnew3")]
212 public Map.from_strings (string key1, string val1, ...);
213 [CCode (cname = "tcmapload")]
214 public Map.load (uint8[] ptr);
215 [CCode (cname = "tcmapdup")]
217 [CCode (cname = "tcmapputkeep")]
218 public void put (uint8[] key, uint8[] value);
219 [CCode (cname = "tcmapputkeep2")]
220 public void put_string (string key, string value);
221 [CCode (cname = "tcmapput")]
222 public bool replace (uint8[] key, uint8[] value);
223 [CCode (cname = "tcmapput2")]
224 public bool replace_string (string key, string value);
225 [CCode (cname = "tcmapputcat")]
226 public void append (uint8[] key, uint8[] value);
227 [CCode (cname = "tcmapputcat2")]
228 public void append_string (string key, string value);
229 [CCode (cname = "tcmapout")]
230 public bool remove (uint8[] key);
231 [CCode (cname = "tcmapout2")]
232 public bool remove_string (string key);
233 [CCode (cname = "tcmapget")]
234 public unowned uint8[]? get (uint8[] key);
235 [CCode (cname = "tcmapget2")]
236 public unowned string? get_string (string key);
237 public bool move (uint8[] key, bool head = true);
238 [CCode (cname = "tcmapmove2")]
239 public bool move_string (string key, bool head = true);
240 [CCode (cname = "tcmapiterinit")]
241 public void iterator_init ();
242 [CCode (cname = "tcmapiternext")]
243 public unowned uint8[] iterator_next ();
244 [CCode (cname = "tcmapiternext2")]
245 public unowned string? iterator_next_string ();
246 [CCode (cname = "tcmapiterval2")]
247 public unowned string? iterator_value_string (string key);
248 [CCode (cname = "tcmapiterval")]
249 public unowned uint8[]? iterator_value (uint8[] key);
250 public TokyoCabinet.List keys ();
251 [CCode (cname = "tcmapvals")]
252 public TokyoCabinet.List values ();
253 [CCode (cname = "tcmapaddint")]
254 public int add_int (uint8[] key, int num);
255 [CCode (cname = "tcmapadddouble")]
256 public double add_double (uint8[] key, double num);
257 public void clear ();
258 [CCode (cname = "tcmapcutfront")]
259 public void cut_front (int num);
260 [CCode (cname = "tcmapdump")]
261 public unowned uint8[] _dump ();
262 [CCode (cname = "_vala_tcmapdump")]
263 public uint8[] dump () {
264 return TokyoCabinet.Memory.copy_and_free (this._dump ());
267 [CCode (array_length_cname = "bnum", array_length_type = "guint32")]
268 public TokyoCabinet.MapRecord[] buckets;
269 public TokyoCabinet.MapRecord first;
270 public TokyoCabinet.MapRecord last;
271 public TokyoCabinet.MapRecord cur;
272 [CCode (cname = "rnum")]
273 public uint64 num_records;
274 [CCode (cname = "msiz")]
278 [Compact, CCode (cname = "TCTREE", cprefix = "tctree", free_function = "tctreedel", cheader_filename = "tcutil.h", copy_function = "tctreedup")]
280 [CCode (cname = "TREECMP")]
281 public delegate int Compare (uint8[] a, uint8[] b);
283 [Compact, CCode (cname = "TCTREEREC")]
284 public class Record {
285 [CCode (cname = "ksiz")]
286 public int32 key_size;
287 [CCode (cname = "vsiz")]
288 public int32 value_size;
289 TokyoCabinet.Tree.Record left;
290 TokyoCabinet.Tree.Record right;
293 [CCode (cname = "tctreecmplexical")]
294 public static int compare_lexical (uint8[] a, uint8[] b);
295 [CCode (cname = "tctreecmpdecimal")]
296 public static int compare_decimal (uint8[] a, uint8[] b);
297 [CCode (cname = "tctreecmpint32")]
298 public static int compare_int32 (uint8[] a, uint8[] b);
299 [CCode (cname = "tctreecmpint64")]
300 public static int compare_int64 (uint8[] a, uint8[] b);
302 [CCode (cname = "tctreenew2")]
303 public Tree (TokyoCabinet.Tree.Compare cmp = TokyoCabinet.Tree.compare_lexical);
304 public Tree.load (uint8[] data, TokyoCabinet.Tree.Compare cmp = TokyoCabinet.Tree.compare_lexical);
305 [CCode (cname = "tctreedup")]
307 [CCode (cname = "tctreeput")]
308 public void replace (uint8[] key, uint8[] value);
309 [CCode (cname = "tctreeput2")]
310 public void replace_string (string key, string value);
311 [CCode (cname = "tctreeputkeep")]
312 public bool put (uint8[] key, uint8[] value);
313 [CCode (cname = "tctreeputkeep2")]
314 public bool put_string (string key, string value);
315 [CCode (cname = "tctreeputcat")]
316 public void append (uint8[] key, uint8[] value);
317 [CCode (cname = "tctreeputcat2")]
318 public void append_string (string key, string value);
319 [CCode (cname = "tctreeout")]
320 public bool remove (uint8[] key);
321 [CCode (cname = "tctreeout2")]
322 public bool remove_string (string key);
323 [CCode (cname = "tctreeget")]
324 public unowned uint8[]? get (uint8[] key);
325 [CCode (cname = "tctreeget2")]
326 public unowned string? get_string (string key);
327 [CCode (cname = "tctreeiterinit")]
328 public void iterator_init ();
329 [CCode (cname = "tctreeiternext")]
330 public unowned uint8[]? iterator_next ();
331 [CCode (cname = "tctreeiternext2")]
332 public unowned string? iterator_next_string ();
333 [CCode (cname = "tctreeiterval")]
334 public unowned uint8[]? iterator_value (uint8[] key);
335 [CCode (cname = "tctreeiterval2")]
336 public unowned string? iterator_value_string (string key);
337 [CCode (cname = "tctreekeys")]
338 public TokyoCabinet.List get_keys ();
339 [CCode (cname = "tctreevals")]
340 public TokyoCabinet.List get_values ();
341 [CCode (cname = "tctreeaddint")]
342 public int add_int (uint8[] key, int num);
343 [CCode (cname = "tctreeadddouble")]
344 public double add_double (uint8[] key, double num);
345 public void clear ();
346 [CCode (cname = "tctreedump")]
347 public unowned uint8[] _dump ();
348 [CCode (cname = "tctreedump")]
349 public uint8[] dump () {
350 return TokyoCabinet.Memory.copy_and_free (this._dump ());
353 public TokyoCabinet.Tree.Record root;
354 public TokyoCabinet.Tree.Record cur;
357 [CCode (delegate_target = false)]
358 public TokyoCabinet.Tree.Compare cmp;
361 [Compact, CCode (cname = "TCMDB", cprefix = "tcmdb", free_function = "tctreedel", cheader_filename = "tcutil.h")]
364 public MDB.with_num_buckets (uint32 bnum);
365 public void replace (uint8[] key, uint8[] value);
366 [CCode (cname = "tcmdbput2")]
367 public void replace_string (string key, string value);
368 [CCode (cname = "tcmdbputkeep")]
369 public bool put (uint8[] key, uint8[] value);
370 [CCode (cname = "tcmdbputkeep2")]
371 public bool put_string (string key, string value);
372 [CCode (cname = "tcmdbputcat")]
373 public void append (uint8[] key, uint8[] value);
374 [CCode (cname = "tcmdbputcat2")]
375 public void append_string (string key, string value);
376 [CCode (cname = "tcmdbout")]
377 public bool remove (uint8[] key);
378 [CCode (cname = "tcmdbout2")]
379 public bool remove_string (string key);
380 [CCode (cname = "tcmdbget2")]
381 public unowned string? get_string (string key);
382 [CCode (cname = "tcmdbget")]
383 public unowned uint8[]? get (uint8[] key);
384 [CCode (cname = "tcmdbvsiz")]
385 public int value_size (uint8[] key);
386 [CCode (cname = "tcmdbvsiz2")]
387 public int value_size_string (string key);
388 [CCode (cname = "tcmdbiterinit")]
389 public void iterator_init ();
390 [CCode (cname = "tcmdbiternext")]
391 public uint8[]? iterator_next ();
392 [CCode (cname = "tcmdbiternext2")]
393 public unowned string? iterator_next_string ();
394 [CCode (cname = "tcmdbfwmkeys")]
395 public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
396 [CCode (cname = "tcmdbfwmkeys2")]
397 public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
398 [CCode (cname = "tcmdbrnum")]
399 public uint64 get_length ();
400 [CCode (cname = "tcmdbmsiz")]
401 public uint64 get_size ();
402 [CCode (cname = "tcmdbaddint")]
403 public int add_int (uint8[] key, int num);
404 [CCode (cname = "tcmdbadddouble")]
405 public double add_double (uint8[] key, double num);
406 [CCode (cname = "tcmdbvanish")]
407 public void clear ();
408 [CCode (cname = "tcmdbcutfront")]
409 public void cut_front (int num);
411 public uint64 length { get { return this.get_length (); } }
412 public uint64 size { get { return this.get_size (); } }
415 [Compact, CCode (cname = "TCNDB", cprefix = "tcndb", free_function = "tcndbdel", cheader_filename = "tcutil.h")]
417 [CCode (cname = "tcndbnew2")]
418 public NDB (TokyoCabinet.BDB.Compare cmp = TokyoCabinet.Tree.compare_lexical, void * cmpop = null);
419 public void replace (uint8[] key, uint8[] value);
420 [CCode (cname = "tcndbput2")]
421 public void replace_string (string key, string value);
422 [CCode (cname = "tcndbputkeep")]
423 public bool put (uint8[] key, uint8[] value);
424 [CCode (cname = "tcndbputkeep2")]
425 public bool put_string (string key, string value);
426 [CCode (cname = "tcndbputcat")]
427 public bool append (uint8[] key, uint8[] value);
428 [CCode (cname = "tcndbputcat2")]
429 public bool append_string (string key, string value);
430 [CCode (cname = "tcndbout")]
431 public bool remove (uint8[] key);
432 [CCode (cname = "tcndbout2")]
433 public bool remove_string (string key);
434 [CCode (cname = "tcndbget")]
435 private unowned uint8[]? _get (uint8[] key);
436 [CCode (cname = "_vala_tcndbget")]
437 public uint8[]? get (uint8[] key) {
438 return TokyoCabinet.Memory.copy_and_free (this._get (key));
440 public string? get_string (string key) {
441 unowned uint8[] kbuf = (uint8[]) key;
442 kbuf.length = (int) key.size ();
443 return (string) this.get (kbuf);
445 [CCode (cname = "tcndbvsiz")]
446 public int value_size (uint8[] key);
447 [CCode (cname = "tcndbvsiz2")]
448 public int value_size_string (string key);
449 [CCode (cname = "tcndbiterinit")]
450 public void iterator_init ();
451 [CCode (cname = "tcndbiterinit2")]
452 public void iterator_init_before (uint8[] key);
453 [CCode (cname = "tcndbiterinit3")]
454 public void iterator_init_before_string (string key);
455 [CCode (cname = "tcndbiternext")]
456 public unowned uint8[]? _iterator_next ();
457 public uint8[]? iterator_next () {
458 return TokyoCabinet.Memory.copy_and_free (this._iterator_next ());
460 [CCode (cname = "tcndbiternext2")]
461 public unowned string? _iterator_next_string ();
462 public string? iterator_next_string () {
463 return TokyoCabinet.Memory.copy_and_free_string (this._iterator_next_string ());
465 [CCode (cname = "tcndbfwmkeys")]
466 public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
467 [CCode (cname = "tcndbfwnkeys2")]
468 public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
469 [CCode (cname = "tcndbrnum")]
470 public uint64 get_length ();
471 [CCode (cname = "tcndbmsiz")]
472 public uint64 get_size ();
473 [CCode (cname = "tcndbaddint")]
474 public int add_int (uint8[] key, int num);
475 [CCode (cname = "tcndbadddouble")]
476 public double add_double (uint8[] key, double num);
477 [CCode (cname = "tcndbvanish")]
478 public void clear ();
479 [CCode (cname = "tcndbcutfringe")]
480 public void cut_fringe (int num);
482 public uint64 length { get { return this.get_length (); } }
483 public uint64 size { get { return this.get_size (); } }
486 [CCode (cname = "int", cprefix = "TCE", cheader_filename = "tchdb.h", has_type_id = false)]
487 public enum ErrorCode {
514 [Compact, CCode (cname = "TCHDB", cprefix = "tchdb", free_function = "tchdbdel", cheader_filename = "tchdb.h")]
516 [Flags, CCode (cname = "uint8_t", cprefix = "HDBT", cheader_filename = "tchdb.h", has_type_id = false)]
517 public enum TuningOption {
525 [Flags, CCode (cname = "uint8_t", cprefix = "HDBO", cheader_filename = "tchdb.h", has_type_id = false)]
526 public enum OpenMode {
536 [CCode (cname = "tchdberrstr")]
537 public static unowned string get_error_message (TokyoCabinet.ErrorCode ecode);
539 [CCode (cname = "tchdberrcode")]
540 public TokyoCabinet.ErrorCode get_error_code ();
541 [CCode (cname = "tchdbsetmutex")]
542 public bool set_mutex ();
543 [CCode (cname = "tchdbtune")]
544 public bool tune (int64 bnum, int8 apow, int8 fpow, TokyoCabinet.HDB.TuningOption opts);
545 [CCode (cname = "tchdbsetcache")]
546 public bool set_cache (int32 rcnum);
547 [CCode (cname = "tchdbsetxmsiz")]
548 public bool setxmsiz (int64 xmsiz);
549 [CCode (cname = "tchdbopen")]
550 public bool open (string path, TokyoCabinet.HDB.OpenMode omode);
551 [CCode (cname = "tchdbclose")]
552 public bool close ();
553 [CCode (cname = "tchdbput")]
554 public bool replace (uint8[] key, uint8[] value);
555 [CCode (cname = "tchdbput2")]
556 public bool replace_string (string key, string value);
557 [CCode (cname = "tchdbputkeep")]
558 public bool put (uint8[] key, uint8[] value);
559 [CCode (cname = "tchdbputkeep2")]
560 public bool put_string (string key, string value);
561 [CCode (cname = "tchdbputcat")]
562 public bool append (uint8[] key, uint8[] value);
563 [CCode (cname = "tchdbputcat2")]
564 public bool append_string (string key, string value);
565 [CCode (cname = "tchdbputasync")]
566 public bool replace_async (uint8[] key, uint8[] ksiz);
567 [CCode (cname = "tchdbputasync2")]
568 public bool replace_async_string (string key, string value);
569 [CCode (cname = "tchdbout")]
570 public bool remove (uint8[] key);
571 [CCode (cname = "tchdbout2")]
572 public bool remove_string (string key);
573 [CCode (cname = "tchdbget3")]
574 public int _get (uint8[] kbuf, uint8[] vbuf);
575 [CCode (cname = "_vala_tchdbget")]
576 public uint8[]? get (uint8[] key) {
577 int vsiz = this.value_size (key);
581 var vbuf = new uint8[vsiz];
582 this._get (key, vbuf);
585 [CCode (cname = "_vala_tchdbget2")]
586 public string? get_string (string key) {
587 unowned uint8[] kbuf = (uint8[]) key;
588 kbuf.length = (int) key.size ();
589 return (string) this.get (kbuf);
591 [CCode (cname = "tchdbvsiz")]
592 public int value_size (uint8[] key);
593 [CCode (cname = "tchdbvsiz2")]
594 public int value_size_string (string key);
595 [CCode (cname = "tchdbfwmkeys")]
596 public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
597 [CCode (cname = "tchdbfwmkeys2")]
598 public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
599 [CCode (cname = "tchdbaddint")]
600 public int add_int (uint8[] key, int num);
601 [CCode (cname = "tchdbadddouble")]
602 public double add_double (uint8[] key, double num);
603 [CCode (cname = "tchdbsync")]
605 [CCode (cname = "tchdboptimize")]
606 public bool optimize (int64 bnum, int8 apow, int8 fpow, TuningOption opts);
607 [CCode (cname = "tchdbvanish")]
608 public bool clear ();
609 [CCode (cname = "tchdbcopy")]
610 public bool copy (string path);
611 [CCode (cname = "tchdbpath")]
612 public unowned string path ();
613 [CCode (cname = "tchdbrnum")]
614 public uint64 get_length ();
615 [CCode (cname = "tchdbfsiz")]
616 public uint64 get_size ();
618 public uint64 length { get { return this.get_length (); } }
619 public uint64 size { get { return this.get_size (); } }
622 [Compact, CCode (cname = "TCBDB", cprefix = "tcbdb", free_function = "tcbdbdel", cheader_filename = "tcbdb.h")]
624 [CCode (cname = "BDBCMP")]
625 public delegate int Compare (uint8[] a, uint8[] b);
627 [Compact, CCode (cname = "BDBCUR", cprefix = "tcbdbcur", free_function = "tcbdbcurdel", cheader_filename = "tcbdb.h")]
628 public class Cursor {
629 [CCode (cname = "int", cprefix = "BDBCP", has_type_id = false)]
630 public enum PutMode {
636 [CCode (cname = "tcbdbcurnew")]
637 public Cursor (TokyoCabinet.BDB bdb);
638 public bool first ();
640 public bool jump (uint8[] key);
641 [CCode (cname = "tcbdbcurjump2")]
642 public bool jump_string (string key);
643 [CCode (cname = "tcbdbcurprev")]
644 public bool previous ();
646 public bool put (uint8[] value, TokyoCabinet.BDB.Cursor.PutMode cpmode);
647 [CCode (cname = "tcbdbput2")]
648 public bool put_string (string value, TokyoCabinet.BDB.Cursor.PutMode cpmode);
649 [CCode (cname = "tcbdbcurout")]
650 public bool remove ();
651 [CCode (cname = "tcbdbcurkey3")]
652 public unowned uint8[]? key ();
653 [CCode (cname = "_vala_tcbdbcurkey2")]
654 public unowned string? key_string () {
655 return (string) this.key ();
657 [CCode (cname = "tcbdbcurval3")]
658 public unowned uint8[]? value ();
659 [CCode (cname = "_vala_tcbdbcurval2")]
660 public unowned string? value_string () {
661 return (string) this.value ();
663 [CCode (cname = "tcbdbcurrec")]
664 public bool record (TokyoCabinet.XString kxstr, TokyoCabinet.XString vxstr);
667 [Flags, CCode (cname = "int", cprefix = "BDBO", cheader_filename = "tcbdb.h", has_type_id = false)]
668 public enum OpenMode {
677 [Flags, CCode (cname = "uint8_t", cprefix = "BDBT", cheader_filename = "tcbdb.h", has_type_id = false)]
678 public enum TuningOption {
686 [CCode (cname = "tcbdberrmsg")]
687 public static unowned string get_error_message (TokyoCabinet.ErrorCode ecode);
689 [CCode (cname = "tcbdbecode")]
690 public TokyoCabinet.ErrorCode get_error_code ();
691 [CCode (cname = "tcbdbsetmutex")]
692 public bool set_mutex ();
693 [CCode (cname = "tcbdbsetcmpfunc")]
694 public bool set_compare_func (TokyoCabinet.BDB.Compare cmp);
695 [CCode (cname = "tcbdbtune")]
696 public bool tune (int32 lmemb, int32 nmemb, int64 bnum, int8 apow, int8 fpow, TokyoCabinet.BDB.TuningOption opts);
697 [CCode (cname = "tcbdbsetxmsiz")]
698 public bool set_extra_mapped_size (int64 xmsiz);
699 [CCode (cname = "tcbdbopen")]
700 public bool open (string path, TokyoCabinet.BDB.OpenMode mode = TokyoCabinet.BDB.OpenMode.READER | TokyoCabinet.BDB.OpenMode.WRITER | TokyoCabinet.BDB.OpenMode.CREAT);
701 [CCode (cname = "tcbdbclose")]
702 public bool close ();
703 [CCode (cname = "tcbdbput")]
704 public bool replace (uint8[] key, uint8[] value);
705 [CCode (cname = "tcbdbput2")]
706 public bool replace_string (string key, string value);
707 [CCode (cname = "tcbdbputkeep")]
708 public bool put (uint8[] key, uint8[] value);
709 [CCode (cname = "tcbdbputkeep2")]
710 public bool put_string (string key, string value);
711 [CCode (cname = "tcbdbputcat")]
712 public bool append (uint8[] key, uint8[] value);
713 [CCode (cname = "tcbdbputcat2")]
714 public bool append_string (string key, string value);
715 [CCode (cname = "tcbdbputdup")]
716 public bool put_duplicate (uint8[] key, uint8[] value);
717 [CCode (cname = "tcbdbputdup2")]
718 public bool put_duplicate_string (string key, string value);
719 [CCode (cname = "tcbdbout")]
720 public bool remove (uint8[] key);
721 [CCode (cname = "tcbdbout2")]
722 public bool remove_string (string key);
723 [CCode (cname = "tcbdbget3")]
724 private unowned uint8[]? _get (uint8[] key);
725 [CCode (cname = "tcbdbsetdfunit")]
726 public bool set_defragment_unit (int32 dfunit);
727 [CCode (cname = "_vala_tcbdbget")]
728 public uint8[]? get (uint8[] key) {
729 return this._get (key);
731 public string? get_string (string key) {
732 unowned uint8[] k = (uint8[]) key;
733 k.length = (int) key.size ();
734 return (string) this._get (k);
736 [CCode (cname = "tcbdbget4")]
737 public TokyoCabinet.List get_list (uint8[] key);
738 [CCode (cname = "tcbdbvnum")]
739 public int value_count (uint8[] key);
740 [CCode (cname = "tcbdbvnum2")]
741 public int value_count_string (string key);
742 [CCode (cname = "tcbdbvsiz")]
743 public int value_size (uint8[] key);
744 [CCode (cname = "tcbdbvsiz2")]
745 public int value_size_string (string key);
746 [CCode (cname = "tcbdbrange")]
747 public TokyoCabinet.List range (uint8[] bkey, bool binc, uint8[] ekey, bool einc, int max);
748 [CCode (cname = "tcbdbrange2")]
749 public TokyoCabinet.List range_string (string bkey, bool binc, string ekey, bool einc, int max);
750 [CCode (cname = "tcbdbfwmkeys")]
751 public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
752 [CCode (cname = "tcbdbfwmkeys2")]
753 public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
754 [CCode (cname = "tcbdbaddint")]
755 public int add_int (uint8[] key, int num);
756 [CCode (cname = "tcbdbadddouble")]
757 public double add_double (uint8[] key, double num);
758 [CCode (cname = "tcbdbsync")]
760 [CCode (cname = "tcbdboptimize")]
761 public bool optimize (int32 lmemb, int32 nmemb, int64 bnum, int8 apow, int8 fpow, TuningOption opts);
762 [CCode (cname = "tcbdbvanish")]
763 public bool clear ();
764 [CCode (cname = "tcbdbcopy")]
765 public bool copy (string path);
766 [CCode (cname = "tcbdbtranbegin")]
767 public bool transaction_begin ();
768 [CCode (cname = "tcbdbtrancommit")]
769 public bool transaction_commit ();
770 [CCode (cname = "tcbdbtranabort")]
771 public bool transaction_abort ();
772 [CCode (cname = "tcbdbpath")]
773 public unowned string path ();
774 [CCode (cname = "tcbdbrnum")]
775 public uint64 get_length ();
776 [CCode (cname = "tcbdbfsiz")]
777 public uint64 get_size ();
778 [CCode (cname = "tcbdbcurnew")]
779 public BDB.Cursor iterator ();
781 public uint64 length { get { return this.get_length (); } }
782 public uint64 size { get { return this.get_size (); } }
785 [Compact, CCode (cname = "TCFDB", cprefix = "tcfdb", free_function = "tcfdbdel", cheader_filename = "tcfdb.h")]
787 [CCode (cname = "FDBIDMIN")]
788 public const int IDMIN;
789 [CCode (cname = "FDBIDMAX")]
790 public const int IDMAX;
791 [CCode (cname = "FDBIDPREV")]
792 public const int IDPREV;
793 [CCode (cname = "FDBIDNEXT")]
794 public const int IDNEXT;
796 [CCode (cname = "tcfdberrmsg")]
797 public unowned string get_error_message (TokyoCabinet.ErrorCode ecode);
798 [CCode (cname = "tcfdbnew")]
800 [CCode (cname = "tcfdbecode")]
801 public TokyoCabinet.ErrorCode get_error_code ();
802 [CCode (cname = "tcfdbsetmutex")]
803 public bool set_mutex ();
804 [CCode (cname = "tcfdbtune")]
805 public bool tune (int32 width = 0, int64 limsiz = 0);
806 [CCode (cname = "tcfdbclose")]
807 public bool close ();
808 [CCode (cname = "tcfdbput")]
809 public bool replace (int64 id, uint8[] value);
810 [CCode (cname = "tcfdbputkeep")]
811 public bool put (int64 id, uint8[] value);
812 [CCode (cname = "tcfdbputcat")]
813 public bool append (int64 id, uint8[] value);
814 [CCode (cname = "tcfdbout")]
815 public bool remove (int64 id);
816 [CCode (cname = "tcfdbget4")]
817 public int _get (int64 id, uint8[] value);
818 [CCode (cname = "_vala_tcfdbget")]
819 public uint8[]? get (int64 id) {
820 var vsiz = this.get_value_size (id);
824 var vbuf = new uint8[vsiz];
825 this._get (id, vbuf);
828 [CCode (cname = "tcfdbvsiz")]
829 public int get_value_size (int64 id);
830 [CCode (cname = "tcfdbiterinit")]
831 public bool iterator_init ();
832 [CCode (cname = "tcfdbiternext")]
833 public uint64 iterator_next ();
834 [CCode (cname = "tcfdbaddint")]
835 public int add_int (int64 id, int num);
836 [CCode (cname = "tcfdbadddouble")]
837 public double add_double (int64 id, double num);
838 [CCode (cname = "tcfdbsync")]
840 [CCode (cname = "tcfdboptimize")]
841 public bool optimize (int32 width = 0, int64 limsiz = 0);
842 [CCode (cname = "tcfdbvanish")]
843 public bool clear ();
844 [CCode (cname = "tcfdbcopy")]
845 public bool copy (string path);
846 [CCode (cname = "tcfdbpath")]
847 public unowned string path ();
848 [CCode (cname = "tcfdbrnum")]
849 public uint64 get_length ();
850 [CCode (cname = "tcfdbfsiz")]
851 public uint64 get_size ();
853 public uint64 length { get { return this.get_length (); } }
854 public uint64 size { get { return this.get_size (); } }
857 [Compact, CCode (cname = "TCADB", cprefix = "tcadb", free_function = "tcadbdel", cheader_filename = "tcadb.h")]
859 [CCode (cname = "tcadbnew")]
861 [CCode (cname = "tcadbopen")]
862 public bool open (string name);
863 [CCode (cname = "tcadbclose")]
864 public bool close ();
865 [CCode (cname = "tcadbput")]
866 public bool replace (uint8[] key, uint8[] vsiz);
867 [CCode (cname = "tcadbput2")]
868 public bool replace_string (string key, string value);
869 [CCode (cname = "tcadbputkeep")]
870 public bool put (uint8[] key, uint8[] value);
871 [CCode (cname = "tcadbputkeep2")]
872 public bool put_string (string key, string value);
873 [CCode (cname = "tcadbputcat")]
874 public bool append (uint8[] key, uint8[] value);
875 [CCode (cname = "tcadbputcat2")]
876 public bool append_string (string key, string value);
877 [CCode (cname = "tcadbout")]
878 public bool remove (uint8[] key);
879 [CCode (cname = "tcadbout2")]
880 public bool remove_string (string key);
881 [CCode (cname = "tcadbget")]
882 public unowned uint8[]? _get (uint8[] key);
883 [CCode (cname = "_vala_tcadbget")]
884 public uint8[]? get (uint8[] key) {
885 return TokyoCabinet.Memory.copy_and_free (this._get (key));
887 [CCode (cname = "tcadbget2")]
888 public unowned string? _get_string (string key);
889 public string? get_string (string key) {
890 return TokyoCabinet.Memory.copy_and_free_string (this._get_string (key));
892 [CCode (cname = "tcadbvsiz")]
893 public int value_size (uint8[] key);
894 [CCode (cname = "tcadbvsiz2")]
895 public int value_size_string (string key);
896 [CCode (cname = "tcadbiterinit")]
897 public bool iterator_init ();
899 [CCode (cname = "tcadbiternext")]
900 public unowned uint8[]? _iterator_next ();
901 [CCode (cname = "_vala_tcadbiternext")]
902 public uint8[]? iterator_next () {
903 return TokyoCabinet.Memory.copy_and_free (this._iterator_next ());
905 [CCode (cname = "tcadbiternext2")]
906 public unowned string? _iterator_next_string ();
907 [CCode (cname = "_vala_tcadbiternext")]
908 public string? iterator_next_string () {
909 return TokyoCabinet.Memory.copy_and_free_string (this._iterator_next_string ());
912 [CCode (cname = "tcadbfwmkeys")]
913 public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
914 [CCode (cname = "tcadbfwmkeys2")]
915 public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
916 [CCode (cname = "tcadbaddint")]
917 public int add_int (uint8[] key, int num);
918 [CCode (cname = "tcadbadddouble")]
919 public double add_double (uint8[] key, double num);
920 [CCode (cname = "tcadbsync")]
922 [CCode (cname = "tcadbvanish")]
923 public bool clear ();
924 [CCode (cname = "tcadbcopy")]
925 public bool copy (string path);
926 [CCode (cname = "tcadbrnum")]
927 public uint64 get_length ();
928 [CCode (cname = "tcadbsize")]
929 public uint64 get_size ();
931 public uint64 length { get { return this.get_length (); } }
932 public uint64 size { get { return this.get_size (); } }