18 |
19 |
19 typedef struct UcxMap UcxMap; |
20 typedef struct UcxMap UcxMap; |
20 typedef struct UcxKey UcxKey; |
21 typedef struct UcxKey UcxKey; |
21 typedef struct UcxMapElement UcxMapElement; |
22 typedef struct UcxMapElement UcxMapElement; |
22 typedef struct UcxMapIterator UcxMapIterator; |
23 typedef struct UcxMapIterator UcxMapIterator; |
|
24 |
|
25 /* |
|
26 * param 1: element |
|
27 * param 2: additional data |
|
28 * param 3: size of encoded data will be stored here |
|
29 * returns encoded / decoded string or NULL on failure |
|
30 */ |
|
31 typedef void*(*ucx_map_coder)(void*,void*,size_t*); |
23 |
32 |
24 struct UcxMap { |
33 struct UcxMap { |
25 UcxMapElement **map; |
34 UcxMapElement **map; |
26 size_t size; |
35 size_t size; |
27 size_t count; |
36 size_t count; |
65 UcxMapIterator ucx_map_iterator(UcxMap *map); |
74 UcxMapIterator ucx_map_iterator(UcxMap *map); |
66 |
75 |
67 int ucx_map_iter_next(UcxMapIterator *i, void **elm); |
76 int ucx_map_iter_next(UcxMapIterator *i, void **elm); |
68 |
77 |
69 /* use macros for string maps only, values are not encoded */ |
78 /* use macros for string maps only, values are not encoded */ |
70 #define ucx_map_load(map, f) ucx_map_load_enc(map, f, NULL, NULL) |
79 #define ucx_map_load(map, f, alloc) ucx_map_load_enc(map, f, alloc, NULL, NULL) |
71 #define ucx_map_store(map, f) ucx_map_store_enc(map, f, NULL, NULL) |
80 #define ucx_map_store(map, f) ucx_map_store_enc(map, f, NULL, NULL) |
72 |
81 |
73 int ucx_map_load_enc(UcxMap *map, FILE *f, copy_func decoder, void* decdata); |
82 int ucx_map_load_enc(UcxMap *map, FILE *f, UcxAllocator allocator, |
|
83 ucx_map_coder decoder, void* decdata); |
74 /* encoders shall provide null terminated strings*/ |
84 /* encoders shall provide null terminated strings*/ |
75 int ucx_map_store_enc(UcxMap *map, FILE *f, copy_func encoder, void* encdata); |
85 int ucx_map_store_enc(UcxMap *map, FILE *f, |
|
86 ucx_map_coder encoder, void* encdata); |
76 |
87 |
77 #ifdef __cplusplus |
88 #ifdef __cplusplus |
78 } |
89 } |
79 #endif |
90 #endif |
80 |
91 |