src/cx/kv_list.h

changeset 1377
1562bdf948da
parent 1356
0ffcccb83b69
child 1378
1b4fa55f7caa
equal deleted inserted replaced
1376:0698e573936f 1377:1562bdf948da
211 static inline int cxKvListSetKey(CxList *list, size_t index, const char *key) { 211 static inline int cxKvListSetKey(CxList *list, size_t index, const char *key) {
212 return cx_kv_list_set_key(list, index, cx_hash_key_str(key)); 212 return cx_kv_list_set_key(list, index, cx_hash_key_str(key));
213 } 213 }
214 214
215 cx_attr_nonnull 215 cx_attr_nonnull
216 static inline int cxKvListRemoveKey(CxList *list, size_t index, CxHashKey key) {
217 return cx_kv_list_remove_key(list, index, key);
218 }
219
220 cx_attr_nonnull
221 static inline int cxKvListRemoveKey(CxList *list, size_t index, cxstring key) {
222 return cx_kv_list_remove_key(list, index, cx_hash_key_cxstr(key));
223 }
224
225 cx_attr_nonnull
226 static inline int cxKvListRemoveKey(CxList *list, size_t index, cxmutstr key) {
227 return cx_kv_list_remove_key(list, index, cx_hash_key_cxstr(key));
228 }
229
230 cx_attr_nonnull
231 cx_attr_cstr_arg(3)
232 static inline int cxKvListRemoveKey(CxList *list, size_t index, const char *key) {
233 return cx_kv_list_remove_key(list, index, cx_hash_key_str(key));
234 }
235
236 cx_attr_nonnull
237 static inline int cxKvListInsert(CxList *list, size_t index, CxHashKey key, void *value) { 216 static inline int cxKvListInsert(CxList *list, size_t index, CxHashKey key, void *value) {
238 return cx_kv_list_insert(list, index, key, value); 217 return cx_kv_list_insert(list, index, key, value);
239 } 218 }
240 219
241 cx_attr_nonnull 220 cx_attr_nonnull
290 static inline int cx_kv_list_set_key_str(CxList *list, size_t index, const char *key) { 269 static inline int cx_kv_list_set_key_str(CxList *list, size_t index, const char *key) {
291 return cx_kv_list_set_key(list, index, cx_hash_key_str(key)); 270 return cx_kv_list_set_key(list, index, cx_hash_key_str(key));
292 } 271 }
293 272
294 /** 273 /**
295 * Removes the key for a list item. 274 * Removes the key of a list item.
296 * 275 *
297 * This can be useful if you want to explicitly remove an item from the lookup map, 276 * This can be useful if you want to explicitly remove an item from the lookup map.
298 * for example, when you want to prevent a deletion by cxMapClear(). 277 *
299 * 278 * If no key is associated with the item, nothing happens, and this function returns zero.
300 * @param list (@c CxList*) the list 279 *
301 * @param index (@c size_t) the index of the element in the list 280 * @param list the list
302 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key 281 * @param index the index of the element in the list
303 * @retval zero success 282 * @retval zero success
304 * @retval non-zero the index is out of bounds 283 * @retval non-zero the index is out of bounds
305 */ 284 */
306 #define cxKvListRemoveKey(list, index, key) _Generic((key), \ 285 cx_attr_nonnull
307 CxHashKey: cx_kv_list_remove_key, \ 286 cx_attr_export
308 cxstring: cx_kv_list_remove_key_cxstr, \ 287 int cxKvListRemoveKey(CxList *list, size_t index);
309 cxmutstr: cx_kv_list_remove_key_mustr, \
310 char*: cx_kv_list_remove_key_str, \
311 const char*: cx_kv_list_remove_key_str) \
312 (list, index, key)
313
314 cx_attr_nonnull
315 static inline int cx_kv_list_remove_key_cxstr(CxList *list, size_t index, cxstring key) {
316 return cx_kv_list_remove_key(list, index, cx_hash_key_cxstr(key));
317 }
318
319 cx_attr_nonnull
320 static inline int cx_kv_list_remove_key_mustr(CxList *list, size_t index, cxmutstr key) {
321 return cx_kv_list_remove_key(list, index, cx_hash_key_cxstr(key));
322 }
323
324 cx_attr_nonnull
325 cx_attr_cstr_arg(3)
326 static inline int cx_kv_list_remove_key_str(CxList *list, size_t index, const char *key) {
327 return cx_kv_list_remove_key(list, index, cx_hash_key_str(key));
328 }
329 288
330 /** 289 /**
331 * Inserts an item into the list at the specified index and associates it with the specified key. 290 * Inserts an item into the list at the specified index and associates it with the specified key.
332 * 291 *
333 * @param list (@c CxList*) the list 292 * @param list (@c CxList*) the list

mercurial