Map access standardization

This commit is contained in:
2022-06-08 21:00:33 +03:00
parent 4b3204c00f
commit d592c0adac
4 changed files with 73 additions and 74 deletions
+2 -5
View File
@@ -6,15 +6,12 @@
#ifndef LIBCDSB_EXTRA_MAP_H
#define LIBCDSB_EXTRA_MAP_H
typedef int (*map_foreach_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data);
#define map_foreach(x, data, callback) libcdsb_map_foreach(x, data, callback, 0)
extern _Bool libcdsb_map_find (vtype_value* x, vtype_map* s, const void* key, vtype key_type, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn23__;
extern _Bool libcdsb_map_update(vtype_map* x, const void* k, vtype kt, const void* v, vtype vt) LIBCDSB_nt__ LIBCDSB_nn124__;
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
extern int libcdsb_map_find (vtype_map* x, const void* key, vtype key_type, void* data, map_access_callback, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_access_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
#endif /* LIBCDSB_EXTRA_MAP_H */
+21 -19
View File
@@ -7,6 +7,8 @@
#ifndef LIBCDSB_MAP_H
#define LIBCDSB_MAP_H
typedef int (*map_access_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data);
extern void map_init(vtype_map* x, vtype key_type);
#define map_pop(x, s, key) _LIBCDSB_Generic (libcdsb_map, find, key)(x, s, key, 1)
@@ -14,25 +16,25 @@ extern void map_init(vtype_map* x, vtype key_type);
#define map_update(x, key, value) _LIBCDSB_Generic2(libcdsb_map, update, key, value)(x, key, value)
#define map_remove(x, key) map_pop(0, x, key)
extern _Bool libcdsb_map_find_pointer(vtype_value* x, vtype_map* s, const void* key, _Bool cut);
extern _Bool libcdsb_map_find_cstring(vtype_value* x, vtype_map* s, const char* key, _Bool cut);
extern _Bool libcdsb_map_find_string (vtype_value* x, vtype_map* s, const vtype_string* key, _Bool cut);
extern _Bool libcdsb_map_find_array (vtype_value* x, vtype_map* s, const vtype_array* key, _Bool cut);
extern _Bool libcdsb_map_find_list (vtype_value* x, vtype_map* s, const vtype_list* key, _Bool cut);
extern _Bool libcdsb_map_find_map (vtype_value* x, vtype_map* s, const vtype_map* key, _Bool cut);
extern _Bool libcdsb_map_find_vset (vtype_value* x, vtype_map* s, const vtype_set* key, _Bool cut);
extern _Bool libcdsb_map_find_boolean(vtype_value* x, vtype_map* s, vtype_bool key, _Bool cut);
extern _Bool libcdsb_map_find_int8 (vtype_value* x, vtype_map* s, vtype_int8 key, _Bool cut);
extern _Bool libcdsb_map_find_int16 (vtype_value* x, vtype_map* s, vtype_int16 key, _Bool cut);
extern _Bool libcdsb_map_find_int32 (vtype_value* x, vtype_map* s, vtype_int32 key, _Bool cut);
extern _Bool libcdsb_map_find_int64 (vtype_value* x, vtype_map* s, vtype_int64 key, _Bool cut);
extern _Bool libcdsb_map_find_uint8 (vtype_value* x, vtype_map* s, vtype_uint8 key, _Bool cut);
extern _Bool libcdsb_map_find_uint16 (vtype_value* x, vtype_map* s, vtype_uint16 key, _Bool cut);
extern _Bool libcdsb_map_find_uint32 (vtype_value* x, vtype_map* s, vtype_uint32 key, _Bool cut);
extern _Bool libcdsb_map_find_uint64 (vtype_value* x, vtype_map* s, vtype_uint64 key, _Bool cut);
extern _Bool libcdsb_map_find_float (vtype_value* x, vtype_map* s, vtype_float key, _Bool cut);
extern _Bool libcdsb_map_find_double (vtype_value* x, vtype_map* s, vtype_double key, _Bool cut);
extern _Bool libcdsb_map_find_ldouble(vtype_value* x, vtype_map* s, vtype_ldouble key, _Bool cut);
extern int libcdsb_map_find_pointer(vtype_map* x, const void* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_cstring(vtype_map* x, const char* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_string (vtype_map* x, const vtype_string* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_array (vtype_map* x, const vtype_array* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_list (vtype_map* x, const vtype_list* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_map (vtype_map* x, const vtype_map* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_vset (vtype_map* x, const vtype_set* key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_boolean(vtype_map* x, vtype_bool key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int8 (vtype_map* x, vtype_int8 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int16 (vtype_map* x, vtype_int16 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int32 (vtype_map* x, vtype_int32 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_int64 (vtype_map* x, vtype_int64 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint8 (vtype_map* x, vtype_uint8 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint16 (vtype_map* x, vtype_uint16 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint32 (vtype_map* x, vtype_uint32 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_uint64 (vtype_map* x, vtype_uint64 key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_float (vtype_map* x, vtype_float key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_double (vtype_map* x, vtype_double key, void* data, map_access_callback, _Bool cut);
extern int libcdsb_map_find_ldouble(vtype_map* x, vtype_ldouble key, void* data, map_access_callback, _Bool cut);
extern _Bool libcdsb_map_update_pointer_pointer(vtype_map* x, const void* key, const void* value);
extern _Bool libcdsb_map_update_pointer_cstring(vtype_map* x, const void* key, const char* value);