2 //gcc eina_value_01.c -o eina_value_01 `pkg-config --cflags --libs eina`
6 int main(int argc, char **argv)
14 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
15 eina_value_set(&v, 123);
16 eina_value_get(&v, &i);
19 newstr = eina_value_to_string(&v);
20 printf("v as string: %s\n", newstr);
21 free(newstr); // it was allocated by eina_value_to_string()
22 eina_value_flush(&v); // destroy v contents, will not use anymore
25 eina_value_setup(&v, EINA_VALUE_TYPE_STRING);
26 eina_value_set(&v, "My string");
27 eina_value_get(&v, &s);
28 printf("v=%s (pointer: %p)\n", s, s);
30 newstr = eina_value_to_string(&v);
31 printf("v as string: %s (pointer: %p)\n", newstr, newstr);
32 free(newstr); // it was allocated by eina_value_to_string()
33 eina_value_flush(&v); // destroy v contents, string 's' is not valid anymore!
36 eina_value_setup(&otherv, EINA_VALUE_TYPE_STRING);
37 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
39 // convert from int to string:
40 eina_value_set(&v, 123);
41 eina_value_convert(&v, &otherv);
42 eina_value_get(&otherv, &s);
43 printf("otherv=%s\n", s);
45 // and the other way around!
46 eina_value_set(&otherv, "33");
47 eina_value_convert(&otherv, &v);
48 eina_value_get(&v, &i);
51 eina_value_flush(&otherv);