1 /* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
24 #include "eina_types.h"
25 #include "eina_fp.h" /* defines int64_t and uint64_t */
26 #include "eina_inarray.h"
27 #include "eina_list.h"
28 #include "eina_hash.h"
31 * @page eina_value_example_01_page Eina_Value usage
32 * @dontinclude eina_value_01.c
34 * This very simple example shows how to use some of the basic features of eina
35 * value: setting and getting values, converting between types and printing a
38 * Our main function starts out with the basic, declaring some variables and
42 * Now we can jump into using eina value. We set a value, get this value and
46 * In the above snippet of code we printed an @c int value, we can however print
47 * the value as a string:
50 * And once done with a value it's good practice to destroy it:
51 * @until eina_value_flush
53 * We now reuse @c v to store a string, get its value and print it:
55 * @note Since @c s is the value and not returned by @c eina_value_to_string()
56 * we don't need to free it.
58 * Just because we stored a string doesn't mean we can't use the @c
59 * eina_value_to_string() function, we can and it's important to note that it
60 * will return not the stored string but rather a copy of it(one we have to
62 * @until eina_value_flush
64 * And now to explore conversions between two type we'll create another value:
65 * @until eina_value_setup
67 * And make sure @c v and @c otherv have different types:
68 * @until eina_value_setup
70 * We then set a value to @c v and have it converted, to do this we don't need
71 * to tell to which type we want to convert, we just say were we want to store
72 * the converted value and eina value will figure out what to convert to, and
74 * @until eina_value_convert
76 * And now let's check the conversion worked:
79 * But converting to strings is not particularly exciting, @c
80 * eina_value_to_string() already did that, so now let's make the conversion the
81 * other way around, from string to @c int:
84 * And once done, destroy the values:
87 * Full source code: @ref eina_value_01_c
91 * @page eina_value_01_c eina_value_01.c
92 * @include eina_value_01.c
93 * @example eina_value_01.c
97 * @page eina_value_example_02_page Eina_Value struct usage
98 * @dontinclude eina_value_02.c
100 * This example will examine a hypothetical situation in which we had a
101 * structure(which represented parameters) with two fields, and then need to add
102 * a third field to our structure. If using structs directly we'd need to
103 * rewrite every piece of code that touches the struct, by using eina value, and
104 * thus having the compiler not even know the struct, we can reduce the amount
105 * of changes needed and retain interoperability between the old and new format.
107 * Our example will start with a function that creates descriptions of both of
108 * our structs for eina value usage. The first step is to create a struct and
109 * describe its members:
110 * @until v1_members[1]
111 * @note We can't pass the types of the members to EINA_VALUE_STRUCT_MEMBER
112 * macro because they are not constant initializers.
114 * So far it should be pretty easy to understand, we said @c My_Struct_V1 has
115 * two members, one of type @c int and another of type @c char. We now create
116 * the description of the actual struct, again nothing overly complex, we signal
117 * which version of EINA_VALUE_STRUCT we're using, we declare no special
118 * operations, our members and our size:
121 * We now repeat the process for the second version of our struct, the only
122 * difference is the addition of a third parameter of type @c int :
126 * We'll now look at a function that sets the values of our structs. For
127 * simplicity's sake we initialize it we random values, a real world case would
128 * read these values from a file, a database or even from the network. The
129 * fundamental detail here is that this function works for both V1 and V2
130 * structs, this is because setting a parameter that a struct that doesn't have
131 * does nothing without throwing any errors:
133 * @note While using eina_value_struct_set() with an in-existing parameter
134 * causes no error, it does return #EINA_FALSE, to notify it was not possible
135 * to set the value. This could be used to determine that we're handling a V1
136 * struct and take some action based on that.
138 * The next thing is to do is see what a function that uses the values of the
139 * struct looks like. We'll again be very simplistic in our usage, we'll just
140 * print the values, but a real world case, might send these values to another
141 * process use them to open a network/database connection or anything else.
142 * Since all versions of the struct have @c param1 and @c param2 we'll
143 * unconditionally use them:
146 * The next step is to conditionally use @c param3, which can fortunately be
147 * done in the same step in which we get it's value:
150 * There we've now got functions that can both populate and use values from both
151 * our structs, so now let's actually use them in our main function by creating
152 * a struct of each type, initializing them and them using them:
155 * This concludes our example. For the full source code see @ref
160 * @page eina_value_02_c eina_value_02.c
161 * @include eina_value_02.c
162 * @example eina_value_02.c
166 * @page eina_value_example_03_page Eina value custom type example
167 * @dontinclude eina_value_03.c
169 * For this example we'll be creating our own custom type of eina value. Eina
170 * value can already store struct timeval(man gettimeofday for more information)
171 * but it has no type to store struct timezone, so that's what this example will
173 * @note struct timezone is actually obsolete, so using it in real world
174 * programs is probably not a good idea, but this is an example so, bear with
177 * To create our own custom eina value type we need to define functions to
178 * do the following operations on it:
187 * Most of this functions are very simple, so let's look at them, starting with
188 * setup which only clear the memory so that we can be certain we won't be using
192 * Now the flush function, which is even simpler, it does nothing, that's
193 * because there is nothing we need to do, all the necessary steps are taken by
197 * Our next function, copy, is a bit more interesting, but not much, it just
198 * casts our void pointers to struct timezone pointers and does the copy:
200 * @note By now you might be wondering why our functions receive void pointers
201 * instead of pointers to struct timezone, and this is a good point. The reason
202 * for this is that eina value doesn't know anything about our type so it must
203 * use a generic void pointer, casting that pointer into a proper value is the
204 * job of the implementor of the new type.
206 * Next we have the comparison function, which compares the @c tz_minuteswest
207 * field of struct timezone, we don't compare @c tz_dsttime because that field
208 * is not used in linux:
211 * Next we have setting, this however requires not one but rather two functions,
212 * the reason for this is because to be able to receive arguments of any type
213 * eina value uses <a href="https://wikipedia.org/wiki/Variadic_functions">
214 * variadic functions</a>, so we need a function to get the argument from a
215 * va_list and another to actually to the setting.
217 * Lets first look at the pset function which sets the received value to a
221 * Next we have the vset function which get the argument from the va_list and
222 * passes it to the pset function:
225 * And now the function to get the value, a very simple copying of the value to
229 * And finally our conversion function, this is our longest and most interesting
230 * one. For numeric type we simply assign the value of @c tz_minuteswest to the
231 * new type and call a set function using it:
232 * @until EINA_VALUE_TYPE_DOUBLE
234 * @note It would be a good idea to add checks for over and underflow for these
235 * types and return #EINA_FALSE in thoses cases, we omit this here for brevity.
237 * For string types we use @c snprintf() to format our @c tz_minuteswest field
238 * and put it in a string(again @c tz_dsttime is ignored because it's not used):
241 * Finally we handle any other types by returning an error in that case:
244 * Now that we have all the functions, we can populate an @c Eina_Value_Type to
245 * later use it with @c eina_value_setup():
248 * We can now finally use our new TZ_TYPE with eina value, so lets conclude our
249 * example by practicing that by setting its value and printing it:
252 * For the full source code see @ref eina_value_03_c.
256 * @page eina_value_03_c eina_value_03.c
257 * @include eina_value_03.c
258 * @example eina_value_03.c
262 * @addtogroup Eina_Data_Types_Group Data Types
270 * @addtogroup Eina_Containers_Group Containers
276 * @defgroup Eina_Value_Group Generic Value Storage
278 * Abstracts generic data storage and access to it in an extensible
281 * It comes with pre-defined types for numbers, array, list, hash,
282 * blob and structs. It is able to convert between data types,
283 * including to string.
285 * It is meant for simple data types, providing uniform access and
286 * release functions, useful to exchange data preserving their
287 * types. For more complex hierarchical data, with properties and
288 * children, reference counting, inheritance and interfaces,
290 * Examples of usage of the Eina_Value API:
291 * @li @ref eina_value_example_01_page
292 * @li @ref eina_value_example_02_page
293 * @li @ref eina_value_example_03_page
300 * @typedef Eina_Value
301 * Store generic values.
305 typedef struct _Eina_Value Eina_Value;
308 * @typedef Eina_Value_Type
309 * Describes the data contained by the value
313 typedef struct _Eina_Value_Type Eina_Value_Type;
316 * @typedef Eina_Value_Union
317 * Union of all known value types.
319 * This is only used to specify the minimum payload memory for #Eina_Value.
324 typedef union _Eina_Value_Union Eina_Value_Union;
327 * @union _Eina_Value_Union
328 * All possible value types.
330 * This is only used to specify the minimum payload memory for #Eina_Value.
335 union _Eina_Value_Union
337 unsigned char buf[8]; /**< just hold 8-bytes, more goes into ptr */
338 void *ptr; /**< used as generic pointer */
339 uint64_t _guarantee; /**< guarantees 8-byte alignment */
343 * @var EINA_VALUE_TYPE_UCHAR
344 * manages unsigned char type.
348 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR;
351 * @var EINA_VALUE_TYPE_USHORT
352 * manages unsigned short type.
356 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_USHORT;
359 * @var EINA_VALUE_TYPE_UINT
360 * manages unsigned int type.
364 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT;
367 * @var EINA_VALUE_TYPE_ULONG
368 * manages unsigned long type.
372 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG;
375 * @var EINA_VALUE_TYPE_TIMESTAMP
376 * manages unsigned long type used for timestamps.
377 * @note this is identical in function to EINA_VALUE_TYPE_ULONG
381 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMESTAMP;
384 * @var EINA_VALUE_TYPE_UINT64
385 * manages unsigned integer of 64 bits type.
389 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT64;
392 * @var EINA_VALUE_TYPE_CHAR
397 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_CHAR;
400 * @var EINA_VALUE_TYPE_SHORT
401 * manages short type.
405 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_SHORT;
408 * @var EINA_VALUE_TYPE_INT
413 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT;
416 * @var EINA_VALUE_TYPE_LONG
421 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LONG;
424 * @var EINA_VALUE_TYPE_INT64
425 * manages integer of 64 bits type.
429 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT64;
432 * @var EINA_VALUE_TYPE_FLOAT
433 * manages float type.
437 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_FLOAT;
440 * @var EINA_VALUE_TYPE_DOUBLE
441 * manages double type.
445 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_DOUBLE;
448 * @var EINA_VALUE_TYPE_STRINGSHARE
449 * manages stringshared string type.
453 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRINGSHARE;
456 * @var EINA_VALUE_TYPE_STRING
457 * manages string type.
461 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRING;
465 * @var EINA_VALUE_TYPE_ARRAY
467 * manages array type. Use the value get/set for arrays:
468 * @li eina_value_array_get() and eina_value_array_set()
469 * @li eina_value_array_vget() and eina_value_array_vset()
470 * @li eina_value_array_pget() and eina_value_array_pset()
472 * eina_value_set() takes an #Eina_Value_Array where just @c subtype
473 * and @c step are used. If there is an @c array, it will be copied
474 * (including each item) and its contents must be properly
475 * configurable as @c subtype expects. eina_value_pset() takes a
476 * pointer to an #Eina_Value_Array. For your convenience, use
477 * eina_value_array_setup().
479 * eina_value_get() and eina_value_pget() takes a pointer
480 * to #Eina_Value_Array, it's an exact copy of the current structure in
481 * use by value, no copies are done.
485 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY;
488 * @var EINA_VALUE_TYPE_LIST
490 * manages list type. Use the value get/set for lists:
491 * @li eina_value_list_get() and eina_value_list_set()
492 * @li eina_value_list_vget() and eina_value_list_vset()
493 * @li eina_value_list_pget() and eina_value_list_pset()
495 * eina_value_set() takes an #Eina_Value_List where just @c subtype is
496 * used. If there is an @c list, it will be copied (including each
497 * item) and its contents must be properly configurable as @c
498 * subtype expects. eina_value_pset() takes a pointer to an #Eina_Value_List.
499 * For your convenience, use eina_value_list_setup().
501 * eina_value_get() and eina_value_pget() takes a pointer to #Eina_Value_List,
502 * it's an exact copy of the current structure in use by value, no copies are
507 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST;
510 * @var EINA_VALUE_TYPE_HASH
512 * manages hash type. Use the value get/set for hashes:
513 * @li eina_value_hash_get() and eina_value_hash_set()
514 * @li eina_value_hash_vget() and eina_value_hash_vset()
515 * @li eina_value_hash_pget() and eina_value_hash_pset()
517 * eina_value_set() takes an #Eina_Value_Hash where just @c subtype
518 * and @c buckets_power_size are used. If there is an @c hash, it will
519 * be copied (including each item) and its contents must be
520 * properly configurable as @c subtype expects. eina_value_pset()
521 * takes a pointer to an #Eina_Value_Hash. For your convenience, use
522 * eina_value_hash_setup().
524 * eina_value_get() and eina_value_pget() takes a pointer to #Eina_Value_Hash,
525 * it's an exact copy of the current structure in use by value, no copies are
528 * @note be aware that hash data is always an allocated memory of size
529 * defined by @c subtype->value_size. If your @c subtype is an
530 * integer, add as data malloc(sizeof(int)). If your @c subtype
531 * is an string, add as data malloc(sizeof(char*)) and this data
532 * value must point to strdup(string)!
536 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_HASH;
539 * @var EINA_VALUE_TYPE_TIMEVAL
540 * manages 'struct timeval' type
542 * eina_value_set() takes a "struct timeval" from sys/time.h.
543 * eina_value_pset() takes a pointer to "struct timeval".
545 * eina_value_get() and eina_value_pget() takes a pointer to "struct
546 * timeval" and it's an exact copy of value.
550 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMEVAL;
553 * @var EINA_VALUE_TYPE_BLOB
554 * manages blob of bytes type, see @ref Eina_Value_Blob
556 * eina_value_set() takes an #Eina_Value_Blob
557 * eina_value_pset() takes a pointer to #Eina_Value_Blob.
559 * eina_value_get() and eina_value_pget() takes a pointer to #Eina_Value_Blob
560 * and it's an exact copy of value, no allocations are made.
562 * Memory is untouched unless you provide @c ops (operations) pointer.
566 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB;
569 * @var EINA_VALUE_TYPE_STRUCT
571 * manages struct type. Use the value get/set for structs:
572 * @li eina_value_struct_get() and eina_value_struct_set()
573 * @li eina_value_struct_vget() and eina_value_struct_vset()
574 * @li eina_value_struct_pget() and eina_value_struct_pset()
576 * eina_value_set() takes an #Eina_Value_Struct where just @c desc is
577 * used. If there is an @c memory, it will be copied (including each
578 * member) and its contents must be properly configurable as @c desc
579 * expects. eina_value_pset() takes a pointer to an #Eina_Value_Struct. For
580 * your convenience, use eina_value_struct_setup().
582 * eina_value_get() and eina_value_pget() takes a pointer
583 * to #Eina_Value_Struct, it's an exact copy of the current structure in
584 * use by value, no copies are done.
588 EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT;
591 * @var EINA_ERROR_VALUE_FAILED
592 * Error identifier corresponding to value check failure.
596 EAPI extern int EINA_ERROR_VALUE_FAILED;
599 * @defgroup Eina_Value_Value_Group Generic Value management
605 * @struct _Eina_Value
606 * defines the contents of a value
612 const Eina_Value_Type *type; /**< how to access values */
613 Eina_Value_Union value; /**< to be accessed with type descriptor */
617 * @brief Create generic value storage.
618 * @param type how to manage this value.
619 * @return The new value or @c NULL on failure.
621 * Create a new generic value storage. The members are managed using
622 * the description specified by @a type.
624 * Some types may specify more operations:
625 * eg. #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(),
626 * eina_value_array_get() and so on.
628 * On failure, @c NULL is returned and either #EINA_ERROR_OUT_OF_MEMORY
629 * or #EINA_ERROR_VALUE_FAILED is set.
631 * @note this calls creates from mempool and then uses
632 * eina_value_setup(). Consider using eina_value_flush() and
633 * eina_value_setup() instead to avoid memory allocations.
635 * @see eina_value_free()
639 EAPI Eina_Value *eina_value_new(const Eina_Value_Type *type) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
642 * @brief Free value and its data.
643 * @param value value object
645 * @see eina_value_flush()
649 EAPI void eina_value_free(Eina_Value *value) EINA_ARG_NONNULL(1);
653 * @brief Initialize generic value storage.
654 * @param value value object
655 * @param type how to manage this value.
656 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
658 * Initializes existing generic value storage. The members are managed using the
659 * description specified by @a type.
661 * Some types may specify more operations, as an example #EINA_VALUE_TYPE_ARRAY
662 * uses eina_value_array_set(), eina_value_array_get() and so on.
664 * @note Existing contents are ignored! If the value was previously used, then
665 * use eina_value_flush() first.
667 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
668 * or #EINA_ERROR_VALUE_FAILED is set.
670 * @see eina_value_flush()
674 static inline Eina_Bool eina_value_setup(Eina_Value *value,
675 const Eina_Value_Type *type) EINA_ARG_NONNULL(1, 2);
678 * @brief Create generic value storage.
679 * @param value value object
681 * Releases all the resources associated with an #Eina_Value. The
682 * value must be already set with eina_value_setup() or
685 * After this call returns, the contents of the value are undefined,
686 * but the value can be reused by calling eina_value_setup() again.
688 * @see eina_value_setup()
689 * @see eina_value_free()
693 static inline void eina_value_flush(Eina_Value *value) EINA_ARG_NONNULL(1);
696 * @brief Copy generic value storage.
697 * @param value source value object
698 * @param copy destination value object
699 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
701 * The @a copy object is considered uninitialized and its existing
702 * contents are overwritten (just as if eina_value_flush() was called on
705 * The copy happens by calling eina_value_setup() on @a copy, followed
706 * by getting the contents of @a value and setting it to @a copy.
710 EAPI Eina_Bool eina_value_copy(const Eina_Value *value,
711 Eina_Value *copy) EINA_ARG_NONNULL(1, 2);
714 * @brief Compare generic value storage.
715 * @param a left side of comparison
716 * @param b right side of comparison
717 * @return less than zero if a < b, greater than zero if a > b, zero
722 static inline int eina_value_compare(const Eina_Value *a,
723 const Eina_Value *b) EINA_ARG_NONNULL(1, 2);
726 * @brief Set the generic value.
727 * @param value source value object
728 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
730 * The variable argument is dependent on chosen type. The list for
733 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
734 * @li EINA_VALUE_TYPE_USHORT: unsigned short
735 * @li EINA_VALUE_TYPE_UINT: unsigned int
736 * @li EINA_VALUE_TYPE_ULONG: unsigned long
737 * @li EINA_VALUE_TYPE_UINT64: uint64_t
738 * @li EINA_VALUE_TYPE_CHAR: char
739 * @li EINA_VALUE_TYPE_SHORT: short
740 * @li EINA_VALUE_TYPE_INT: int
741 * @li EINA_VALUE_TYPE_LONG: long
742 * @li EINA_VALUE_TYPE_INT64: int64_t
743 * @li EINA_VALUE_TYPE_FLOAT: float
744 * @li EINA_VALUE_TYPE_DOUBLE: double
745 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
746 * @li EINA_VALUE_TYPE_STRING: const char *
747 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
748 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
749 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
750 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
751 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
752 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
755 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
757 * eina_value_set(value, 1234);
758 * eina_value_set(value, x);
760 * eina_value_flush(value);
762 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
763 * eina_value_set(value, "hello world!");
765 * eina_value_free(value);
768 * @note for array member see eina_value_array_set()
769 * @note for list member see eina_value_list_set()
770 * @note for hash member see eina_value_hash_set()
772 * @see eina_value_get()
773 * @see eina_value_vset()
774 * @see eina_value_pset()
778 static inline Eina_Bool eina_value_set(Eina_Value *value,
779 ...) EINA_ARG_NONNULL(1);
782 * @brief Get the generic value.
783 * @param value source value object
784 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
786 * The value is returned in the variable argument parameter, the
787 * actual value is type-dependent, but usually it will be what is
788 * stored inside the object. There shouldn't be any memory allocation,
789 * thus the contents should @b not be freed.
791 * The variable argument is dependent on chosen type. The list for
794 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
795 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
796 * @li EINA_VALUE_TYPE_UINT: unsigned int*
797 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
798 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
799 * @li EINA_VALUE_TYPE_CHAR: char*
800 * @li EINA_VALUE_TYPE_SHORT: short*
801 * @li EINA_VALUE_TYPE_INT: int*
802 * @li EINA_VALUE_TYPE_LONG: long*
803 * @li EINA_VALUE_TYPE_INT64: int64_t*
804 * @li EINA_VALUE_TYPE_FLOAT: float*
805 * @li EINA_VALUE_TYPE_DOUBLE: double*
806 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
807 * @li EINA_VALUE_TYPE_STRING: const char **
808 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
809 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
810 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
811 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
812 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
813 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
816 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
820 * eina_value_set(value, 1234);
821 * eina_value_get(value, &x);
823 * eina_value_flush(value);
825 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
826 * eina_value_set(value, "hello world!");
827 * eina_value_get(value, &s);
829 * eina_value_free(value);
832 * @note for array member see eina_value_array_get()
833 * @note for list member see eina_value_list_get()
834 * @note for hash member see eina_value_hash_get()
836 * @see eina_value_set()
837 * @see eina_value_vset()
838 * @see eina_value_pset()
842 static inline Eina_Bool eina_value_get(const Eina_Value *value,
843 ...) EINA_ARG_NONNULL(1);
846 * @brief Set the generic value.
847 * @param value source value object
848 * @param args variable argument
849 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
851 * @note for array member see eina_value_array_vset()
852 * @note for list member see eina_value_list_vset()
853 * @note for hash member see eina_value_hash_vset()
855 * @see eina_value_vget()
856 * @see eina_value_set()
857 * @see eina_value_pset()
861 static inline Eina_Bool eina_value_vset(Eina_Value *value,
862 va_list args) EINA_ARG_NONNULL(1);
865 * @brief Get the generic value.
866 * @param value source value object
867 * @param args variable argument
868 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
870 * The value is returned in the variable argument parameter, the
871 * actual value is type-dependent, but usually it will be what is
872 * stored inside the object. There shouldn't be any memory allocation,
873 * thus the contents should @b not be freed.
875 * @note for array member see eina_value_array_vget()
876 * @note for list member see eina_value_list_vget()
877 * @note for hash member see eina_value_hash_vget()
879 * @see eina_value_vset()
880 * @see eina_value_get()
881 * @see eina_value_pget()
885 static inline Eina_Bool eina_value_vget(const Eina_Value *value,
886 va_list args) EINA_ARG_NONNULL(1);
889 * @brief Set the generic value from pointer.
890 * @param value source value object
891 * @param ptr pointer to specify the contents.
892 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
894 * The pointer type is dependent on chosen value type. The list for
897 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
898 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
899 * @li EINA_VALUE_TYPE_UINT: unsigned int*
900 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
901 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
902 * @li EINA_VALUE_TYPE_CHAR: char*
903 * @li EINA_VALUE_TYPE_SHORT: short*
904 * @li EINA_VALUE_TYPE_INT: int*
905 * @li EINA_VALUE_TYPE_LONG: long*
906 * @li EINA_VALUE_TYPE_INT64: int64_t*
907 * @li EINA_VALUE_TYPE_FLOAT: float*
908 * @li EINA_VALUE_TYPE_DOUBLE: double*
909 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
910 * @li EINA_VALUE_TYPE_STRING: const char **
911 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
912 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
913 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
914 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
915 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
916 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
918 * @note the pointer contents are written using the size defined by
919 * type. It can be larger than void* or uint64_t.
922 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
924 * const char *s = "hello world!";
926 * eina_value_pset(value, &x);
928 * eina_value_flush(value);
930 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
931 * eina_value_pset(value, &s);
933 * eina_value_free(value);
936 * @note for array member see eina_value_array_pset()
937 * @note for list member see eina_value_list_pset()
938 * @note for hash member see eina_value_hash_pset()
940 * @see eina_value_pget()
941 * @see eina_value_set()
942 * @see eina_value_vset()
946 static inline Eina_Bool eina_value_pset(Eina_Value *value,
947 const void *ptr) EINA_ARG_NONNULL(1, 2);
950 * @brief Get the generic value to pointer.
951 * @param value source value object
952 * @param ptr pointer to receive the contents.
953 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
955 * The value is returned in pointer contents, the actual value is
956 * type-dependent, but usually it will be what is stored inside the
957 * object. There shouldn't be any memory allocation, thus the contents
958 * should @b not be freed.
960 * The pointer type is dependent on chosen value type. The list for
963 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
964 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
965 * @li EINA_VALUE_TYPE_UINT: unsigned int*
966 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
967 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
968 * @li EINA_VALUE_TYPE_CHAR: char*
969 * @li EINA_VALUE_TYPE_SHORT: short*
970 * @li EINA_VALUE_TYPE_INT: int*
971 * @li EINA_VALUE_TYPE_LONG: long*
972 * @li EINA_VALUE_TYPE_INT64: int64_t*
973 * @li EINA_VALUE_TYPE_FLOAT: float*
974 * @li EINA_VALUE_TYPE_DOUBLE: double*
975 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
976 * @li EINA_VALUE_TYPE_STRING: const char **
977 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
978 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
979 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
980 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
981 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
982 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
985 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
989 * eina_value_set(value, 1234);
990 * eina_value_pget(value, &x);
992 * eina_value_flush(value);
994 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
995 * eina_value_set(value, "hello world!");
996 * eina_value_pget(value, &s);
998 * eina_value_free(value);
1001 * @note for array member see eina_value_array_get()
1002 * @note for list member see eina_value_list_get()
1003 * @note for hash member see eina_value_hash_get()
1005 * @see eina_value_set()
1006 * @see eina_value_vset()
1007 * @see eina_value_pset()
1011 static inline Eina_Bool eina_value_pget(const Eina_Value *value,
1012 void *ptr) EINA_ARG_NONNULL(1, 2);
1015 * @brief Convert one value to another type.
1016 * @param value source value object.
1017 * @param convert destination value object.
1018 * @return #EINA_TRUE if converted, #EINA_FALSE otherwise.
1020 * Converts one value to another trying first @a value type
1021 * @c convert_to() function. If unsuccessful, tries using @c convert_from()
1022 * function in @a convert.
1024 * Conversion functions are type defined, and the basic types can convert
1025 * between themselves, but conversion is strict! That is, if
1026 * converting from negative value to unsigned type, it will fail. It
1027 * also fails on value overflow.
1029 * It is recommended that all types implement at least convert to
1030 * string, used by eina_value_to_string().
1032 * @note Both objects must have eina_value_setup() called on them beforehand!
1036 EAPI Eina_Bool eina_value_convert(const Eina_Value *value,
1037 Eina_Value *convert) EINA_ARG_NONNULL(1, 2);
1041 * @brief Convert value to string.
1042 * @param value value object.
1043 * @return newly allocated memory or @c NULL on failure.
1045 * @see eina_value_convert()
1048 EAPI char *eina_value_to_string(const Eina_Value *value) EINA_ARG_NONNULL(1);
1051 * @brief Query value type.
1052 * @param value value object.
1053 * @return type instance or @c NULL if type is invalid.
1055 * Check if value type is valid and returns it. A type is invalid if
1056 * it does not exist or if it is using a different version field.
1058 * @see eina_value_type_check()
1062 static inline const Eina_Value_Type *eina_value_type_get(const Eina_Value *value) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
1070 * @defgroup Eina_Value_Array_Group Generic Value Array management
1077 * @typedef Eina_Value_Array
1078 * Value type for #EINA_VALUE_TYPE_ARRAY.
1080 * @see #_Eina_Value_Array explains fields.
1083 typedef struct _Eina_Value_Array Eina_Value_Array;
1086 * @struct _Eina_Value_Array
1087 * Used to store the array and its subtype.
1090 struct _Eina_Value_Array
1092 const Eina_Value_Type *subtype; /**< how to allocate and access items */
1093 unsigned int step; /**< how to grow the members array */
1094 Eina_Inarray *array; /**< the array that holds data, members are of subtype->value_size bytes. */
1098 * @brief Create generic value storage of type array.
1099 * @param subtype how to manage this array members.
1100 * @param step how to grow the members array.
1101 * @return The new value or @c NULL on failure.
1103 * Create a new generic value storage of type array. The members are
1104 * managed using the description specified by @a subtype.
1106 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY
1107 * or #EINA_ERROR_VALUE_FAILED is set.
1109 * @note this creates from mempool and then uses
1110 * eina_value_array_setup(). @see eina_value_free() @see
1111 * eina_value_array_setup()
1115 EAPI Eina_Value *eina_value_array_new(const Eina_Value_Type *subtype,
1116 unsigned int step) EINA_ARG_NONNULL(1);
1119 * @brief Initialize generic value storage of type array.
1120 * @param value value object
1121 * @param subtype how to manage array members.
1122 * @param step how to grow the members array.
1123 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1125 * Initializes new generic value storage of type array with the given
1128 * This is the same as calling eina_value_set()
1129 * with #EINA_VALUE_TYPE_ARRAY followed by eina_value_pset() with
1130 * the #Eina_Value_Array description configured.
1132 * @note Existing contents are ignored! If the value was previously used, then
1133 * use eina_value_flush() first.
1135 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
1136 * or #EINA_ERROR_VALUE_FAILED is set.
1138 * @see eina_value_flush()
1142 static inline Eina_Bool eina_value_array_setup(Eina_Value *value,
1143 const Eina_Value_Type *subtype,
1144 unsigned int step) EINA_ARG_NONNULL(1, 2);
1147 * @brief Query number of elements in value of array type.
1148 * @param value value object.
1149 * @return number of child elements.
1152 static inline unsigned int eina_value_array_count(const Eina_Value *value);
1155 * @brief Remove element at given position in value of array type.
1156 * @param value value object.
1157 * @param position index of the member
1158 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1161 static inline Eina_Bool eina_value_array_remove(Eina_Value *value,
1162 unsigned int position) EINA_ARG_NONNULL(1);
1165 * @brief Set the generic value in an array member.
1166 * @param value source value object
1167 * @param position index of the member
1168 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1170 * The variable argument is dependent on chosen subtype. The list for
1173 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1174 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1175 * @li EINA_VALUE_TYPE_UINT: unsigned int
1176 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1177 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1178 * @li EINA_VALUE_TYPE_CHAR: char
1179 * @li EINA_VALUE_TYPE_SHORT: short
1180 * @li EINA_VALUE_TYPE_INT: int
1181 * @li EINA_VALUE_TYPE_LONG: long
1182 * @li EINA_VALUE_TYPE_INT64: int64_t
1183 * @li EINA_VALUE_TYPE_FLOAT: float
1184 * @li EINA_VALUE_TYPE_DOUBLE: double
1185 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1186 * @li EINA_VALUE_TYPE_STRING: const char *
1187 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1188 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1189 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1190 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1191 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1192 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1195 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1198 * eina_value_array_append(value, 1234);
1199 * eina_value_array_set(value, 0, 5678);
1200 * eina_value_array_get(value, 0, &x);
1201 * eina_value_free(value);
1204 * @see eina_value_array_get()
1205 * @see eina_value_array_vset()
1206 * @see eina_value_array_pset()
1207 * @see eina_value_array_insert()
1208 * @see eina_value_array_vinsert()
1209 * @see eina_value_array_pinsert()
1210 * @see eina_value_array_append()
1211 * @see eina_value_array_vappend()
1212 * @see eina_value_array_pappend()
1216 static inline Eina_Bool eina_value_array_set(Eina_Value *value,
1217 unsigned int position,
1218 ...) EINA_ARG_NONNULL(1);
1221 * @brief Get the generic value from an array member.
1222 * @param value source value object
1223 * @param position index of the member
1224 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1226 * The value is returned in the variable argument parameter, and the
1227 * actual value is type-dependent, but usually it will be what is
1228 * stored inside the object. There shouldn't be any memory allocation;
1229 * thus the contents should @b not be freed.
1231 * The variable argument is dependent on chosen subtype. The list for
1234 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1235 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1236 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1237 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1238 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1239 * @li EINA_VALUE_TYPE_CHAR: char*
1240 * @li EINA_VALUE_TYPE_SHORT: short*
1241 * @li EINA_VALUE_TYPE_INT: int*
1242 * @li EINA_VALUE_TYPE_LONG: long*
1243 * @li EINA_VALUE_TYPE_INT64: int64_t*
1244 * @li EINA_VALUE_TYPE_FLOAT: float*
1245 * @li EINA_VALUE_TYPE_DOUBLE: double*
1246 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1247 * @li EINA_VALUE_TYPE_STRING: const char **
1248 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1249 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1250 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1251 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1252 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1253 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1256 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1259 * eina_value_array_append(value, 1234);
1260 * eina_value_array_get(value, 0, &x);
1261 * eina_value_free(value);
1264 * @see eina_value_array_set()
1265 * @see eina_value_array_vset()
1266 * @see eina_value_array_pset()
1270 static inline Eina_Bool eina_value_array_get(const Eina_Value *value,
1271 unsigned int position,
1272 ...) EINA_ARG_NONNULL(1);
1275 * @brief Insert a generic value in an array member position.
1276 * @param value source value object
1277 * @param position index of the member
1278 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1280 * The variable argument is dependent on chosen subtype. The list for
1283 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1284 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1285 * @li EINA_VALUE_TYPE_UINT: unsigned int
1286 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1287 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1288 * @li EINA_VALUE_TYPE_CHAR: char
1289 * @li EINA_VALUE_TYPE_SHORT: short
1290 * @li EINA_VALUE_TYPE_INT: int
1291 * @li EINA_VALUE_TYPE_LONG: long
1292 * @li EINA_VALUE_TYPE_INT64: int64_t
1293 * @li EINA_VALUE_TYPE_FLOAT: float
1294 * @li EINA_VALUE_TYPE_DOUBLE: double
1295 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1296 * @li EINA_VALUE_TYPE_STRING: const char *
1297 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1298 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1299 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1300 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1301 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1302 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1305 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1308 * eina_value_array_insert(value, 0, 1234);
1309 * eina_value_array_get(value, 0, &x);
1310 * eina_value_free(value);
1313 * @see eina_value_array_set()
1314 * @see eina_value_array_get()
1315 * @see eina_value_array_vset()
1316 * @see eina_value_array_pset()
1317 * @see eina_value_array_vinsert()
1318 * @see eina_value_array_pinsert()
1319 * @see eina_value_array_append()
1320 * @see eina_value_array_vappend()
1321 * @see eina_value_array_pappend()
1325 static inline Eina_Bool eina_value_array_insert(Eina_Value *value,
1326 unsigned int position,
1327 ...) EINA_ARG_NONNULL(1);
1331 * @brief Append a generic value in an array.
1332 * @param value source value object
1333 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1335 * The variable argument is dependent on chosen subtype. The list for
1338 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1339 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1340 * @li EINA_VALUE_TYPE_UINT: unsigned int
1341 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1342 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1343 * @li EINA_VALUE_TYPE_CHAR: char
1344 * @li EINA_VALUE_TYPE_SHORT: short
1345 * @li EINA_VALUE_TYPE_INT: int
1346 * @li EINA_VALUE_TYPE_LONG: long
1347 * @li EINA_VALUE_TYPE_INT64: int64_t
1348 * @li EINA_VALUE_TYPE_FLOAT: float
1349 * @li EINA_VALUE_TYPE_DOUBLE: double
1350 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1351 * @li EINA_VALUE_TYPE_STRING: const char *
1352 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1353 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1354 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1355 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1356 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1357 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1360 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1363 * eina_value_array_append(value, 1234);
1364 * eina_value_array_get(value, 0, &x);
1365 * eina_value_free(value);
1368 * @see eina_value_array_set()
1369 * @see eina_value_array_get()
1370 * @see eina_value_array_vset()
1371 * @see eina_value_array_pset()
1372 * @see eina_value_array_vinsert()
1373 * @see eina_value_array_pinsert()
1374 * @see eina_value_array_append()
1375 * @see eina_value_array_vappend()
1376 * @see eina_value_array_pappend()
1380 static inline Eina_Bool eina_value_array_append(Eina_Value *value,
1381 ...) EINA_ARG_NONNULL(1);
1384 * @brief Set a generic value to an array member.
1385 * @param value source value object
1386 * @param position index of the member
1387 * @param args variable argument
1388 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1389 * @see eina_value_array_set()
1390 * @see eina_value_array_get()
1391 * @see eina_value_array_pset()
1392 * @see eina_value_array_insert()
1393 * @see eina_value_array_vinsert()
1394 * @see eina_value_array_pinsert()
1395 * @see eina_value_array_append()
1396 * @see eina_value_array_vappend()
1397 * @see eina_value_array_pappend()
1401 static inline Eina_Bool eina_value_array_vset(Eina_Value *value,
1402 unsigned int position,
1403 va_list args) EINA_ARG_NONNULL(1);
1406 * @brief Get the generic value from an array member.
1407 * @param value source value object
1408 * @param position index of the member
1409 * @param args variable argument
1410 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1412 * The value is returned in the variable argument parameter, the
1413 * actual value is type-dependent, but usually it will be what is
1414 * stored inside the object. There shouldn't be any memory allocation,
1415 * thus the contents should @b not be freed.
1417 * @see eina_value_array_vset()
1418 * @see eina_value_array_get()
1419 * @see eina_value_array_pget()
1423 static inline Eina_Bool eina_value_array_vget(const Eina_Value *value,
1424 unsigned int position,
1425 va_list args) EINA_ARG_NONNULL(1);
1427 * @brief Insert a generic value to an array member position.
1428 * @param value source value object
1429 * @param position index of the member
1430 * @param args variable argument
1431 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1432 * @see eina_value_array_set()
1433 * @see eina_value_array_get()
1434 * @see eina_value_array_vset()
1435 * @see eina_value_array_pset()
1436 * @see eina_value_array_insert()
1437 * @see eina_value_array_pinsert()
1438 * @see eina_value_array_append()
1439 * @see eina_value_array_vappend()
1440 * @see eina_value_array_pappend()
1444 static inline Eina_Bool eina_value_array_vinsert(Eina_Value *value,
1445 unsigned int position,
1446 va_list args) EINA_ARG_NONNULL(1);
1449 * @brief Append a generic value to an array.
1450 * @param value source value object
1451 * @param args variable argument
1452 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1453 * @see eina_value_array_set()
1454 * @see eina_value_array_get()
1455 * @see eina_value_array_vget()
1456 * @see eina_value_array_pset()
1457 * @see eina_value_array_insert()
1458 * @see eina_value_array_vinsert()
1459 * @see eina_value_array_pinsert()
1460 * @see eina_value_array_append()
1461 * @see eina_value_array_pappend()
1465 static inline Eina_Bool eina_value_array_vappend(Eina_Value *value,
1466 va_list args) EINA_ARG_NONNULL(1);
1470 * @brief Set a generic value to an array member from a pointer.
1471 * @param value source value object
1472 * @param position index of the member
1473 * @param ptr pointer to specify the contents.
1474 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1476 * The pointer type is dependent on chosen value type. The list for
1479 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1480 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1481 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1482 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1483 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1484 * @li EINA_VALUE_TYPE_CHAR: char*
1485 * @li EINA_VALUE_TYPE_SHORT: short*
1486 * @li EINA_VALUE_TYPE_INT: int*
1487 * @li EINA_VALUE_TYPE_LONG: long*
1488 * @li EINA_VALUE_TYPE_INT64: int64_t*
1489 * @li EINA_VALUE_TYPE_FLOAT: float*
1490 * @li EINA_VALUE_TYPE_DOUBLE: double*
1491 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1492 * @li EINA_VALUE_TYPE_STRING: const char **
1493 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1494 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1495 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1496 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1497 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1498 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1500 * @note the pointer contents are written using the size defined by
1501 * type. It can be larger than void* or uint64_t.
1504 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1507 * eina_value_array_append(value, 1234);
1508 * eina_value_array_pset(value, 0, &x);
1509 * eina_value_array_pget(value, 0, &x);
1510 * eina_value_free(value);
1513 * @see eina_value_array_set()
1514 * @see eina_value_array_get()
1515 * @see eina_value_array_vset()
1516 * @see eina_value_array_insert()
1517 * @see eina_value_array_vinsert()
1518 * @see eina_value_array_pinsert()
1519 * @see eina_value_array_append()
1520 * @see eina_value_array_vappend()
1521 * @see eina_value_array_pappend()
1525 static inline Eina_Bool eina_value_array_pset(Eina_Value *value,
1526 unsigned int position,
1527 const void *ptr) EINA_ARG_NONNULL(1, 3);
1530 * @brief Retrieve a generic value into a pointer from an array member.
1531 * @param value source value object
1532 * @param position index of the member
1533 * @param ptr pointer to receive the contents.
1534 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1536 * The value is returned in pointer contents, the actual value is
1537 * type-dependent, but usually it will be what is stored inside the
1538 * object. There shouldn't be any memory allocation, thus the contents
1539 * should @b not be freed.
1541 * The pointer type is dependent on chosen value type. The list for
1544 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1545 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1546 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1547 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1548 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1549 * @li EINA_VALUE_TYPE_CHAR: char*
1550 * @li EINA_VALUE_TYPE_SHORT: short*
1551 * @li EINA_VALUE_TYPE_INT: int*
1552 * @li EINA_VALUE_TYPE_LONG: long*
1553 * @li EINA_VALUE_TYPE_INT64: int64_t*
1554 * @li EINA_VALUE_TYPE_FLOAT: float*
1555 * @li EINA_VALUE_TYPE_DOUBLE: double*
1556 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1557 * @li EINA_VALUE_TYPE_STRING: const char **
1558 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1559 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1560 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1561 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1562 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1563 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1566 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1569 * eina_value_array_append(value, 1234);
1570 * eina_value_array_pget(value, 0, &x);
1571 * eina_value_free(value);
1574 * @see eina_value_array_set()
1575 * @see eina_value_array_vset()
1576 * @see eina_value_array_pset()
1580 static inline Eina_Bool eina_value_array_pget(const Eina_Value *value,
1581 unsigned int position,
1582 void *ptr) EINA_ARG_NONNULL(1, 3);
1585 * @brief Insert a generic value to an array member position from a pointer.
1586 * @param value source value object
1587 * @param position index of the member
1588 * @param ptr pointer to specify the contents.
1589 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1591 * The pointer type is dependent on chosen value type. The list for
1594 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1595 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1596 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1597 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1598 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1599 * @li EINA_VALUE_TYPE_CHAR: char*
1600 * @li EINA_VALUE_TYPE_SHORT: short*
1601 * @li EINA_VALUE_TYPE_INT: int*
1602 * @li EINA_VALUE_TYPE_LONG: long*
1603 * @li EINA_VALUE_TYPE_INT64: int64_t*
1604 * @li EINA_VALUE_TYPE_FLOAT: float*
1605 * @li EINA_VALUE_TYPE_DOUBLE: double*
1606 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1607 * @li EINA_VALUE_TYPE_STRING: const char **
1608 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1609 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1610 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1611 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1612 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1613 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1615 * @note the pointer contents are written using the size defined by
1616 * type. It can be larger than void* or uint64_t.
1619 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1622 * eina_value_array_pinsert(value, 0, &x);
1623 * eina_value_array_pget(value, 0, &x);
1624 * eina_value_free(value);
1627 * @see eina_value_array_set()
1628 * @see eina_value_array_get()
1629 * @see eina_value_array_vset()
1630 * @see eina_value_array_insert()
1631 * @see eina_value_array_vinsert()
1632 * @see eina_value_array_pinsert()
1633 * @see eina_value_array_append()
1634 * @see eina_value_array_vappend()
1635 * @see eina_value_array_pappend()
1639 static inline Eina_Bool eina_value_array_pinsert(Eina_Value *value,
1640 unsigned int position,
1641 const void *ptr) EINA_ARG_NONNULL(1);
1644 * @brief Append a generic value to an array from a pointer.
1645 * @param value source value object
1646 * @param ptr pointer to specify the contents.
1647 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1649 * The pointer type is dependent on chosen value type. The list for
1652 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1653 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1654 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1655 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1656 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1657 * @li EINA_VALUE_TYPE_CHAR: char*
1658 * @li EINA_VALUE_TYPE_SHORT: short*
1659 * @li EINA_VALUE_TYPE_INT: int*
1660 * @li EINA_VALUE_TYPE_LONG: long*
1661 * @li EINA_VALUE_TYPE_INT64: int64_t*
1662 * @li EINA_VALUE_TYPE_FLOAT: float*
1663 * @li EINA_VALUE_TYPE_DOUBLE: double*
1664 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1665 * @li EINA_VALUE_TYPE_STRING: const char **
1666 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1667 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1668 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1669 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1670 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1671 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1673 * @note the pointer contents are written using the size defined by
1674 * type. It can be larger than void* or uint64_t.
1677 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1680 * eina_value_array_pappend(value, &x);
1681 * eina_value_array_pget(value, 0, &x);
1682 * eina_value_free(value);
1685 * @see eina_value_array_set()
1686 * @see eina_value_array_get()
1687 * @see eina_value_array_vset()
1688 * @see eina_value_array_insert()
1689 * @see eina_value_array_vinsert()
1690 * @see eina_value_array_pinsert()
1691 * @see eina_value_array_append()
1692 * @see eina_value_array_vappend()
1693 * @see eina_value_array_pappend()
1697 static inline Eina_Bool eina_value_array_pappend(Eina_Value *value,
1698 const void *ptr) EINA_ARG_NONNULL(1);
1701 * @brief Retrieves a value from the array as an Eina_Value copy.
1702 * @param src source value object
1703 * @param position index of the member
1704 * @param dst where to return the array member
1705 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1707 * The argument @a dst is considered uninitialized and it's setup to
1708 * the type of the member.
1712 static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src,
1713 unsigned int position,
1714 Eina_Value *dst) EINA_ARG_NONNULL(1, 3);
1722 * @defgroup Eina_Value_List_Group Generic Value List management
1729 * @typedef Eina_Value_List
1730 * Value type for #EINA_VALUE_TYPE_LIST.
1732 * @see #_Eina_Value_List explains fields.
1735 typedef struct _Eina_Value_List Eina_Value_List;
1738 * @struct _Eina_Value_List
1739 * Used to store the list and its subtype.
1742 struct _Eina_Value_List
1744 const Eina_Value_Type *subtype; /**< how to allocate and access items */
1745 Eina_List *list; /**< the list that holds data, members are of subtype->value_size bytes. */
1749 * @brief Create generic value storage of type list.
1750 * @param subtype how to manage this list members.
1751 * @return The new value or @c NULL on failure.
1753 * Create a new generic value storage of type list. The members are
1754 * managed using the description specified by @a subtype.
1756 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY
1757 * or #EINA_ERROR_VALUE_FAILED is set.
1759 * @note this creates from mempool and then uses
1760 * eina_value_list_setup().
1762 * @see eina_value_free()
1763 * @see eina_value_list_setup()
1767 EAPI Eina_Value *eina_value_list_new(const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1);
1770 * @brief Initialize generic value storage of type list.
1771 * @param value value object
1772 * @param subtype how to manage this list members.
1773 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1775 * Initializes new generic value storage of type list with the given
1778 * This is the same as calling eina_value_set()
1779 * with #EINA_VALUE_TYPE_LIST followed by eina_value_pset() with
1780 * the #Eina_Value_List description configured.
1782 * @note Existing contents are ignored! If the value was previously used, then
1783 * use eina_value_flush() first.
1785 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
1786 * or #EINA_ERROR_VALUE_FAILED is set.
1788 * @see eina_value_flush()
1792 static inline Eina_Bool eina_value_list_setup(Eina_Value *value,
1793 const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1, 2);
1796 * @brief Query number of elements in value of list type.
1797 * @param value value object.
1798 * @return number of child elements.
1801 static inline unsigned int eina_value_list_count(const Eina_Value *value);
1804 * @brief Remove element at given position in value of list type.
1805 * @param value value object.
1806 * @param position index of the member
1807 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1810 static inline Eina_Bool eina_value_list_remove(Eina_Value *value,
1811 unsigned int position) EINA_ARG_NONNULL(1);
1814 * @brief Set the generic value in an list member.
1815 * @param value source value object
1816 * @param position index of the member
1817 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1819 * The variable argument is dependent on chosen subtype. The list for
1822 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1823 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1824 * @li EINA_VALUE_TYPE_UINT: unsigned int
1825 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1826 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1827 * @li EINA_VALUE_TYPE_CHAR: char
1828 * @li EINA_VALUE_TYPE_SHORT: short
1829 * @li EINA_VALUE_TYPE_INT: int
1830 * @li EINA_VALUE_TYPE_LONG: long
1831 * @li EINA_VALUE_TYPE_INT64: int64_t
1832 * @li EINA_VALUE_TYPE_FLOAT: float
1833 * @li EINA_VALUE_TYPE_DOUBLE: double
1834 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1835 * @li EINA_VALUE_TYPE_STRING: const char *
1836 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1837 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1838 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1839 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1840 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1843 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1846 * eina_value_list_append(value, 1234);
1847 * eina_value_list_set(value, 0, 5678);
1848 * eina_value_list_get(value, 0, &x);
1849 * eina_value_free(value);
1852 * @see eina_value_list_get()
1853 * @see eina_value_list_vset()
1854 * @see eina_value_list_pset()
1855 * @see eina_value_list_insert()
1856 * @see eina_value_list_vinsert()
1857 * @see eina_value_list_pinsert()
1858 * @see eina_value_list_append()
1859 * @see eina_value_list_vappend()
1860 * @see eina_value_list_pappend()
1864 static inline Eina_Bool eina_value_list_set(Eina_Value *value,
1865 unsigned int position,
1866 ...) EINA_ARG_NONNULL(1);
1869 * @brief Get the generic value from an list member.
1870 * @param value source value object
1871 * @param position index of the member
1872 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1874 * The value is returned in the variable argument parameter, the
1875 * actual value is type-dependent, but usually it will be what is
1876 * stored inside the object. There shouldn't be any memory allocation,
1877 * thus the contents should @b not be freed.
1879 * The variable argument is dependent on chosen subtype. The list for
1882 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1883 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1884 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1885 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1886 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1887 * @li EINA_VALUE_TYPE_CHAR: char*
1888 * @li EINA_VALUE_TYPE_SHORT: short*
1889 * @li EINA_VALUE_TYPE_INT: int*
1890 * @li EINA_VALUE_TYPE_LONG: long*
1891 * @li EINA_VALUE_TYPE_INT64: int64_t*
1892 * @li EINA_VALUE_TYPE_FLOAT: float*
1893 * @li EINA_VALUE_TYPE_DOUBLE: double*
1894 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1895 * @li EINA_VALUE_TYPE_STRING: const char **
1896 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1897 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1898 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1899 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1900 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1903 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1906 * eina_value_list_append(value, 1234);
1907 * eina_value_list_get(value, 0, &x);
1908 * eina_value_free(value);
1911 * @see eina_value_list_set()
1912 * @see eina_value_list_vset()
1913 * @see eina_value_list_pset()
1917 static inline Eina_Bool eina_value_list_get(const Eina_Value *value,
1918 unsigned int position,
1919 ...) EINA_ARG_NONNULL(1);
1922 * @brief Insert the generic value in an list member position.
1923 * @param value source value object
1924 * @param position index of the member
1925 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1927 * The variable argument is dependent on chosen subtype. The list for
1930 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1931 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1932 * @li EINA_VALUE_TYPE_UINT: unsigned int
1933 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1934 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1935 * @li EINA_VALUE_TYPE_CHAR: char
1936 * @li EINA_VALUE_TYPE_SHORT: short
1937 * @li EINA_VALUE_TYPE_INT: int
1938 * @li EINA_VALUE_TYPE_LONG: long
1939 * @li EINA_VALUE_TYPE_INT64: int64_t
1940 * @li EINA_VALUE_TYPE_FLOAT: float
1941 * @li EINA_VALUE_TYPE_DOUBLE: double
1942 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1943 * @li EINA_VALUE_TYPE_STRING: const char *
1944 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1945 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1946 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1947 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1948 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1951 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1954 * eina_value_list_insert(value, 0, 1234);
1955 * eina_value_list_get(value, 0, &x);
1956 * eina_value_free(value);
1959 * @see eina_value_list_set()
1960 * @see eina_value_list_get()
1961 * @see eina_value_list_vset()
1962 * @see eina_value_list_pset()
1963 * @see eina_value_list_vinsert()
1964 * @see eina_value_list_pinsert()
1965 * @see eina_value_list_append()
1966 * @see eina_value_list_vappend()
1967 * @see eina_value_list_pappend()
1971 static inline Eina_Bool eina_value_list_insert(Eina_Value *value,
1972 unsigned int position,
1973 ...) EINA_ARG_NONNULL(1);
1977 * @brief Append the generic value in an list.
1978 * @param value source value object
1979 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1981 * The variable argument is dependent on chosen subtype. The list for
1984 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1985 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1986 * @li EINA_VALUE_TYPE_UINT: unsigned int
1987 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1988 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1989 * @li EINA_VALUE_TYPE_CHAR: char
1990 * @li EINA_VALUE_TYPE_SHORT: short
1991 * @li EINA_VALUE_TYPE_INT: int
1992 * @li EINA_VALUE_TYPE_LONG: long
1993 * @li EINA_VALUE_TYPE_INT64: int64_t
1994 * @li EINA_VALUE_TYPE_FLOAT: float
1995 * @li EINA_VALUE_TYPE_DOUBLE: double
1996 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1997 * @li EINA_VALUE_TYPE_STRING: const char *
1998 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1999 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
2000 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
2001 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
2002 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
2005 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2008 * eina_value_list_append(value, 1234);
2009 * eina_value_list_get(value, 0, &x);
2010 * eina_value_free(value);
2013 * @see eina_value_list_set()
2014 * @see eina_value_list_get()
2015 * @see eina_value_list_vset()
2016 * @see eina_value_list_pset()
2017 * @see eina_value_list_vinsert()
2018 * @see eina_value_list_pinsert()
2019 * @see eina_value_list_append()
2020 * @see eina_value_list_vappend()
2021 * @see eina_value_list_pappend()
2025 static inline Eina_Bool eina_value_list_append(Eina_Value *value,
2026 ...) EINA_ARG_NONNULL(1);
2029 * @brief Set the generic value in an list member.
2030 * @param value source value object
2031 * @param position index of the member
2032 * @param args variable argument
2033 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2034 * @see eina_value_list_set()
2035 * @see eina_value_list_get()
2036 * @see eina_value_list_pset()
2037 * @see eina_value_list_insert()
2038 * @see eina_value_list_vinsert()
2039 * @see eina_value_list_pinsert()
2040 * @see eina_value_list_append()
2041 * @see eina_value_list_vappend()
2042 * @see eina_value_list_pappend()
2046 static inline Eina_Bool eina_value_list_vset(Eina_Value *value,
2047 unsigned int position,
2048 va_list args) EINA_ARG_NONNULL(1);
2051 * @brief Get the generic value from an list member.
2052 * @param value source value object
2053 * @param position index of the member
2054 * @param args variable argument
2055 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2057 * The value is returned in the variable argument parameter, the
2058 * actual value is type-dependent, but usually it will be what is
2059 * stored inside the object. There shouldn't be any memory allocation,
2060 * thus the contents should @b not be freed.
2062 * @see eina_value_list_vset()
2063 * @see eina_value_list_get()
2064 * @see eina_value_list_pget()
2068 static inline Eina_Bool eina_value_list_vget(const Eina_Value *value,
2069 unsigned int position,
2070 va_list args) EINA_ARG_NONNULL(1);
2072 * @brief Insert the generic value in an list member position.
2073 * @param value source value object
2074 * @param position index of the member
2075 * @param args variable argument
2076 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2077 * @see eina_value_list_set()
2078 * @see eina_value_list_get()
2079 * @see eina_value_list_vset()
2080 * @see eina_value_list_pset()
2081 * @see eina_value_list_insert()
2082 * @see eina_value_list_pinsert()
2083 * @see eina_value_list_append()
2084 * @see eina_value_list_vappend()
2085 * @see eina_value_list_pappend()
2089 static inline Eina_Bool eina_value_list_vinsert(Eina_Value *value,
2090 unsigned int position,
2091 va_list args) EINA_ARG_NONNULL(1);
2094 * @brief Append the generic value in an list.
2095 * @param value source value object
2096 * @param args variable argument
2097 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2098 * @see eina_value_list_set()
2099 * @see eina_value_list_get()
2100 * @see eina_value_list_vget()
2101 * @see eina_value_list_pset()
2102 * @see eina_value_list_insert()
2103 * @see eina_value_list_vinsert()
2104 * @see eina_value_list_pinsert()
2105 * @see eina_value_list_append()
2106 * @see eina_value_list_pappend()
2110 static inline Eina_Bool eina_value_list_vappend(Eina_Value *value,
2111 va_list args) EINA_ARG_NONNULL(1);
2115 * @brief Set the generic value in an list member from pointer.
2116 * @param value source value object
2117 * @param position index of the member
2118 * @param ptr pointer to specify the contents.
2119 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2121 * The pointer type is dependent on chosen value type. The list for
2124 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2125 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2126 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2127 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2128 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2129 * @li EINA_VALUE_TYPE_CHAR: char*
2130 * @li EINA_VALUE_TYPE_SHORT: short*
2131 * @li EINA_VALUE_TYPE_INT: int*
2132 * @li EINA_VALUE_TYPE_LONG: long*
2133 * @li EINA_VALUE_TYPE_INT64: int64_t*
2134 * @li EINA_VALUE_TYPE_FLOAT: float*
2135 * @li EINA_VALUE_TYPE_DOUBLE: double*
2136 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2137 * @li EINA_VALUE_TYPE_STRING: const char **
2138 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2139 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2140 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2141 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2142 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2144 * @note the pointer contents are written using the size defined by
2145 * type. It can be larger than void* or uint64_t.
2148 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2151 * eina_value_list_append(value, 1234);
2152 * eina_value_list_pset(value, 0, &x);
2153 * eina_value_list_pget(value, 0, &x);
2154 * eina_value_free(value);
2157 * @see eina_value_list_set()
2158 * @see eina_value_list_get()
2159 * @see eina_value_list_vset()
2160 * @see eina_value_list_insert()
2161 * @see eina_value_list_vinsert()
2162 * @see eina_value_list_pinsert()
2163 * @see eina_value_list_append()
2164 * @see eina_value_list_vappend()
2165 * @see eina_value_list_pappend()
2169 static inline Eina_Bool eina_value_list_pset(Eina_Value *value,
2170 unsigned int position,
2171 const void *ptr) EINA_ARG_NONNULL(1, 3);
2174 * @brief Get the generic value to pointer from an list member.
2175 * @param value source value object
2176 * @param position index of the member
2177 * @param ptr pointer to receive the contents.
2178 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2180 * The value is returned in pointer contents, the actual value is
2181 * type-dependent, but usually it will be what is stored inside the
2182 * object. There shouldn't be any memory allocation, thus the contents
2183 * should @b not be freed.
2185 * The pointer type is dependent on chosen value type. The list for
2188 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2189 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2190 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2191 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2192 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2193 * @li EINA_VALUE_TYPE_CHAR: char*
2194 * @li EINA_VALUE_TYPE_SHORT: short*
2195 * @li EINA_VALUE_TYPE_INT: int*
2196 * @li EINA_VALUE_TYPE_LONG: long*
2197 * @li EINA_VALUE_TYPE_INT64: int64_t*
2198 * @li EINA_VALUE_TYPE_FLOAT: float*
2199 * @li EINA_VALUE_TYPE_DOUBLE: double*
2200 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2201 * @li EINA_VALUE_TYPE_STRING: const char **
2202 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2203 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2204 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2205 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2206 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2209 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2212 * eina_value_list_append(value, 1234);
2213 * eina_value_list_pget(value, 0, &x);
2214 * eina_value_free(value);
2217 * @see eina_value_list_set()
2218 * @see eina_value_list_vset()
2219 * @see eina_value_list_pset()
2223 static inline Eina_Bool eina_value_list_pget(const Eina_Value *value,
2224 unsigned int position,
2225 void *ptr) EINA_ARG_NONNULL(1, 3);
2228 * @brief Insert the generic value in an list member position from pointer.
2229 * @param value source value object
2230 * @param position index of the member
2231 * @param ptr pointer to specify the contents.
2232 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2234 * The pointer type is dependent on chosen value type. The list for
2237 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2238 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2239 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2240 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2241 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2242 * @li EINA_VALUE_TYPE_CHAR: char*
2243 * @li EINA_VALUE_TYPE_SHORT: short*
2244 * @li EINA_VALUE_TYPE_INT: int*
2245 * @li EINA_VALUE_TYPE_LONG: long*
2246 * @li EINA_VALUE_TYPE_INT64: int64_t*
2247 * @li EINA_VALUE_TYPE_FLOAT: float*
2248 * @li EINA_VALUE_TYPE_DOUBLE: double*
2249 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2250 * @li EINA_VALUE_TYPE_STRING: const char **
2251 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2252 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2253 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2254 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2255 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2257 * @note the pointer contents are written using the size defined by
2258 * type. It can be larger than void* or uint64_t.
2261 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2264 * eina_value_list_pinsert(value, 0, &x);
2265 * eina_value_list_pget(value, 0, &x);
2266 * eina_value_free(value);
2269 * @see eina_value_list_set()
2270 * @see eina_value_list_get()
2271 * @see eina_value_list_vset()
2272 * @see eina_value_list_insert()
2273 * @see eina_value_list_vinsert()
2274 * @see eina_value_list_pinsert()
2275 * @see eina_value_list_append()
2276 * @see eina_value_list_vappend()
2277 * @see eina_value_list_pappend()
2281 static inline Eina_Bool eina_value_list_pinsert(Eina_Value *value,
2282 unsigned int position,
2283 const void *ptr) EINA_ARG_NONNULL(1);
2286 * @brief Append the generic value in an list from pointer.
2287 * @param value source value object
2288 * @param ptr pointer to specify the contents.
2289 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2291 * The pointer type is dependent on chosen value type. The list for
2294 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2295 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2296 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2297 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2298 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2299 * @li EINA_VALUE_TYPE_CHAR: char*
2300 * @li EINA_VALUE_TYPE_SHORT: short*
2301 * @li EINA_VALUE_TYPE_INT: int*
2302 * @li EINA_VALUE_TYPE_LONG: long*
2303 * @li EINA_VALUE_TYPE_INT64: int64_t*
2304 * @li EINA_VALUE_TYPE_FLOAT: float*
2305 * @li EINA_VALUE_TYPE_DOUBLE: double*
2306 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2307 * @li EINA_VALUE_TYPE_STRING: const char **
2308 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2309 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2310 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2311 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2312 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2314 * @note the pointer contents are written using the size defined by
2315 * type. It can be larger than void* or uint64_t.
2318 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2321 * eina_value_list_pappend(value, &x);
2322 * eina_value_list_pget(value, 0, &x);
2323 * eina_value_free(value);
2326 * @see eina_value_list_set()
2327 * @see eina_value_list_get()
2328 * @see eina_value_list_vset()
2329 * @see eina_value_list_insert()
2330 * @see eina_value_list_vinsert()
2331 * @see eina_value_list_pinsert()
2332 * @see eina_value_list_append()
2333 * @see eina_value_list_vappend()
2334 * @see eina_value_list_pappend()
2338 static inline Eina_Bool eina_value_list_pappend(Eina_Value *value,
2339 const void *ptr) EINA_ARG_NONNULL(1);
2346 * @defgroup Eina_Value_Hash_Group Generic Value Hash management
2352 * @typedef Eina_Value_Hash
2353 * Value type for #EINA_VALUE_TYPE_HASH.
2355 * @see #_Eina_Value_Hash explains fields.
2358 typedef struct _Eina_Value_Hash Eina_Value_Hash;
2361 * @struct _Eina_Value_Hash
2362 * Used to store the hash and its subtype.
2365 struct _Eina_Value_Hash
2367 const Eina_Value_Type *subtype; /**< how to allocate and access items */
2368 unsigned int buckets_power_size; /**< how to allocate hash buckets, if zero a sane default is chosen. */
2369 Eina_Hash *hash; /**< the hash that holds data, members are of subtype->value_size bytes. */
2373 * @brief Create generic value storage of type hash.
2374 * @param subtype how to manage this hash members.
2375 * @param buckets_power_size how to allocate hash buckets (2 ^
2376 * buckets_power_size), if zero then a sane value is chosen.
2377 * @return The new value or @c NULL on failure.
2379 * Create a new generic value storage of type hash. The members are
2380 * managed using the description specified by @a subtype.
2382 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY
2383 * or #EINA_ERROR_VALUE_FAILED is set.
2385 * @note this creates from mempool and then uses
2386 * eina_value_hash_setup().
2388 * @see eina_value_free()
2389 * @see eina_value_hash_setup()
2393 EAPI Eina_Value *eina_value_hash_new(const Eina_Value_Type *subtype, unsigned int buckets_power_size) EINA_ARG_NONNULL(1);
2396 * @brief Initialize generic value storage of type hash.
2397 * @param value value object
2398 * @param subtype how to manage this hash members.
2399 * @param buckets_power_size how to allocate hash buckets (2 ^
2400 * buckets_power_size), if zero then a sane value is chosen.
2401 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2403 * Initializes new generic value storage of type hash with the given
2406 * This is the same as calling eina_value_set()
2407 * with #EINA_VALUE_TYPE_HASH followed by eina_value_pset() with
2408 * the #Eina_Value_Hash description configured.
2410 * @note Existing contents are ignored! If the value was previously used, then
2411 * use eina_value_flush() first.
2413 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
2414 * or #EINA_ERROR_VALUE_FAILED is set.
2416 * @see eina_value_flush()
2420 static inline Eina_Bool eina_value_hash_setup(Eina_Value *value,
2421 const Eina_Value_Type *subtype,
2422 unsigned int buckets_power_size) EINA_ARG_NONNULL(1, 2);
2425 * @brief Query number of elements in value of hash type.
2426 * @param value value object.
2427 * @return number of child elements.
2430 static inline unsigned int eina_value_hash_population(const Eina_Value *value);
2433 * @brief Remove element at given position in value of hash type.
2434 * @param value value object.
2435 * @param key key to find the member
2436 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2439 static inline Eina_Bool eina_value_hash_del(Eina_Value *value,
2440 const char *key) EINA_ARG_NONNULL(1);
2443 * @brief Set the generic value in an hash member.
2444 * @param value source value object
2445 * @param key key to find the member
2446 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2448 * The variable argument is dependent on chosen subtype. The list for
2451 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
2452 * @li EINA_VALUE_TYPE_USHORT: unsigned short
2453 * @li EINA_VALUE_TYPE_UINT: unsigned int
2454 * @li EINA_VALUE_TYPE_ULONG: unsigned long
2455 * @li EINA_VALUE_TYPE_UINT64: uint64_t
2456 * @li EINA_VALUE_TYPE_CHAR: char
2457 * @li EINA_VALUE_TYPE_SHORT: short
2458 * @li EINA_VALUE_TYPE_INT: int
2459 * @li EINA_VALUE_TYPE_LONG: long
2460 * @li EINA_VALUE_TYPE_INT64: int64_t
2461 * @li EINA_VALUE_TYPE_FLOAT: float
2462 * @li EINA_VALUE_TYPE_DOUBLE: double
2463 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
2464 * @li EINA_VALUE_TYPE_STRING: const char *
2465 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
2466 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2467 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2468 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2471 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2474 * eina_value_hash_set(value, "abc", 5678);
2475 * eina_value_hash_get(value, "abc", &x);
2476 * eina_value_free(value);
2479 * @see eina_value_hash_get()
2480 * @see eina_value_hash_vset()
2481 * @see eina_value_hash_pset()
2482 * @see eina_value_hash_del()
2486 static inline Eina_Bool eina_value_hash_set(Eina_Value *value,
2488 ...) EINA_ARG_NONNULL(1);
2491 * @brief Get the generic value from an hash member.
2492 * @param value source value object
2493 * @param key key to find the member
2494 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2496 * The value is returned in the variable argument parameter, the
2497 * actual value is type-dependent, but usually it will be what is
2498 * stored inside the object. There shouldn't be any memory allocation,
2499 * thus the contents should @b not be freed.
2501 * The variable argument is dependent on chosen subtype. The list for
2504 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2505 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2506 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2507 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2508 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2509 * @li EINA_VALUE_TYPE_CHAR: char*
2510 * @li EINA_VALUE_TYPE_SHORT: short*
2511 * @li EINA_VALUE_TYPE_INT: int*
2512 * @li EINA_VALUE_TYPE_LONG: long*
2513 * @li EINA_VALUE_TYPE_INT64: int64_t*
2514 * @li EINA_VALUE_TYPE_FLOAT: float*
2515 * @li EINA_VALUE_TYPE_DOUBLE: double*
2516 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2517 * @li EINA_VALUE_TYPE_STRING: const char **
2518 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2519 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2520 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2521 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2524 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2527 * eina_value_hash_set(value, "abc", 1234);
2528 * eina_value_hash_get(value, "abc", &x);
2529 * eina_value_free(value);
2532 * @see eina_value_hash_set()
2533 * @see eina_value_hash_vset()
2534 * @see eina_value_hash_pset()
2538 static inline Eina_Bool eina_value_hash_get(const Eina_Value *value,
2540 ...) EINA_ARG_NONNULL(1);
2543 * @brief Set the generic value in an hash member.
2544 * @param value source value object
2545 * @param key key to find the member
2546 * @param args variable argument
2547 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2548 * @see eina_value_hash_set()
2549 * @see eina_value_hash_get()
2550 * @see eina_value_hash_pset()
2554 static inline Eina_Bool eina_value_hash_vset(Eina_Value *value,
2556 va_list args) EINA_ARG_NONNULL(1);
2559 * @brief Get the generic value from an hash member.
2560 * @param value source value object
2561 * @param key key to find the member
2562 * @param args variable argument
2563 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2565 * The value is returned in the variable argument parameter, the
2566 * actual value is type-dependent, but usually it will be what is
2567 * stored inside the object. There shouldn't be any memory allocation,
2568 * thus the contents should @b not be freed.
2570 * @see eina_value_hash_vset()
2571 * @see eina_value_hash_get()
2572 * @see eina_value_hash_pget()
2576 static inline Eina_Bool eina_value_hash_vget(const Eina_Value *value,
2578 va_list args) EINA_ARG_NONNULL(1);
2581 * @brief Set the generic value in an hash member from pointer.
2582 * @param value source value object
2583 * @param key key to find the member
2584 * @param ptr pointer to specify the contents.
2585 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2587 * The pointer type is dependent on chosen value type. The list for
2590 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2591 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2592 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2593 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2594 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2595 * @li EINA_VALUE_TYPE_CHAR: char*
2596 * @li EINA_VALUE_TYPE_SHORT: short*
2597 * @li EINA_VALUE_TYPE_INT: int*
2598 * @li EINA_VALUE_TYPE_LONG: long*
2599 * @li EINA_VALUE_TYPE_INT64: int64_t*
2600 * @li EINA_VALUE_TYPE_FLOAT: float*
2601 * @li EINA_VALUE_TYPE_DOUBLE: double*
2602 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2603 * @li EINA_VALUE_TYPE_STRING: const char **
2604 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2605 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2606 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2607 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2609 * @note the pointer contents are written using the size defined by
2610 * type. It can be larger than void* or uint64_t.
2613 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2616 * eina_value_hash_pset(value, "abc", &x);
2617 * eina_value_hash_pget(value, "abc", &x);
2618 * eina_value_free(value);
2621 * @see eina_value_hash_set()
2622 * @see eina_value_hash_get()
2623 * @see eina_value_hash_vset()
2627 static inline Eina_Bool eina_value_hash_pset(Eina_Value *value,
2629 const void *ptr) EINA_ARG_NONNULL(1, 3);
2632 * @brief Get the generic value to pointer from an hash member.
2633 * @param value source value object
2634 * @param key key to find the member
2635 * @param ptr pointer to receive the contents.
2636 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2638 * The value is returned in pointer contents, the actual value is
2639 * type-dependent, but usually it will be what is stored inside the
2640 * object. There shouldn't be any memory allocation, thus the contents
2641 * should @b not be freed.
2643 * The pointer type is dependent on chosen value type. The list for
2646 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2647 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2648 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2649 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2650 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2651 * @li EINA_VALUE_TYPE_CHAR: char*
2652 * @li EINA_VALUE_TYPE_SHORT: short*
2653 * @li EINA_VALUE_TYPE_INT: int*
2654 * @li EINA_VALUE_TYPE_LONG: long*
2655 * @li EINA_VALUE_TYPE_INT64: int64_t*
2656 * @li EINA_VALUE_TYPE_FLOAT: float*
2657 * @li EINA_VALUE_TYPE_DOUBLE: double*
2658 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2659 * @li EINA_VALUE_TYPE_STRING: const char **
2660 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2661 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2662 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2663 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2666 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2669 * eina_value_hash_set(value, "abc", 1234);
2670 * eina_value_hash_pget(value, "abc", &x);
2671 * eina_value_free(value);
2674 * @see eina_value_hash_set()
2675 * @see eina_value_hash_vset()
2676 * @see eina_value_hash_pset()
2680 static inline Eina_Bool eina_value_hash_pget(const Eina_Value *value,
2682 void *ptr) EINA_ARG_NONNULL(1, 3);
2689 * @defgroup Eina_Value_Blob_Group Generic Value Blob management
2695 * @typedef Eina_Value_Blob_Operations
2696 * How to manage blob. Any @c NULL callback is ignored.
2697 * @see #_Eina_Value_Blob_Operations explains fields.
2700 typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations;
2703 * @def EINA_VALUE_BLOB_OPERATIONS_VERSION
2704 * Current API version, used to validate #_Eina_Value_Blob_Operations.
2706 #define EINA_VALUE_BLOB_OPERATIONS_VERSION (1)
2709 * @struct _Eina_Value_Blob_Operations
2710 * How to manage blob. Any @c NULL callback is ignored.
2713 struct _Eina_Value_Blob_Operations
2715 unsigned int version; /**< must be #EINA_VALUE_BLOB_OPERATIONS_VERSION */
2716 void (*free)(const Eina_Value_Blob_Operations *ops, void *memory, size_t size);
2717 void *(*copy)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size);
2718 int (*compare)(const Eina_Value_Blob_Operations *ops, const void *data1, size_t size_data1, const void *data2, size_t size_data2);
2719 char *(*to_string)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size);
2723 * @var EINA_VALUE_BLOB_OPERATIONS_MALLOC
2725 * Assumes @c memory was create with malloc() and applies free() to it
2726 * during flush (Eina_Value_Blob_Operations::free). Copy is done with
2729 * No compare or to_string are provided, defaults will be used.
2731 EAPI extern const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC;
2734 * @typedef Eina_Value_Blob
2735 * Value type for #EINA_VALUE_TYPE_BLOB.
2737 * @see #_Eina_Value_Blob explains fields.
2740 typedef struct _Eina_Value_Blob Eina_Value_Blob;
2743 * @struct _Eina_Value_Blob
2744 * Used to store the blob information and management operations.
2747 struct _Eina_Value_Blob
2749 const Eina_Value_Blob_Operations *ops; /**< if @c NULL, nothing is freed, copy will just copy the memory pointer, not its value. */
2759 * @defgroup Eina_Value_Struct_Group Generic Value Struct management
2765 * @typedef Eina_Value_Struct_Operations
2766 * How to manage struct. Any @c NULL callback is ignored.
2768 * A structure can specify alternative methods to allocate, free and
2769 * copy itself. See structure definition for all methods.
2771 * @see #_Eina_Value_Struct_Operations explains fields.
2774 typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations;
2777 * @typedef Eina_Value_Struct_Member
2778 * Describes a single member of struct.
2780 * The member holds a name, type and its byte offset within the struct
2781 * memory. Most Eina_Value_Struct functions takes the member name as
2782 * parameter, as in eina_value_struct_set().
2784 * @see #_Eina_Value_Struct_Member explains fields.
2787 typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member;
2790 * @typedef Eina_Value_Struct_Desc
2791 * Describes the struct by listing its size, members and operations.
2792 * @see #_Eina_Value_Struct_Desc explains fields.
2795 typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc;
2798 * @typedef Eina_Value_Struct
2799 * Value type for #EINA_VALUE_TYPE_STRUCT.
2801 * @see #_Eina_Value_Struct explains fields.
2804 typedef struct _Eina_Value_Struct Eina_Value_Struct;
2807 * @def EINA_VALUE_STRUCT_OPERATIONS_VERSION
2808 * Current API version, used to validate #_Eina_Value_Struct_Operations.
2810 #define EINA_VALUE_STRUCT_OPERATIONS_VERSION (1)
2813 * @struct _Eina_Value_Struct_Operations
2814 * How to manage struct. Any @c NULL callback is ignored.
2817 struct _Eina_Value_Struct_Operations
2819 unsigned int version; /**< must be #EINA_VALUE_STRUCT_OPERATIONS_VERSION */
2820 void *(*alloc)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc); /**< How to allocate struct memory to be managed by the Eina_Value */
2821 void (*free)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, void *memory); /**< How to release memory managed by the Eina_Value */
2822 void *(*copy)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *memory); /**< How to copy struct memory from an existing Eina_Value, if not provided alloc() will be used, then every member is copied using eina_value_type_copy() with member's type. */
2823 int (*compare)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *data1, const void *data2); /**< How to compare two struct memories */
2824 const Eina_Value_Struct_Member *(*find_member)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const char *name); /**< How to find description for member. For huge structures consider using binary search, stringshared, hash or gperf. The default function does linear search using strcmp(). */
2828 * @var EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH
2830 * Assumes @c members is sorted by name and applies binary search for
2833 * Ideally the @c member_count field is set to speed it up.
2835 * No other methods are set (alloc, free, copy, compare), then it uses
2836 * the default operations.
2838 EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
2841 * @var EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE
2843 * Assumes @c members name are stringshared and can be compared for
2844 * equality without using its contents (simple pointer comparison).
2846 * Ideally the search @c name will be stringshared as well, but it
2847 * will do a second loop with a forced stringshare if it did not find
2850 * No other methods are set (alloc, free, copy, compare), then it uses
2851 * the default operations.
2853 EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE;
2856 * @struct _Eina_Value_Struct_Member
2857 * Describes a single member of struct.
2859 * The name is used to lookup the member description. This is done as
2860 * specified as _Eina_Value_Struct_Operations::find_member(). For
2861 * structures with huge number of members, consider using a better
2862 * find_member function to quickly finding it! There are two helper
2863 * operations provided to help this: #EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH
2864 * and #EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE, both depend on properly
2865 * set #_Eina_Value_Struct_Desc and #_Eina_Value_Struct_Member.
2867 * @see #EINA_VALUE_STRUCT_MEMBER
2868 * @see #EINA_VALUE_STRUCT_MEMBER_SENTINEL
2872 struct _Eina_Value_Struct_Member
2874 const char *name; /**< member name, used in lookups such as eina_value_struct_get() */
2875 const Eina_Value_Type *type; /**< how to use this member */
2876 unsigned int offset; /**< where this member is located within the structure memory */
2880 * @def EINA_VALUE_STRUCT_DESC_VERSION
2881 * Current API version, used to validate #_Eina_Value_Struct_Desc.
2883 #define EINA_VALUE_STRUCT_DESC_VERSION (1)
2886 * @struct _Eina_Value_Struct_Desc
2887 * Describes the struct by listing its size, members and operations.
2889 * This is the root of Eina_Value knowledge about the memory it's
2890 * handling as a structure. It adds introspection, saying the byte
2891 * size of the structure, its members and how to manage such members.
2895 struct _Eina_Value_Struct_Desc
2897 unsigned int version; /**< must be #EINA_VALUE_STRUCT_DESC_VERSION */
2898 const Eina_Value_Struct_Operations *ops; /**< operations, if @c NULL defaults will be used. You may use operations to optimize member lookup using binary search or gperf hash. */
2899 const Eina_Value_Struct_Member *members; /**< array of member descriptions, if @c member_count is zero, then it must be @c NULL terminated. */
2900 unsigned int member_count; /**< if > 0, specifies number of members. If zero then @c members must be NULL terminated. */
2901 unsigned int size; /**< byte size to allocate, may be bigger than sum of members */
2905 * @def EINA_VALUE_STRUCT_MEMBER
2907 * Helper to define Eina_Value_Struct_Member fields, uses offsetof()
2908 * with type and member.
2912 #define EINA_VALUE_STRUCT_MEMBER(eina_value_type, type, member) \
2913 {#member, eina_value_type, offsetof(type, member)}
2916 * @def EINA_VALUE_STRUCT_MEMBER_SENTINEL
2918 * Helper to define Eina_Value_Struct_Member fields for sentinel (last
2919 * item), useful if you did not define @c member_count.
2923 #define EINA_VALUE_STRUCT_MEMBER_SENTINEL {NULL, NULL, 0}
2927 * @struct _Eina_Value_Struct
2928 * Used to store the memory and its description.
2931 struct _Eina_Value_Struct
2933 const Eina_Value_Struct_Desc *desc; /**< How to manage the structure */
2934 void *memory; /**< The managed structure memory */
2938 * @brief Create generic value storage of type struct.
2939 * @param desc how to manage this struct members.
2940 * @return The new value or @c NULL on failure.
2942 * Create a new generic value storage of type struct. The members are
2943 * managed using the description specified by @a desc.
2945 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY
2946 * or #EINA_ERROR_VALUE_FAILED is set.
2948 * @note this creates from mempool and then uses
2949 * eina_value_struct_setup().
2951 * @see eina_value_free()
2952 * @see eina_value_struct_setup()
2956 EAPI Eina_Value *eina_value_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1);
2959 * @brief Initialize generic value storage of type struct.
2960 * @param value value object
2961 * @param desc how to manage this struct members.
2962 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2964 * Initializes new generic value storage of type struct with the given
2967 * This is the same as calling eina_value_set()
2968 * with #EINA_VALUE_TYPE_STRUCT followed by eina_value_pset() with
2969 * the #Eina_Value_Struct description configured.
2971 * @note Existing contents are ignored! If the value was previously used, then
2972 * use eina_value_flush() first.
2974 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
2975 * or #EINA_ERROR_VALUE_FAILED is set.
2977 * @see eina_value_flush()
2981 static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
2982 const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2);
2985 * @brief Set the generic value in an struct member.
2986 * @param value source value object
2987 * @param name name to find the member
2988 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2990 * The variable argument is dependent on chosen member type. The list
2993 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
2994 * @li EINA_VALUE_TYPE_USHORT: unsigned short
2995 * @li EINA_VALUE_TYPE_UINT: unsigned int
2996 * @li EINA_VALUE_TYPE_ULONG: unsigned long
2997 * @li EINA_VALUE_TYPE_UINT64: uint64_t
2998 * @li EINA_VALUE_TYPE_CHAR: char
2999 * @li EINA_VALUE_TYPE_SHORT: short
3000 * @li EINA_VALUE_TYPE_INT: int
3001 * @li EINA_VALUE_TYPE_LONG: long
3002 * @li EINA_VALUE_TYPE_INT64: int64_t
3003 * @li EINA_VALUE_TYPE_FLOAT: float
3004 * @li EINA_VALUE_TYPE_DOUBLE: double
3005 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
3006 * @li EINA_VALUE_TYPE_STRING: const char *
3007 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
3008 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3009 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3010 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3017 * const Eina_Value_Struct_Member myst_members[] = {
3018 * {"i", EINA_VALUE_TYPE_INT, 0},
3019 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3022 * const Eina_Value_Struct_Desc myst_desc = {
3023 * EINA_VALUE_STRUCT_DESC_VERSION,
3024 * NULL, myst_members, 2, sizeof(struct myst)
3026 * Eina_Value *value = eina_value_struct_new(&my_desc);
3030 * eina_value_struct_set(value, "i", 5678);
3031 * eina_value_struct_get(value, "i", &x);
3032 * eina_value_struct_set(value, "c", 0xf);
3033 * eina_value_struct_get(value, "c", &y);
3034 * eina_value_free(value);
3037 * @see eina_value_struct_get()
3038 * @see eina_value_struct_vset()
3039 * @see eina_value_struct_pset()
3043 static inline Eina_Bool eina_value_struct_set(Eina_Value *value,
3045 ...) EINA_ARG_NONNULL(1, 2);
3048 * @brief Get the generic value from an struct member.
3049 * @param value source value object
3050 * @param name name to find the member
3051 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3053 * The value is returned in the variable argument parameter, the
3054 * actual value is type-dependent, but usually it will be what is
3055 * stored inside the object. There shouldn't be any memory allocation,
3056 * thus the contents should @b not be freed.
3058 * The variable argument is dependent on chosen member type. The list
3061 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
3062 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
3063 * @li EINA_VALUE_TYPE_UINT: unsigned int*
3064 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
3065 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
3066 * @li EINA_VALUE_TYPE_CHAR: char*
3067 * @li EINA_VALUE_TYPE_SHORT: short*
3068 * @li EINA_VALUE_TYPE_INT: int*
3069 * @li EINA_VALUE_TYPE_LONG: long*
3070 * @li EINA_VALUE_TYPE_INT64: int64_t*
3071 * @li EINA_VALUE_TYPE_FLOAT: float*
3072 * @li EINA_VALUE_TYPE_DOUBLE: double*
3073 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
3074 * @li EINA_VALUE_TYPE_STRING: const char **
3075 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
3076 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3077 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3078 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3085 * const Eina_Value_Struct_Member myst_members[] = {
3086 * {"i", EINA_VALUE_TYPE_INT, 0},
3087 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3090 * const Eina_Value_Struct_Desc myst_desc = {
3091 * EINA_VALUE_STRUCT_DESC_VERSION,
3092 * NULL, myst_members, 2, sizeof(struct myst)
3094 * Eina_Value *value = eina_value_struct_new(&my_desc);
3098 * eina_value_struct_set(value, "i", 5678);
3099 * eina_value_struct_get(value, "i", &x);
3100 * eina_value_struct_set(value, "c", 0xf);
3101 * eina_value_struct_get(value, "c", &y);
3102 * eina_value_free(value);
3105 * @see eina_value_struct_set()
3106 * @see eina_value_struct_vset()
3107 * @see eina_value_struct_pset()
3111 static inline Eina_Bool eina_value_struct_get(const Eina_Value *value,
3113 ...) EINA_ARG_NONNULL(1, 2);
3116 * @brief Set the generic value in an struct member.
3117 * @param value source value object
3118 * @param name name to find the member
3119 * @param args variable argument
3120 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3121 * @see eina_value_struct_set()
3122 * @see eina_value_struct_get()
3123 * @see eina_value_struct_pset()
3127 static inline Eina_Bool eina_value_struct_vset(Eina_Value *value,
3129 va_list args) EINA_ARG_NONNULL(1, 2);
3132 * @brief Get the generic value from an struct member.
3133 * @param value source value object
3134 * @param name name to find the member
3135 * @param args variable argument
3136 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3138 * The value is returned in the variable argument parameter, the
3139 * actual value is type-dependent, but usually it will be what is
3140 * stored inside the object. There shouldn't be any memory allocation,
3141 * thus the contents should @b not be freed.
3143 * @see eina_value_struct_vset()
3144 * @see eina_value_struct_get()
3145 * @see eina_value_struct_pget()
3149 static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value,
3151 va_list args) EINA_ARG_NONNULL(1, 2);
3154 * @brief Set the generic value in an struct member from pointer.
3155 * @param value source value object
3156 * @param name name to find the member
3157 * @param ptr pointer to specify the contents.
3158 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3160 * The pointer type is dependent on chosen value type. The list for
3163 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
3164 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
3165 * @li EINA_VALUE_TYPE_UINT: unsigned int*
3166 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
3167 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
3168 * @li EINA_VALUE_TYPE_CHAR: char*
3169 * @li EINA_VALUE_TYPE_SHORT: short*
3170 * @li EINA_VALUE_TYPE_INT: int*
3171 * @li EINA_VALUE_TYPE_LONG: long*
3172 * @li EINA_VALUE_TYPE_INT64: int64_t*
3173 * @li EINA_VALUE_TYPE_FLOAT: float*
3174 * @li EINA_VALUE_TYPE_DOUBLE: double*
3175 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
3176 * @li EINA_VALUE_TYPE_STRING: const char **
3177 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
3178 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3179 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3180 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3182 * @note the pointer contents are written using the size defined by
3183 * type. It can be larger than void* or uint64_t.
3190 * const Eina_Value_Struct_Member myst_members[] = {
3191 * {"i", EINA_VALUE_TYPE_INT, 0},
3192 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3195 * const Eina_Value_Struct_Desc myst_desc = {
3196 * EINA_VALUE_STRUCT_DESC_VERSION,
3197 * NULL, myst_members, 2, sizeof(struct myst)
3199 * Eina_Value *value = eina_value_struct_new(&my_desc);
3203 * eina_value_struct_pset(value, "i", &);
3204 * eina_value_struct_pget(value, "i", &x);
3205 * eina_value_struct_pset(value, "c", &y);
3206 * eina_value_struct_pget(value, "c", &y);
3207 * eina_value_free(value);
3210 * @see eina_value_struct_set()
3211 * @see eina_value_struct_get()
3212 * @see eina_value_struct_vset()
3216 static inline Eina_Bool eina_value_struct_pset(Eina_Value *value,
3218 const void *ptr) EINA_ARG_NONNULL(1, 2, 3);
3221 * @brief Get the generic value to pointer from an struct member.
3222 * @param value source value object
3223 * @param name name to find the member
3224 * @param ptr pointer to receive the contents.
3225 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3227 * The value is returned in pointer contents, the actual value is
3228 * type-dependent, but usually it will be what is stored inside the
3229 * object. There shouldn't be any memory allocation, thus the contents
3230 * should @b not be freed.
3232 * The pointer type is dependent on chosen value type. The list for
3235 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
3236 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
3237 * @li EINA_VALUE_TYPE_UINT: unsigned int*
3238 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
3239 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
3240 * @li EINA_VALUE_TYPE_CHAR: char*
3241 * @li EINA_VALUE_TYPE_SHORT: short*
3242 * @li EINA_VALUE_TYPE_INT: int*
3243 * @li EINA_VALUE_TYPE_LONG: long*
3244 * @li EINA_VALUE_TYPE_INT64: int64_t*
3245 * @li EINA_VALUE_TYPE_FLOAT: float*
3246 * @li EINA_VALUE_TYPE_DOUBLE: double*
3247 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
3248 * @li EINA_VALUE_TYPE_STRING: const char **
3249 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
3250 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3251 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3252 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3259 * const Eina_Value_Struct_Member myst_members[] = {
3260 * {"i", EINA_VALUE_TYPE_INT, 0},
3261 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3264 * const Eina_Value_Struct_Desc myst_desc = {
3265 * EINA_VALUE_STRUCT_DESC_VERSION,
3266 * NULL, myst_members, 2, sizeof(struct myst)
3268 * Eina_Value *value = eina_value_struct_new(&my_desc);
3272 * eina_value_struct_pset(value, "i", &);
3273 * eina_value_struct_pget(value, "i", &x);
3274 * eina_value_struct_pset(value, "c", &y);
3275 * eina_value_struct_pget(value, "c", &y);
3276 * eina_value_free(value);
3279 * @see eina_value_struct_set()
3280 * @see eina_value_struct_vset()
3281 * @see eina_value_struct_pset()
3285 static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value,
3287 void *ptr) EINA_ARG_NONNULL(1, 2, 3);
3290 * @brief Get the member as Eina_Value copy
3291 * @param src source value object
3292 * @param name name to find the member
3293 * @param dst where to return the member value.
3294 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
3296 * The argument @a dst is considered uninitialized and it's setup to
3297 * the type of the member.
3301 static inline Eina_Bool eina_value_struct_value_get(const Eina_Value *src,
3303 Eina_Value *dst) EINA_ARG_NONNULL(1, 2, 3);
3306 * @brief Set the member from Eina_Value source
3307 * @param dst destination value object
3308 * @param name name to find the member
3309 * @param src source value
3310 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
3314 static inline Eina_Bool eina_value_struct_value_set(Eina_Value *dst,
3316 const Eina_Value *src) EINA_ARG_NONNULL(1, 2, 3);
3319 * @brief Get the member as Eina_Value copy given its member description.
3320 * @param src source value object
3321 * @param member the member description to use
3322 * @param dst where to return the member value.
3323 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
3325 * The argument @a dst is considered uninitialized and it's setup to
3326 * the type of the member.
3330 static inline Eina_Bool eina_value_struct_member_value_get(const Eina_Value *src,
3331 const Eina_Value_Struct_Member *member,
3332 Eina_Value *dst) EINA_ARG_NONNULL(1, 2, 3);
3335 * @brief Set the member from Eina_Value source
3336 * @param dst destination value object
3337 * @param member the member description to use
3338 * @param src source value
3339 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
3343 static inline Eina_Bool eina_value_struct_member_value_set(Eina_Value *dst,
3344 const Eina_Value_Struct_Member *member,
3345 const Eina_Value *src) EINA_ARG_NONNULL(1, 2, 3);
3354 * @defgroup Eina_Value_Type_Group Generic Value Type management
3360 * @def EINA_VALUE_TYPE_VERSION
3361 * Current API version, used to validate type.
3363 #define EINA_VALUE_TYPE_VERSION (1)
3366 * @struct _Eina_Value_Type
3367 * API to access values.
3371 struct _Eina_Value_Type
3373 unsigned int version; /**< must be #EINA_VALUE_TYPE_VERSION */
3374 unsigned int value_size; /**< byte size of value */
3375 const char *name; /**< name for debug and introspection */
3376 Eina_Bool (*setup)(const Eina_Value_Type *type, void *mem); /**< mem will be malloc(value_size) and should be configured */
3377 Eina_Bool (*flush)(const Eina_Value_Type *type, void *mem); /**< clear any values from mem */
3378 Eina_Bool (*copy)(const Eina_Value_Type *type, const void *src, void *dst); /**< how to copy values, both memory are @c value_size */
3379 int (*compare)(const Eina_Value_Type *type, const void *a, const void *b); /**< how to compare values, both memory are @c value_size */
3380 Eina_Bool (*convert_to)(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); /**< how to convert values, both memory are @c value_size */
3381 Eina_Bool (*convert_from)(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); /**< how to convert values, both memory are @c value_size */
3382 Eina_Bool (*vset)(const Eina_Value_Type *type, void *mem, va_list args); /**< how to set memory from variable argument */
3383 Eina_Bool (*pset)(const Eina_Value_Type *type, void *mem, const void *ptr); /**< how to set memory from pointer */
3384 Eina_Bool (*pget)(const Eina_Value_Type *type, const void *mem, void *ptr); /**< how to read memory */
3388 * @brief Query type name.
3389 * @param type type reference.
3390 * @return string or @c NULL if type is invalid.
3393 EAPI const char *eina_value_type_name_get(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
3396 * @brief Check if type is valid.
3397 * @param type type reference.
3398 * @return #EINA_TRUE if valid, #EINA_FALSE otherwise.
3400 * A type is invalid if it's NULL or if version field is not the same
3401 * as runtime #EINA_VALUE_TYPE_VERSION.
3405 EAPI Eina_Bool eina_value_type_check(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
3408 * @brief Initialize memory using type descriptor.
3409 * @param type type reference.
3410 * @param mem memory to operate, must be of size @c type->value_size.
3411 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3414 static inline Eina_Bool eina_value_type_setup(const Eina_Value_Type *type, void *mem);
3417 * @brief Flush (clear) memory using type descriptor.
3418 * @param type type reference.
3419 * @param mem memory to operate, must be of size @c type->value_size.
3420 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3423 static inline Eina_Bool eina_value_type_flush(const Eina_Value_Type *type, void *mem);
3426 * @brief Copy memory using type descriptor.
3427 * @param type type reference.
3428 * @param src memory to operate, must be of size @c type->value_size.
3429 * @param dst memory to operate, must be of size @c type->value_size.
3430 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3433 static inline Eina_Bool eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst);
3436 * @brief Compare memory using type descriptor.
3437 * @param type type reference.
3438 * @param a memory to operate, must be of size @c type->value_size.
3439 * @param b memory to operate, must be of size @c type->value_size.
3440 * @return less than zero if a < b, greater than zero if a > b, zero if equal.
3443 static inline int eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b);
3446 * @brief Convert memory using type descriptor.
3447 * @param type type reference of the source.
3448 * @param convert type reference of the destination.
3449 * @param type_mem memory to operate, must be of size @c type->value_size.
3450 * @param convert_mem memory to operate, must be of size @c convert->value_size.
3451 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3454 static inline Eina_Bool eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem);
3457 * @brief Convert memory using type descriptor.
3458 * @param type type reference of the destination.
3459 * @param convert type reference of the source.
3460 * @param type_mem memory to operate, must be of size @c type->value_size.
3461 * @param convert_mem memory to operate, must be of size @c convert->value_size.
3462 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3465 static inline Eina_Bool eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem);
3468 * @brief Set memory using type descriptor and variable argument.
3469 * @param type type reference of the source.
3470 * @param mem memory to operate, must be of size @c type->value_size.
3471 * @param args input value.
3472 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3475 static inline Eina_Bool eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args);
3478 * @brief Set memory using type descriptor and pointer.
3479 * @param type type reference of the source.
3480 * @param mem memory to operate, must be of size @c type->value_size.
3481 * @param ptr pointer to input value.
3482 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3485 static inline Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr);
3488 * @brief Get memory using type descriptor.
3489 * @param type type reference of the source.
3490 * @param mem memory to operate, must be of size @c type->value_size.
3491 * @param ptr pointer to output.
3492 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3495 static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr);
3501 #include "eina_inline_value.x"