src/cx/kv_list.h

changeset 1406
85dc816f3442
parent 1404
ae80e36c05c7
child 1407
59290d70434a
--- a/src/cx/kv_list.h	Mon Sep 29 23:31:59 2025 +0200
+++ b/src/cx/kv_list.h	Tue Sep 30 20:29:55 2025 +0200
@@ -184,52 +184,6 @@
 cx_attr_export
 int cx_kv_list_insert(CxList *list, size_t index, CxHashKey key, void *value);
 
-// Generic Functions
-#ifdef __cplusplus
-} // extern "C"
-cx_attr_nonnull
-static inline int cxKvListSetKey(CxList *list, size_t index, CxHashKey key) {
-    return cx_kv_list_set_key(list, index, key);
-}
-
-cx_attr_nonnull
-static inline int cxKvListSetKey(CxList *list, size_t index, cxstring key) {
-    return cx_kv_list_set_key(list, index, cx_hash_key_cxstr(key));
-}
-
-cx_attr_nonnull
-static inline int cxKvListSetKey(CxList *list, size_t index, cxmutstr key) {
-    return cx_kv_list_set_key(list, index, cx_hash_key_cxstr(key));
-}
-
-cx_attr_nonnull
-cx_attr_cstr_arg(3)
-static inline int cxKvListSetKey(CxList *list, size_t index, const char *key) {
-    return cx_kv_list_set_key(list, index, cx_hash_key_str(key));
-}
-
-cx_attr_nonnull
-static inline int cxKvListInsert(CxList *list, size_t index, CxHashKey key, void *value) {
-    return cx_kv_list_insert(list, index, key, value);
-}
-
-cx_attr_nonnull
-static inline int cxKvListInsert(CxList *list, size_t index, cxstring key, void *value) {
-    return cx_kv_list_insert(list, index, cx_hash_key_cxstr(key), value);
-}
-
-cx_attr_nonnull
-static inline int cxKvListInsert(CxList *list, size_t index, cxmutstr key, void *value) {
-    return cx_kv_list_insert(list, index, cx_hash_key_cxstr(key), value);
-}
-
-cx_attr_nonnull
-cx_attr_cstr_arg(3)
-static inline int cxKvListInsert(CxList *list, size_t index, const char *key, void *value) {
-    return cx_kv_list_insert(list, index, cx_hash_key_str(key), value);
-}
-extern "C" {
-#else /* ! __cplusplus */
 /**
  * Sets or updates the key of a list item.
  *
@@ -238,69 +192,26 @@
  *
  * @param list (@c CxList*) the list
  * @param index (@c size_t) the index of the element in the list
- * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
+ * @param key (any supported key type) the key
  * @retval zero success
  * @retval non-zero memory allocation failure or the index is out of bounds
+ * @see CX_HASH_KEY()
  */
-#define cxKvListSetKey(list, index, key) _Generic((key), \
-        CxHashKey: cx_kv_list_set_key,                   \
-        cxstring: cx_kv_list_set_key_cxstr,              \
-        cxmutstr: cx_kv_list_set_key_mustr,              \
-        char*: cx_kv_list_set_key_str,                   \
-        const char*: cx_kv_list_set_key_str)             \
-        (list, index, key)
-
-cx_attr_nonnull
-static inline int cx_kv_list_set_key_cxstr(CxList *list, size_t index, cxstring key) {
-    return cx_kv_list_set_key(list, index, cx_hash_key_cxstr(key));
-}
-
-cx_attr_nonnull
-static inline int cx_kv_list_set_key_mustr(CxList *list, size_t index, cxmutstr key) {
-    return cx_kv_list_set_key(list, index, cx_hash_key_cxstr(key));
-}
-
-cx_attr_nonnull
-cx_attr_cstr_arg(3)
-static inline int cx_kv_list_set_key_str(CxList *list, size_t index, const char *key) {
-    return cx_kv_list_set_key(list, index, cx_hash_key_str(key));
-}
+#define cxKvListSetKey(list, index, key) cx_kv_list_set_key(list, index, CX_HASH_KEY(key))
 
 /**
  * Inserts an item into the list at the specified index and associates it with the specified key.
  *
  * @param list (@c CxList*) the list
  * @param index (@c size_t) the index the inserted element shall have
- * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
+ * @param key (any supported key type) the key
  * @param value (@c void*) the value
  * @retval zero success
  * @retval non-zero memory allocation failure or the index is out of bounds
+ * @see CX_HASH_KEY()
  */
-#define cxKvListInsert(list, index, key, value) _Generic((key), \
-        CxHashKey: cx_kv_list_insert,                           \
-        cxstring: cx_kv_list_insert_cxstr,                      \
-        cxmutstr: cx_kv_list_insert_mustr,                      \
-        char*: cx_kv_list_insert_str,                           \
-        const char*: cx_kv_list_insert_str)                     \
-        (list, index, key, value)
+#define cxKvListInsert(list, index, key, value) cx_kv_list_insert(list, index, CX_HASH_KEY(key), value)
 
-cx_attr_nonnull
-static inline int cx_kv_list_insert_cxstr(CxList *list, size_t index, cxstring key, void *value) {
-    return cx_kv_list_insert(list, index, cx_hash_key_cxstr(key), value);
-}
-
-cx_attr_nonnull
-static inline int cx_kv_list_insert_mustr(CxList *list, size_t index, cxmutstr key, void *value) {
-    return cx_kv_list_insert(list, index, cx_hash_key_cxstr(key), value);
-}
-
-cx_attr_nonnull
-cx_attr_cstr_arg(3)
-static inline int cx_kv_list_insert_str(CxList *list, size_t index, const char *key, void *value) {
-    return cx_kv_list_insert(list, index, cx_hash_key_str(key), value);
-}
-
-#endif
 
 /**
  * Removes the key of a list item.

mercurial