summaryrefslogtreecommitdiff
path: root/vapi/tokyocabinet.vapi
blob: af999f91f255e3a126f52820e351b45cb7f3fd11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
/* tokyocabinet.vala
 *
 * Copyright (C) 2008-2010  Evan Nemerson
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 *      Evan Nemerson <evan@coeus-group.com>
 */

namespace TokyoCabinet {
	[CCode (cname = "tcversion")]
	public const string version;

	[CCode (cname = "tcfatalfunc")]
	public delegate void FatalFunc (string msg);
	[CCode (cname = "TCCMP")]
	public delegate int CompareFunc (uint8[] a, uint8[] b);
	[CCode (cname = "TCCODEC")]
	public delegate uint8[] CodecFunc (uint8[] data);
	[CCode (cname = "TCPDPROC")]
	public delegate uint8[] ProcessDuplicateFunc (uint8[] value);
	[CCode (cname = "TCITER")]
	public delegate bool IteratorFunc (uint8[] key, uint8[] data);

	[CCode (lower_case_cprefix = "tc", cheader_filename = "tcutil.h")]
	namespace Memory {
		public static void* malloc (size_t size);
		public static void* calloc (size_t nmemb, size_t size);
		public static void* realloc (void *ptr, size_t size);
		[CCode (cname = "tcmemdup")]
		public static void* copy (void *ptr, size_t size);
		public static string strdup (string str);
		public static void free ([CCode (type = "void*")] void* ptr);

		public static uint8[]? copy_and_free (uint8[]? data) {
			if ( data == null )
				return null;

			uint8[] ret = new uint8[data.length];
			GLib.Memory.copy (ret, data, data.length);
			TokyoCabinet.Memory.free (data);
			return ret;
		}
		public static string? copy_and_free_string (string? str) {
			if ( str == null )
				return null;

			string ret = str;
			TokyoCabinet.Memory.free (str);
			return ret;
		}
	}

	[Compact, CCode (cname = "TCXSTR", cprefix = "tcxstr", free_function = "tcxstrdel", cheader_filename = "tcutil.h", copy_function = "tcxstrdup")]
	public class XString {
		public XString ();
		[CCode (cname = "tcxstrnew2")]
		public XString.from_string (string str);
		[CCode (cname = "tcxstrnew3")]
		public XString.sized (int asiz);
		[CCode (cname = "tcxstrdup")]
		public XString copy ();
		[CCode (cname = "tcxstrcat")]
		public void append (uint8[] data);
		[CCode (cname = "tcxstrcat2")]
		public void append_string (string str);
		public void clear ();
		[PrintfFormat ()]
		public void printf (string format, ...);

		[CCode (cname = "ptr", array_length_cname = "size")]
		public uint8[] data;
		[CCode (cname = "ptr")]
		public string str;
		[CCode (cname = "asize")]
		public int allocated;
	}

	[Compact, CCode (cname = "TCLIST", cprefix = "tclist", free_function = "tclistdel", cheader_filename = "tcutil.h", copy_function = "tclistdup")]
	public class List {
		[CCode (has_target = false)]
		public delegate int CompareDatumFunc (TokyoCabinet.List.Datum a, TokyoCabinet.List.Datum b);

		[CCode (cname = "TCLISTDATUM", has_type_id = false)]
		public struct Datum {
			[CCode (cname = "ptr", array_length_cname = "size")]
			public uint8[] data;
			[CCode (cname = "ptr")]
			public string str;
		}

		public List ();
		[CCode (cname = "tclistnew3")]
		public List.from_strings (string s1, ...);
		[CCode (cname = "tclistnew2")]
		public List.sized (int anum);
		[CCode (cname = "tclistdup")]
		public List copy ();
		[CCode (cname = "tclistval")]
		public unowned uint8[]? index (int index);
		[CCode (cname = "tclistval2")]
		public unowned string? index_string (int index);
		public void push (uint8[] data);
		[CCode (cname = "tclistpush2")]
		public void push_string (string str);
		[CCode (cname = "tclistpop")]
		public unowned uint8[] _pop ();
		[CCode (cname = "_vala_tclistpop")]
		public uint8[] pop () {
			return TokyoCabinet.Memory.copy_and_free (this._pop ());
		}
		[CCode (cname = "tclistpop2")]
		public unowned string _pop_string ();
		[CCode (cname = "_vala_tclistpop2")]
		public string pop_string () {
			return TokyoCabinet.Memory.copy_and_free_string (this._pop_string ());
		}
		public void unshift (uint8[] data);
		[CCode (cname = "tclistunshift2")]
		public void unshift_string (string str);
		[CCode (cname = "tclistshift")]
		public unowned uint8[] _shift ();
		[CCode (cname = "_vala_tclistshift")]
		public uint8[] shift () {
			return TokyoCabinet.Memory.copy_and_free (this._shift ());
		}
		[CCode (cname = "tclistshift2")]
		public unowned string _shift_string ();
		[CCode (cname = "_vala_tclistshift2")]
		public string shift_string () {
			return TokyoCabinet.Memory.copy_and_free_string (this._shift_string ());
		}
		public void insert (int index, uint8[] data);
		[CCode (cname = "tclistinsert2")]
		public void insert_string (int index, string str);
		[CCode (cname = "tclistremove")]
		public unowned uint8[] _remove (int index);
		[CCode (cname = "_vala_tclistremove")]
		public uint8[] remove (int index) {
			return TokyoCabinet.Memory.copy_and_free (this._remove (index));
		}
		[CCode (cname = "tclistremove2")]
		public unowned string _remove_string (int index);
		[CCode (cname = "_vala_tclistremove2")]
		public string remove_string (int index) {
			return TokyoCabinet.Memory.copy_and_free_string (this._remove_string (index));
		}
		[CCode (cname = "tclistover")]
		public void replace (int index, uint8[] data);
		[CCode (cname = "tclistover2")]
		public void replace_string (int index, string str);
		[CCode (cname = "tclistsort")]
		public void sort_sensitive ();
		[CCode (cname = "tclistsortci")]
		public void sort_insensitive ();
		public void sort (TokyoCabinet.List.CompareDatumFunc func);
		[CCode (cname = "tclistlsearch")]
		public int linear_search (uint8[] ptr);
		[CCode (cname = "tclistbsearch")]
		public int binary_search (uint8[] ptr);
		public void clear ();
		[CCode (cname = "tclistdump")]
		public unowned uint8[] _dump ();
		[CCode (cname = "_vala_tclistdump")]
		public uint8[] dump () {
			return TokyoCabinet.Memory.copy_and_free (this._dump ());
		}
		public List.load (uint8[] ptr);
		[CCode (cname = "tclistinvert")]
		public void reverse ();
		[PrintfFormat]
		public void push_printf (string fmt, ...);

		[CCode (array_length_cname = "anum")]
		public TokyoCabinet.List.Datum[] array;
		public int start;
		[CCode (cname = "num")]
		public int num_used;
	}

	[Compact, CCode (cname = "TCMAPREC")]
	public class MapRecord {
		[CCode (cname = "ksiz")]
		public int32 key_size;
		[CCode (cname = "vsiz")]
		public int32 value_size;
		public TokyoCabinet.MapRecord left;
		public TokyoCabinet.MapRecord right;
		public TokyoCabinet.MapRecord prev;
		public TokyoCabinet.MapRecord next;
	}

	[Compact, CCode (cname = "TCMAP", cprefix = "tcmap", free_function = "tcmapdel", cheader_filename = "tcutil.h", copy_function = "tcmapdup")]
	public class Map {
		public Map ();
		[CCode (cname = "tcmapnew2")]
		public Map.sized (uint32 bnum);
		[CCode (cname = "tcmapnew3")]
		public Map.from_strings (string key1, string val1, ...);
		[CCode (cname = "tcmapload")]
		public Map.load (uint8[] ptr);
		[CCode (cname = "tcmapdup")]
		public Map copy ();
		[CCode (cname = "tcmapputkeep")]
		public void put (uint8[] key, uint8[] value);
		[CCode (cname = "tcmapputkeep2")]
		public void put_string (string key, string value);
		[CCode (cname = "tcmapput")]
		public bool replace (uint8[] key, uint8[] value);
		[CCode (cname = "tcmapput2")]
		public bool replace_string (string key, string value);
		[CCode (cname = "tcmapputcat")]
		public void append (uint8[] key, uint8[] value);
		[CCode (cname = "tcmapputcat2")]
		public void append_string (string key, string value);
		[CCode (cname = "tcmapout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tcmapout2")]
		public bool remove_string (string key);
		[CCode (cname = "tcmapget")]
		public unowned uint8[]? get (uint8[] key);
		[CCode (cname = "tcmapget2")]
		public unowned string? get_string (string key);
		public bool move (uint8[] key, bool head = true);
		[CCode (cname = "tcmapmove2")]
		public bool move_string (string key, bool head = true);
		[CCode (cname = "tcmapiterinit")]
		public void iterator_init ();
		[CCode (cname = "tcmapiternext")]
		public unowned uint8[] iterator_next ();
		[CCode (cname = "tcmapiternext2")]
		public unowned string? iterator_next_string ();
		[CCode (cname = "tcmapiterval2")]
		public unowned string? iterator_value_string (string key);
		[CCode (cname = "tcmapiterval")]
		public unowned uint8[]? iterator_value (uint8[] key);
		public TokyoCabinet.List keys ();
		[CCode (cname = "tcmapvals")]
		public TokyoCabinet.List values ();
		[CCode (cname = "tcmapaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tcmapadddouble")]
		public double add_double (uint8[] key, double num);
		public void clear ();
		[CCode (cname = "tcmapcutfront")]
		public void cut_front (int num);
		[CCode (cname = "tcmapdump")]
		public unowned uint8[] _dump ();
		[CCode (cname = "_vala_tcmapdump")]
		public uint8[] dump () {
			return TokyoCabinet.Memory.copy_and_free (this._dump ());
		}

		[CCode (array_length_cname = "bnum", array_length_type = "guint32")]
		public TokyoCabinet.MapRecord[] buckets;
		public TokyoCabinet.MapRecord first;
		public TokyoCabinet.MapRecord last;
		public TokyoCabinet.MapRecord cur;
		[CCode (cname = "rnum")]
		public uint64 num_records;
		[CCode (cname = "msiz")]
		public uint64 size;
	}

	[Compact, CCode (cname = "TCTREE", cprefix = "tctree", free_function = "tctreedel", cheader_filename = "tcutil.h", copy_function = "tctreedup")]
	public class Tree {
		[CCode (cname = "TREECMP")]
		public delegate int Compare (uint8[] a, uint8[] b);

		[Compact, CCode (cname = "TCTREEREC")]
		public class Record {
			[CCode (cname = "ksiz")]
			public int32 key_size;
			[CCode (cname = "vsiz")]
			public int32 value_size;
			TokyoCabinet.Tree.Record left;
			TokyoCabinet.Tree.Record right;
		}

		[CCode (cname = "tctreecmplexical")]
		public static int compare_lexical (uint8[] a, uint8[] b);
		[CCode (cname = "tctreecmpdecimal")]
		public static int compare_decimal (uint8[] a, uint8[] b);
		[CCode (cname = "tctreecmpint32")]
		public static int compare_int32 (uint8[] a, uint8[] b);
		[CCode (cname = "tctreecmpint64")]
		public static int compare_int64 (uint8[] a, uint8[] b);

		[CCode (cname = "tctreenew2")]
		public Tree (TokyoCabinet.Tree.Compare cmp = TokyoCabinet.Tree.compare_lexical);
		public Tree.load (uint8[] data, TokyoCabinet.Tree.Compare cmp = TokyoCabinet.Tree.compare_lexical);
		[CCode (cname = "tctreedup")]
		public Tree copy ();
		[CCode (cname = "tctreeput")]
		public void replace (uint8[] key, uint8[] value);
		[CCode (cname = "tctreeput2")]
		public void replace_string (string key, string value);
		[CCode (cname = "tctreeputkeep")]
		public bool put (uint8[] key, uint8[] value);
		[CCode (cname = "tctreeputkeep2")]
		public bool put_string (string key, string value);
		[CCode (cname = "tctreeputcat")]
		public void append (uint8[] key, uint8[] value);
		[CCode (cname = "tctreeputcat2")]
		public void append_string (string key, string value);
		[CCode (cname = "tctreeout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tctreeout2")]
		public bool remove_string (string key);
		[CCode (cname = "tctreeget")]
		public unowned uint8[]? get (uint8[] key);
		[CCode (cname = "tctreeget2")]
		public unowned string? get_string (string key);
		[CCode (cname = "tctreeiterinit")]
		public void iterator_init ();
		[CCode (cname = "tctreeiternext")]
		public unowned uint8[]? iterator_next ();
		[CCode (cname = "tctreeiternext2")]
		public unowned string? iterator_next_string ();
		[CCode (cname = "tctreeiterval")]
		public unowned uint8[]? iterator_value (uint8[] key);
		[CCode (cname = "tctreeiterval2")]
		public unowned string? iterator_value_string (string key);
		[CCode (cname = "tctreekeys")]
		public TokyoCabinet.List get_keys ();
		[CCode (cname = "tctreevals")]
		public TokyoCabinet.List get_values ();
		[CCode (cname = "tctreeaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tctreeadddouble")]
		public double add_double (uint8[] key, double num);
		public void clear ();
		[CCode (cname = "tctreedump")]
		public unowned uint8[] _dump ();
		[CCode (cname = "tctreedump")]
		public uint8[] dump () {
			return TokyoCabinet.Memory.copy_and_free (this._dump ());
		}

		public TokyoCabinet.Tree.Record root;
		public TokyoCabinet.Tree.Record cur;
		public uint64 rnum;
		public uint64 msiz;
		[CCode (delegate_target = false)]
		public TokyoCabinet.Tree.Compare cmp;
	}

	[Compact, CCode (cname = "TCMDB", cprefix = "tcmdb", free_function = "tctreedel", cheader_filename = "tcutil.h")]
	public class MDB {
		public MDB ();
		public MDB.with_num_buckets (uint32 bnum);
		public void replace (uint8[] key, uint8[] value);
		[CCode (cname = "tcmdbput2")]
		public void replace_string (string key, string value);
		[CCode (cname = "tcmdbputkeep")]
		public bool put (uint8[] key, uint8[] value);
		[CCode (cname = "tcmdbputkeep2")]
		public bool put_string (string key, string value);
		[CCode (cname = "tcmdbputcat")]
		public void append (uint8[] key, uint8[] value);
		[CCode (cname = "tcmdbputcat2")]
		public void append_string (string key, string value);
		[CCode (cname = "tcmdbout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tcmdbout2")]
		public bool remove_string (string key);
		[CCode (cname = "tcmdbget2")]
		public unowned string? get_string (string key);
		[CCode (cname = "tcmdbget")]
		public unowned uint8[]? get (uint8[] key);
		[CCode (cname = "tcmdbvsiz")]
		public int value_size (uint8[] key);
		[CCode (cname = "tcmdbvsiz2")]
		public int value_size_string (string key);
		[CCode (cname = "tcmdbiterinit")]
		public void iterator_init ();
		[CCode (cname = "tcmdbiternext")]
		public uint8[]? iterator_next ();
		[CCode (cname = "tcmdbiternext2")]
		public unowned string? iterator_next_string ();
		[CCode (cname = "tcmdbfwmkeys")]
		public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
		[CCode (cname = "tcmdbfwmkeys2")]
		public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
		[CCode (cname = "tcmdbrnum")]
		public uint64 get_length ();
		[CCode (cname = "tcmdbmsiz")]
		public uint64 get_size ();
		[CCode (cname = "tcmdbaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tcmdbadddouble")]
		public double add_double (uint8[] key, double num);
		[CCode (cname = "tcmdbvanish")]
		public void clear ();
		[CCode (cname = "tcmdbcutfront")]
		public void cut_front (int num);

		public uint64 length { get { return this.get_length (); } }
		public uint64 size { get { return this.get_size (); } }
	}

	[Compact, CCode (cname = "TCNDB", cprefix = "tcndb", free_function = "tcndbdel", cheader_filename = "tcutil.h")]
	public class NDB {
		[CCode (cname = "tcndbnew2")]
		public NDB (TokyoCabinet.BDB.Compare cmp = TokyoCabinet.Tree.compare_lexical, void * cmpop = null);
		public void replace (uint8[] key, uint8[] value);
		[CCode (cname = "tcndbput2")]
		public void replace_string (string key, string value);
		[CCode (cname = "tcndbputkeep")]
		public bool put (uint8[] key, uint8[] value);
		[CCode (cname = "tcndbputkeep2")]
		public bool put_string (string key, string value);
		[CCode (cname = "tcndbputcat")]
		public bool append (uint8[] key, uint8[] value);
		[CCode (cname = "tcndbputcat2")]
		public bool append_string (string key, string value);
		[CCode (cname = "tcndbout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tcndbout2")]
		public bool remove_string (string key);
		[CCode (cname = "tcndbget")]
		private unowned uint8[]? _get (uint8[] key);
		[CCode (cname = "_vala_tcndbget")]
		public uint8[]? get (uint8[] key) {
			return TokyoCabinet.Memory.copy_and_free (this._get (key));
		}
		public string? get_string (string key) {
			unowned uint8[] kbuf = (uint8[]) key;
			kbuf.length = key.length;
			return (string) this.get (kbuf);
		}
		[CCode (cname = "tcndbvsiz")]
		public int value_size (uint8[] key);
		[CCode (cname = "tcndbvsiz2")]
		public int value_size_string (string key);
		[CCode (cname = "tcndbiterinit")]
		public void iterator_init ();
		[CCode (cname = "tcndbiterinit2")]
		public void iterator_init_before (uint8[] key);
		[CCode (cname = "tcndbiterinit3")]
		public void iterator_init_before_string (string key);
		[CCode (cname = "tcndbiternext")]
		public unowned uint8[]? _iterator_next ();
		public uint8[]? iterator_next () {
			return TokyoCabinet.Memory.copy_and_free (this._iterator_next ());
		}
		[CCode (cname = "tcndbiternext2")]
		public unowned string? _iterator_next_string ();
		public string? iterator_next_string () {
			return TokyoCabinet.Memory.copy_and_free_string (this._iterator_next_string ());
		}
		[CCode (cname = "tcndbfwmkeys")]
		public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
		[CCode (cname = "tcndbfwnkeys2")]
		public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
		[CCode (cname = "tcndbrnum")]
		public uint64 get_length ();
		[CCode (cname = "tcndbmsiz")]
		public uint64 get_size ();
		[CCode (cname = "tcndbaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tcndbadddouble")]
		public double add_double (uint8[] key, double num);
		[CCode (cname = "tcndbvanish")]
		public void clear ();
		[CCode (cname = "tcndbcutfringe")]
		public void cut_fringe (int num);

		public uint64 length { get { return this.get_length (); } }
		public uint64 size { get { return this.get_size (); } }
	}

	[CCode (cname = "int", cprefix = "TCE", cheader_filename = "tchdb.h", has_type_id = false)]
	public enum ErrorCode {
		SUCCESS,
		THREAD,
		INVALID,
		NOFILE,
		NOPERM,
		META,
		RHEAD,
		OPEN,
		CLOSE,
		TRUNC,
		SYNC,
		STAT,
		SEEK,
		READ,
		WRITE,
		MMAP,
		LOCK,
		UNLINK,
		RENAME,
		MKDIR,
		RMDIR,
		KEEP,
		NOREC,
		MISC
	}

	[Compact, CCode (cname = "TCHDB", cprefix = "tchdb", free_function = "tchdbdel", cheader_filename = "tchdb.h")]
	public class HDB {
		[Flags, CCode (cname = "uint8_t", cprefix = "HDBT", cheader_filename = "tchdb.h", has_type_id = false)]
		public enum TuningOption {
			LARGE,
			DEFLATE,
			BZIP,
			TCBS,
			EXCODEC
		}

		[Flags, CCode (cname = "uint8_t", cprefix = "HDBO", cheader_filename = "tchdb.h", has_type_id = false)]
		public enum OpenMode {
			READER,
			WRITER,
			CREAT,
			TRUNC,
			NOLCK,
			LCKNB,
			TSYNC
		}

		[CCode (cname = "tchdberrstr")]
		public static unowned string get_error_message (TokyoCabinet.ErrorCode ecode);
		public HDB ();
		[CCode (cname = "tchdberrcode")]
		public TokyoCabinet.ErrorCode get_error_code ();
		[CCode (cname = "tchdbsetmutex")]
		public bool set_mutex ();
		[CCode (cname = "tchdbtune")]
		public bool tune (int64 bnum, int8 apow, int8 fpow, TokyoCabinet.HDB.TuningOption opts);
		[CCode (cname = "tchdbsetcache")]
		public bool set_cache (int32 rcnum);
		[CCode (cname = "tchdbsetxmsiz")]
		public bool setxmsiz (int64 xmsiz);
		[CCode (cname = "tchdbopen")]
		public bool open (string path, TokyoCabinet.HDB.OpenMode omode);
		[CCode (cname = "tchdbclose")]
		public bool close ();
		[CCode (cname = "tchdbput")]
		public bool replace (uint8[] key, uint8[] value);
		[CCode (cname = "tchdbput2")]
		public bool replace_string (string key, string value);
		[CCode (cname = "tchdbputkeep")]
		public bool put (uint8[] key, uint8[] value);
		[CCode (cname = "tchdbputkeep2")]
		public bool put_string (string key, string value);
		[CCode (cname = "tchdbputcat")]
		public bool append (uint8[] key, uint8[] value);
		[CCode (cname = "tchdbputcat2")]
		public bool append_string (string key, string value);
		[CCode (cname = "tchdbputasync")]
		public bool replace_async (uint8[] key, uint8[] ksiz);
		[CCode (cname = "tchdbputasync2")]
		public bool replace_async_string (string key, string value);
		[CCode (cname = "tchdbout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tchdbout2")]
		public bool remove_string (string key);
		[CCode (cname = "tchdbget3")]
		public int _get (uint8[] kbuf, uint8[] vbuf);
		[CCode (cname = "_vala_tchdbget")]
		public uint8[]? get (uint8[] key) {
			int vsiz = this.value_size (key);
			if ( vsiz < 0 )
				return null;

			var vbuf = new uint8[vsiz];
			this._get (key, vbuf);
			return vbuf;
		}
		[CCode (cname = "_vala_tchdbget2")]
		public string? get_string (string key) {
			unowned uint8[] kbuf = (uint8[]) key;
			kbuf.length = key.length;
			return (string) this.get (kbuf);
		}
		[CCode (cname = "tchdbvsiz")]
		public int value_size (uint8[] key);
		[CCode (cname = "tchdbvsiz2")]
		public int value_size_string (string key);
		[CCode (cname = "tchdbfwmkeys")]
		public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
		[CCode (cname = "tchdbfwmkeys2")]
		public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
		[CCode (cname = "tchdbaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tchdbadddouble")]
		public double add_double (uint8[] key, double num);
		[CCode (cname = "tchdbsync")]
		public bool sync ();
		[CCode (cname = "tchdboptimize")]
		public bool optimize (int64 bnum, int8 apow, int8 fpow, TuningOption opts);
		[CCode (cname = "tchdbvanish")]
		public bool clear ();
		[CCode (cname = "tchdbcopy")]
		public bool copy (string path);
		[CCode (cname = "tchdbpath")]
		public unowned string path ();
		[CCode (cname = "tchdbrnum")]
		public uint64 get_length ();
		[CCode (cname = "tchdbfsiz")]
		public uint64 get_size ();

		public uint64 length { get { return this.get_length (); } }
		public uint64 size { get { return this.get_size (); } }
	}

	[Compact, CCode (cname = "TCBDB", cprefix = "tcbdb", free_function = "tcbdbdel", cheader_filename = "tcbdb.h")]
	public class BDB {
		[CCode (cname = "BDBCMP")]
		public delegate int Compare (uint8[] a, uint8[] b);

		[Compact, CCode (cname = "BDBCUR", cprefix = "tcbdbcur", free_function = "tcbdbcurdel", cheader_filename = "tcbdb.h")]
		public class Cursor {
			[CCode (cname = "int", cprefix = "BDBCP", has_type_id = false)]
			public enum PutMode {
				CURRENT,
				BEFORE,
				AFTER
			}

			[CCode (cname = "tcbdbcurnew")]
			public Cursor (TokyoCabinet.BDB bdb);
			public bool first ();
			public bool last ();
			public bool jump (uint8[] key);
			[CCode (cname = "tcbdbcurjump2")]
			public bool jump_string (string key);
			[CCode (cname = "tcbdbcurprev")]
			public bool previous ();
			public bool next ();
			public bool put (uint8[] value, TokyoCabinet.BDB.Cursor.PutMode cpmode);
			[CCode (cname = "tcbdbput2")]
			public bool put_string (string value, TokyoCabinet.BDB.Cursor.PutMode cpmode);
			[CCode (cname = "tcbdbcurout")]
			public bool remove ();
			[CCode (cname = "tcbdbcurkey3")]
			public unowned uint8[]? key ();
			[CCode (cname = "_vala_tcbdbcurkey2")]
			public unowned string? key_string () {
				return (string) this.key ();
			}
			[CCode (cname = "tcbdbcurval3")]
			public unowned uint8[]? value ();
			[CCode (cname = "_vala_tcbdbcurval2")]
			public unowned string? value_string () {
				return (string) this.value ();
			}
			[CCode (cname = "tcbdbcurrec")]
			public bool record (TokyoCabinet.XString kxstr, TokyoCabinet.XString vxstr);
		}

		[Flags, CCode (cname = "int", cprefix = "BDBO", cheader_filename = "tcbdb.h", has_type_id = false)]
		public enum OpenMode {
			READER,
			WRITER,
			CREAT,
			TRUNC,
			NOLCK,
			LCKNB
		}

		[Flags, CCode (cname = "uint8_t", cprefix = "BDBT", cheader_filename = "tcbdb.h", has_type_id = false)]
		public enum TuningOption {
			LARGE,
			DEFLATE,
			BZIP,
			TCBS,
			EXCODEC
		}

		[CCode (cname = "tcbdberrmsg")]
		public static unowned string get_error_message (TokyoCabinet.ErrorCode ecode);
		public BDB ();
		[CCode (cname = "tcbdbecode")]
		public TokyoCabinet.ErrorCode get_error_code ();
		[CCode (cname = "tcbdbsetmutex")]
		public bool set_mutex ();
		[CCode (cname = "tcbdbsetcmpfunc")]
		public bool set_compare_func (TokyoCabinet.BDB.Compare cmp);
		[CCode (cname = "tcbdbtune")]
		public bool tune (int32 lmemb, int32 nmemb, int64 bnum, int8 apow, int8 fpow, TokyoCabinet.BDB.TuningOption opts);
		[CCode (cname = "tcbdbsetxmsiz")]
		public bool set_extra_mapped_size (int64 xmsiz);
		[CCode (cname = "tcbdbopen")]
		public bool open (string path, TokyoCabinet.BDB.OpenMode mode = TokyoCabinet.BDB.OpenMode.READER | TokyoCabinet.BDB.OpenMode.WRITER | TokyoCabinet.BDB.OpenMode.CREAT);
		[CCode (cname = "tcbdbclose")]
		public bool close ();
		[CCode (cname = "tcbdbput")]
		public bool replace (uint8[] key, uint8[] value);
		[CCode (cname = "tcbdbput2")]
		public bool replace_string (string key, string value);
		[CCode (cname = "tcbdbputkeep")]
		public bool put (uint8[] key, uint8[] value);
		[CCode (cname = "tcbdbputkeep2")]
		public bool put_string (string key, string value);
		[CCode (cname = "tcbdbputcat")]
		public bool append (uint8[] key, uint8[] value);
		[CCode (cname = "tcbdbputcat2")]
		public bool append_string (string key, string value);
		[CCode (cname = "tcbdbputdup")]
		public bool put_duplicate (uint8[] key, uint8[] value);
		[CCode (cname = "tcbdbputdup2")]
		public bool put_duplicate_string (string key, string value);
		[CCode (cname = "tcbdbout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tcbdbout2")]
		public bool remove_string (string key);
		[CCode (cname = "tcbdbget3")]
		private unowned uint8[]? _get (uint8[] key);
		[CCode (cname = "tcbdbsetdfunit")]
		public bool set_defragment_unit (int32 dfunit);
		[CCode (cname = "_vala_tcbdbget")]
		public uint8[]? get (uint8[] key) {
			return this._get (key);
		}
		public string? get_string (string key) {
			unowned uint8[] k = (uint8[]) key;
			k.length = key.length;
			return (string) this._get (k);
		}
		[CCode (cname = "tcbdbget4")]
		public TokyoCabinet.List get_list (uint8[] key);
		[CCode (cname = "tcbdbvnum")]
		public int value_count (uint8[] key);
		[CCode (cname = "tcbdbvnum2")]
		public int value_count_string (string key);
		[CCode (cname = "tcbdbvsiz")]
		public int value_size (uint8[] key);
		[CCode (cname = "tcbdbvsiz2")]
		public int value_size_string (string key);
		[CCode (cname = "tcbdbrange")]
		public TokyoCabinet.List range (uint8[] bkey, bool binc, uint8[] ekey, bool einc, int max);
		[CCode (cname = "tcbdbrange2")]
		public TokyoCabinet.List range_string (string bkey, bool binc, string ekey, bool einc, int max);
		[CCode (cname = "tcbdbfwmkeys")]
		public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
		[CCode (cname = "tcbdbfwmkeys2")]
		public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
		[CCode (cname = "tcbdbaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tcbdbadddouble")]
		public double add_double (uint8[] key, double num);
		[CCode (cname = "tcbdbsync")]
		public bool sync ();
		[CCode (cname = "tcbdboptimize")]
		public bool optimize (int32 lmemb, int32 nmemb, int64 bnum, int8 apow, int8 fpow, TuningOption opts);
		[CCode (cname = "tcbdbvanish")]
		public bool clear ();
		[CCode (cname = "tcbdbcopy")]
		public bool copy (string path);
		[CCode (cname = "tcbdbtranbegin")]
		public bool transaction_begin ();
		[CCode (cname = "tcbdbtrancommit")]
		public bool transaction_commit ();
		[CCode (cname = "tcbdbtranabort")]
		public bool transaction_abort ();
		[CCode (cname = "tcbdbpath")]
		public unowned string path ();
		[CCode (cname = "tcbdbrnum")]
		public uint64 get_length ();
		[CCode (cname = "tcbdbfsiz")]
		public uint64 get_size ();
		[CCode (cname = "tcbdbcurnew")]
		public BDB.Cursor iterator ();

		public uint64 length { get { return this.get_length (); } }
		public uint64 size { get { return this.get_size (); } }
	}

	[Compact, CCode (cname = "TCFDB", cprefix = "tcfdb", free_function = "tcfdbdel", cheader_filename = "tcfdb.h")]
	public class FDB {
		[CCode (cname = "FDBIDMIN")]
		public const int IDMIN;
		[CCode (cname = "FDBIDMAX")]
		public const int IDMAX;
		[CCode (cname = "FDBIDPREV")]
		public const int IDPREV;
		[CCode (cname = "FDBIDNEXT")]
		public const int IDNEXT;

		[CCode (cname = "tcfdberrmsg")]
		public unowned string get_error_message (TokyoCabinet.ErrorCode ecode);
		[CCode (cname = "tcfdbnew")]
		public FDB ();
		[CCode (cname = "tcfdbecode")]
		public TokyoCabinet.ErrorCode get_error_code ();
		[CCode (cname = "tcfdbsetmutex")]
		public bool set_mutex ();
		[CCode (cname = "tcfdbtune")]
		public bool tune (int32 width = 0, int64 limsiz = 0);
		[CCode (cname = "tcfdbclose")]
		public bool close ();
		[CCode (cname = "tcfdbput")]
		public bool replace (int64 id, uint8[] value);
		[CCode (cname = "tcfdbputkeep")]
		public bool put (int64 id, uint8[] value);
		[CCode (cname = "tcfdbputcat")]
		public bool append (int64 id, uint8[] value);
		[CCode (cname = "tcfdbout")]
		public bool remove (int64 id);
		[CCode (cname = "tcfdbget4")]
		public int _get (int64 id, uint8[] value);
		[CCode (cname = "_vala_tcfdbget")]
		public uint8[]? get (int64 id) {
			var vsiz = this.get_value_size (id);
			if ( vsiz < 0 )
				return null;

			var vbuf = new uint8[vsiz];
			this._get (id, vbuf);
			return vbuf;
		}
		[CCode (cname = "tcfdbvsiz")]
		public int get_value_size (int64 id);
		[CCode (cname = "tcfdbiterinit")]
		public bool iterator_init ();
		[CCode (cname = "tcfdbiternext")]
		public uint64 iterator_next ();
		[CCode (cname = "tcfdbaddint")]
		public int add_int (int64 id, int num);
		[CCode (cname = "tcfdbadddouble")]
		public double add_double (int64 id, double num);
		[CCode (cname = "tcfdbsync")]
		public bool sync ();
		[CCode (cname = "tcfdboptimize")]
		public bool optimize (int32 width = 0, int64 limsiz = 0);
		[CCode (cname = "tcfdbvanish")]
		public bool clear ();
		[CCode (cname = "tcfdbcopy")]
		public bool copy (string path);
		[CCode (cname = "tcfdbpath")]
		public unowned string path ();
		[CCode (cname = "tcfdbrnum")]
		public uint64 get_length ();
		[CCode (cname = "tcfdbfsiz")]
		public uint64 get_size ();

		public uint64 length { get { return this.get_length (); } }
		public uint64 size { get { return this.get_size (); } }
	}

	[Compact, CCode (cname = "TCADB", cprefix = "tcadb", free_function = "tcadbdel", cheader_filename = "tcadb.h")]
	public class ADB {
		[CCode (cname = "tcadbnew")]
		public ADB ();
		[CCode (cname = "tcadbopen")]
		public bool open (string name);
		[CCode (cname = "tcadbclose")]
		public bool close ();
		[CCode (cname = "tcadbput")]
		public bool replace (uint8[] key, uint8[] vsiz);
		[CCode (cname = "tcadbput2")]
		public bool replace_string (string key, string value);
		[CCode (cname = "tcadbputkeep")]
		public bool put (uint8[] key, uint8[] value);
		[CCode (cname = "tcadbputkeep2")]
		public bool put_string (string key, string value);
		[CCode (cname = "tcadbputcat")]
		public bool append (uint8[] key, uint8[] value);
		[CCode (cname = "tcadbputcat2")]
		public bool append_string (string key, string value);
		[CCode (cname = "tcadbout")]
		public bool remove (uint8[] key);
		[CCode (cname = "tcadbout2")]
		public bool remove_string (string key);
		[CCode (cname = "tcadbget")]
		public unowned uint8[]? _get (uint8[] key);
		[CCode (cname = "_vala_tcadbget")]
		public uint8[]? get (uint8[] key) {
			return TokyoCabinet.Memory.copy_and_free (this._get (key));
		}
		[CCode (cname = "tcadbget2")]
		public unowned string? _get_string (string key);
		public string? get_string (string key) {
			return TokyoCabinet.Memory.copy_and_free_string (this._get_string (key));
		}
		[CCode (cname = "tcadbvsiz")]
		public int value_size (uint8[] key);
		[CCode (cname = "tcadbvsiz2")]
		public int value_size_string (string key);
		[CCode (cname = "tcadbiterinit")]
		public bool iterator_init ();

		[CCode (cname = "tcadbiternext")]
		public unowned uint8[]? _iterator_next ();
		[CCode (cname = "_vala_tcadbiternext")]
		public uint8[]? iterator_next () {
			return TokyoCabinet.Memory.copy_and_free (this._iterator_next ());
		}
		[CCode (cname = "tcadbiternext2")]
		public unowned string? _iterator_next_string ();
		[CCode (cname = "_vala_tcadbiternext")]
		public string? iterator_next_string () {
			return TokyoCabinet.Memory.copy_and_free_string (this._iterator_next_string ());
		}

		[CCode (cname = "tcadbfwmkeys")]
		public TokyoCabinet.List forward_matching_keys (uint8[] pbuf, int max);
		[CCode (cname = "tcadbfwmkeys2")]
		public TokyoCabinet.List forward_matching_keys_string (string pstr, int max);
		[CCode (cname = "tcadbaddint")]
		public int add_int (uint8[] key, int num);
		[CCode (cname = "tcadbadddouble")]
		public double add_double (uint8[] key, double num);
		[CCode (cname = "tcadbsync")]
		public bool sync ();
		[CCode (cname = "tcadbvanish")]
		public bool clear ();
		[CCode (cname = "tcadbcopy")]
		public bool copy (string path);
		[CCode (cname = "tcadbrnum")]
		public uint64 get_length ();
		[CCode (cname = "tcadbsize")]
		public uint64 get_size ();

		public uint64 length { get { return this.get_length (); } }
		public uint64 size { get { return this.get_size (); } }
	}
}