]>
Commit | Line | Data |
---|---|---|
c2b67043 | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
c2b67043 RB |
3 | * |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with | |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
6 | */ | |
7 | #ifndef INCLUDE_strmap_h__ | |
8 | #define INCLUDE_strmap_h__ | |
9 | ||
10 | #include "common.h" | |
11 | ||
ac3d33df | 12 | typedef struct kh_str_s git_strmap; |
c2b67043 | 13 | |
a13cfd2a | 14 | int git_strmap_alloc(git_strmap **map); |
94af9155 | 15 | void git_strmap_free(git_strmap *map); |
a13cfd2a | 16 | void git_strmap_clear(git_strmap *map); |
c2b67043 | 17 | |
a13cfd2a | 18 | size_t git_strmap_num_entries(git_strmap *map); |
c2b67043 | 19 | |
a13cfd2a PS |
20 | size_t git_strmap_lookup_index(git_strmap *map, const char *key); |
21 | int git_strmap_valid_index(git_strmap *map, size_t idx); | |
c2b67043 | 22 | |
a13cfd2a PS |
23 | int git_strmap_exists(git_strmap *map, const char *key); |
24 | int git_strmap_has_data(git_strmap *map, size_t idx); | |
c2b67043 | 25 | |
a13cfd2a PS |
26 | const char *git_strmap_key(git_strmap *map, size_t idx); |
27 | void git_strmap_set_key_at(git_strmap *map, size_t idx, char *key); | |
28 | void *git_strmap_value_at(git_strmap *map, size_t idx); | |
29 | void git_strmap_set_value_at(git_strmap *map, size_t idx, void *value); | |
30 | void git_strmap_delete_at(git_strmap *map, size_t idx); | |
c2b67043 | 31 | |
a13cfd2a PS |
32 | int git_strmap_put(git_strmap *map, const char *key, int *err); |
33 | void git_strmap_insert(git_strmap *map, const char *key, void *value, int *rval); | |
34 | void git_strmap_delete(git_strmap *map, const char *key); | |
b709e951 | 35 | |
ac3d33df JK |
36 | #define git_strmap_foreach(h, kvar, vvar, code) { size_t __i; \ |
37 | for (__i = git_strmap_begin(h); __i != git_strmap_end(h); ++__i) { \ | |
38 | if (!git_strmap_has_data(h,__i)) continue; \ | |
39 | (kvar) = git_strmap_key(h,__i); \ | |
40 | (vvar) = git_strmap_value_at(h,__i); \ | |
41 | code; \ | |
42 | } } | |
43 | ||
44 | #define git_strmap_foreach_value(h, vvar, code) { size_t __i; \ | |
45 | for (__i = git_strmap_begin(h); __i != git_strmap_end(h); ++__i) { \ | |
46 | if (!git_strmap_has_data(h,__i)) continue; \ | |
47 | (vvar) = git_strmap_value_at(h,__i); \ | |
48 | code; \ | |
49 | } } | |
c2b67043 | 50 | |
ac3d33df JK |
51 | size_t git_strmap_begin(git_strmap *map); |
52 | size_t git_strmap_end(git_strmap *map); | |
6385fc5f NG |
53 | |
54 | int git_strmap_next( | |
6385fc5f | 55 | void **data, |
ac3d33df | 56 | size_t *iter, |
6385fc5f NG |
57 | git_strmap *map); |
58 | ||
c2b67043 | 59 | #endif |