From 01e95f4f8601d7fef228fb61c74cdb95d37acb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 May 2012 16:38:12 +0200 Subject: Particle : add eiotas_particle_data_del --- src/include/eiotas_particle.h | 10 ++++++++++ src/lib/eiotas_particle.c | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/include/eiotas_particle.h b/src/include/eiotas_particle.h index b752928..26489aa 100644 --- a/src/include/eiotas_particle.h +++ b/src/include/eiotas_particle.h @@ -137,6 +137,16 @@ EAPI const char* eiotas_particle_data_get(Eiotas_Particle *particle, const char EAPI Eina_Bool eiotas_particle_data_set(Eiotas_Particle *particle, const char *key, const char *value); /** + * @brief Delete the data associated to a given key + * + * @param particle The @ref Eiotas_Particle to delete data from + * @param key The @ref Eina_Hash key + * + * @return @ref EINA_FALSE if an error occurred, @ref EINA_TRUE otherwise. + */ +EAPI Eina_Bool eiotas_particle_data_del(Eiotas_Particle *particle, const char *key); + +/** * @} */ diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 38fc263..cf92aaa 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -165,6 +165,18 @@ EAPI Eina_Bool eiotas_particle_data_set(Eiotas_Particle *particle, const char* k return EINA_TRUE; } +EAPI Eina_Bool eiotas_particle_data_del(Eiotas_Particle *particle, const char* key) +{ + unsigned int i; + Eina_Stringshare *s; + Eina_Array_Iterator it; + + if(!eina_hash_del(particle->payload,key,NULL)) return EINA_FALSE; + update_link_value(particle,key); + + return EINA_TRUE; +} + static void update_link_value(Eiotas_Particle *particle, const char *field) { unsigned int i; -- cgit v1.1-2-g2b99