eina_value_01.c
//Compile with:
//gcc eina_value_01.c -o eina_value_01 `pkg-config --cflags --libs eina`
#include <Eina.h>
int main(int argc, char **argv)
{
(void)argc;
(void)argv;
int i;
char *newstr;
eina_value_set(&v, 123);
eina_value_get(&v, &i);
printf("v=%d\n", i);
newstr = eina_value_to_string(&v);
printf("v as string: %s\n", newstr);
free(newstr); // it was allocated by eina_value_to_string()
eina_value_flush(&v); // destroy v contents, will not use anymore
const char *s;
eina_value_set(&v, "My string");
eina_value_get(&v, &s);
printf("v=%s (pointer: %p)\n", s, s);
newstr = eina_value_to_string(&v);
printf("v as string: %s (pointer: %p)\n", newstr, newstr);
free(newstr); // it was allocated by eina_value_to_string()
eina_value_flush(&v); // destroy v contents, string 's' is not valid anymore!
Eina_Value otherv;
// convert from int to string:
eina_value_set(&v, 123);
eina_value_convert(&v, &otherv);
eina_value_get(&otherv, &s);
printf("otherv=%s\n", s);
// and the other way around!
eina_value_set(&otherv, "33");
eina_value_convert(&otherv, &v);
eina_value_get(&v, &i);
printf("v=%d\n", i);
eina_value_flush(&otherv);
}
eina_value_setup
static Eina_Bool eina_value_setup(Eina_Value *value, const Eina_Value_Type *type)
Initializes generic value storage.
EINA_VALUE_TYPE_INT
const EAPI Eina_Value_Type * EINA_VALUE_TYPE_INT
Definition: eina_value.c:5599
Eina.h
Eina Utility library.
eina_init
int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:277
eina_value_convert
EAPI Eina_Bool eina_value_convert(const Eina_Value *value, Eina_Value *convert)
Converts one value to another type.
Definition: eina_value.c:5692
eina_value_set
static Eina_Bool eina_value_set(Eina_Value *value,...)
Sets the generic value.
eina_value_get
static Eina_Bool eina_value_get(const Eina_Value *value,...)
Gets the generic value.
eina_value_flush
static void eina_value_flush(Eina_Value *value)
Empties a generic value storage.
eina_shutdown
int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:348
EINA_VALUE_TYPE_STRING
const EAPI Eina_Value_Type * EINA_VALUE_TYPE_STRING
Definition: eina_value.c:5605
_Eina_Value
Definition: eina_value.h:661
eina_value_to_string
EAPI char * eina_value_to_string(const Eina_Value *value)
Converts value to string.
Definition: eina_value.c:5723