From 047577a3e1837bf34f40ca6e1c8e0401f068a41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 May 2012 16:37:59 +0200 Subject: Particle : add eiotas_particle_data_set --- src/include/eiotas_particle.h | 11 +++++++++++ src/lib/eiotas_particle.c | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/include/eiotas_particle.h b/src/include/eiotas_particle.h index 2815b71..b752928 100644 --- a/src/include/eiotas_particle.h +++ b/src/include/eiotas_particle.h @@ -126,6 +126,17 @@ EAPI void eiotas_particle_link_fields_set(Eiotas_Particle *particle, const char EAPI const char* eiotas_particle_data_get(Eiotas_Particle *particle, const char *key); /** + * @brief Store a key:value data couple into the Eiotas_Particle + * + * @param particle The @ref Eiotas_Particle to store data into + * @param key The @ref Eina_Hash key + * @param value The value to store + * + * @return @ref EINA_FALSE if an error occurred, @ref EINA_TRUE otherwise. + */ +EAPI Eina_Bool eiotas_particle_data_set(Eiotas_Particle *particle, const char *key, const char *value); + +/** * @} */ diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 5a37ae0..38fc263 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -152,6 +152,19 @@ EAPI const char* eiotas_particle_data_get(Eiotas_Particle *particle, const char* return eina_hash_find(particle->payload,key); } +EAPI Eina_Bool eiotas_particle_data_set(Eiotas_Particle *particle, const char* key, const char* value) +{ + unsigned int i; + Eina_Stringshare *s; + Eina_Array_Iterator it; + + s = eina_stringshare_add(value); + if(!eina_hash_add(particle->payload,key,s)) 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