diff --git a/README.md b/README.md index 2c817bfc..c4db7837 100644 --- a/README.md +++ b/README.md @@ -434,6 +434,7 @@ Other documented operators are: * GET\_KEY (container, key) --> &obj: return a pointer to the object within the container associated to the key 'key' or return NULL if no object is associated to this key. The pointer to the object remains valid until any modification of the container. * SET\_KEY (container, key, object): Associate in the container the key 'key' to the object 'object'. * GET\_SET\_KEY (container, key) --> &obj: return a pointer to the object within the container associated to the key 'key' or create a new object in the container, associate it to the key 'key' and return its pointer. The pointer to the object remains valid until any modification of the container. The returned pointer cannot be NULL. +* ERASE\_KEY (container, key) --> bool: true to erase the object associated to the key 'key' within the container. Return true if successful, false if the key is not found. * PUSH(container, obj) : push 'object' into 'container'. How it is pushed is container dependent. * POP(&obj, container) : pop an object from 'container' and save it in '*obj' if obj is not NULL (giving back the ownership to the caller). Which object is popped is container dependent. Undefined behavior is there is no object in the container. * PUSH_MOVE(container, &obj) : push and move the object '*obj' into 'container'. How it is pushed is container dependent but '*obj' is cleared afterward. diff --git a/m-core.h b/m-core.h index b61a10cc..805dbd53 100644 --- a/m-core.h +++ b/m-core.h @@ -1787,6 +1787,7 @@ m_core_hash (const void *str, size_t length) #define M_GET_KEY_GET_KEY(a) ,a, #define M_SET_KEY_SET_KEY(a) ,a, #define M_GET_SET_KEY_GET_SET_KEY(a) ,a, +#define M_ERASE_KEY_ERASE_KEY(a) ,a, #define M_PUSH_PUSH(a) ,a, #define M_POP_POP(a) ,a, #define M_PUSH_MOVE_PUSH_MOVE(a) ,a, @@ -1857,6 +1858,7 @@ m_core_hash (const void *str, size_t length) #define M_GET_GET_KEY(...) M_GET_METHOD(GET_KEY, M_NO_DEFAULT, __VA_ARGS__) #define M_GET_SET_KEY(...) M_GET_METHOD(SET_KEY, M_NO_DEFAULT, __VA_ARGS__) #define M_GET_GET_SET_KEY(...) M_GET_METHOD(GET_SET_KEY, M_NO_DEFAULT, __VA_ARGS__) +#define M_GET_ERASE_KEY(...) M_GET_METHOD(ERASE_KEY, M_NO_DEFAULT, __VA_ARGS__) #define M_GET_PUSH(...) M_GET_METHOD(PUSH, M_NO_DEFAULT, __VA_ARGS__) #define M_GET_POP(...) M_GET_METHOD(POP, M_NO_DEFAULT, __VA_ARGS__) #define M_GET_PUSH_MOVE(...) M_GET_METHOD(PUSH_MOVE, M_NO_DEFAULT, __VA_ARGS__) @@ -1896,8 +1898,6 @@ m_core_hash (const void *str, size_t length) #define M_CALL_SUBTYPE(oplist, ...) M_APPLY_API(M_GET_SUBTYPE oplist, oplist, __VA_ARGS__) #define M_CALL_OPLIST(oplist, ...) M_APPLY_API(M_GET_OPLIST oplist, oplist, __VA_ARGS__) #define M_CALL_SORT(oplist, ...) M_APPLY_API(M_GET_SORT oplist, oplist, __VA_ARGS__) -#define M_CALL_GET_KEY(oplist, ...) M_APPLY_API(M_GET_GET_KEY oplist, oplist, __VA_ARGS__) -#define M_CALL_SET_KEY(oplist, ...) M_APPLY_API(M_GET_SET_KEY oplist, oplist, __VA_ARGS__) #define M_CALL_SPLICE_BACK(oplist, ...) M_APPLY_API(M_GET_SPLICE_BACK oplist, oplist, __VA_ARGS__) #define M_CALL_SPLICE_AT(oplist, ...) M_APPLY_API(M_GET_SPLICE_AT oplist, oplist, __VA_ARGS__) #define M_CALL_IT_TYPE(oplist, ...) M_APPLY_API(M_GET_IT_TYPE oplist, oplist, __VA_ARGS__) @@ -1919,6 +1919,10 @@ m_core_hash (const void *str, size_t length) #define M_CALL_MUL(oplist, ...) M_APPLY_API(M_GET_MUL oplist, oplist, __VA_ARGS__) #define M_CALL_DIV(oplist, ...) M_APPLY_API(M_GET_DIV oplist, oplist, __VA_ARGS__) #define M_CALL_CLEAN(oplist, ...) M_APPLY_API(M_GET_CLEAN oplist, oplist, __VA_ARGS__) +#define M_CALL_GET_KEY(oplist, ...) M_APPLY_API(M_GET_KEY oplist, oplist, __VA_ARGS__) +#define M_CALL_SET_KEY(oplist, ...) M_APPLY_API(M_SET_KEY oplist, oplist, __VA_ARGS__) +#define M_CALL_GET_SET_KEY(oplist, ...) M_APPLY_API(M_GET_SET_KEY oplist, oplist, __VA_ARGS__) +#define M_CALL_ERASE_KEY(oplist, ...) M_APPLY_API(M_GET_ERASE_KEY oplist, oplist, __VA_ARGS__) #define M_CALL_PUSH(oplist, ...) M_APPLY_API(M_GET_PUSH oplist, oplist, __VA_ARGS__) #define M_CALL_POP(oplist, ...) M_APPLY_API(M_GET_POP oplist, oplist, __VA_ARGS__) #define M_CALL_PUSH_MOVE(oplist, ...) M_APPLY_API(M_GET_PUSH_MOVE oplist, oplist, __VA_ARGS__)