]> mj.ucw.cz Git - leo.git/blob - dict.h
Style: Avoid compiler warning
[leo.git] / dict.h
1 /*
2  *      Hic Est Leo -- Universal Dictionaries
3  *
4  *      (c) 2014 Martin Mares <mj@ucw.cz>
5  */
6
7 #ifndef _LEO_DICT_H
8 #define _LEO_DICT_H
9
10 #include <ucw/gary.h>
11
12 struct dict {
13   const char **names;           // Growing array of names
14   struct kv_map_table *hash;    // Hash table mapping name -> ID
15   struct mempool *pool;
16 };
17
18 void dict_init(struct dict *dict, const char * const * init);
19
20 static inline const char *dict_decode(struct dict *d, u32 id)
21 {
22   ASSERT(id < GARY_SIZE(d->names));
23   return d->names[id];
24 }
25
26 u32 dict_encode(struct dict *d, const char *key);
27
28 static inline u32 dict_size(struct dict *d)
29 {
30   return GARY_SIZE(d->names);
31 }
32
33 #endif