summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-09-14 11:00:34 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-09-14 11:00:34 -0700
commit112777fc7a7c7f0bbdbe21ce70d2074367710a88 (patch)
tree6d6c73130b1c4413f24fa839722fb709789e1424 /src
parentcba58203a32d4c586570cf2bb47cbcc048d803d4 (diff)
eina: add iterator macro for Eina_Value that contain an array.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_value.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib/eina/eina_value.h b/src/lib/eina/eina_value.h
index 773de02119..1b85ac7d87 100644
--- a/src/lib/eina/eina_value.h
+++ b/src/lib/eina/eina_value.h
@@ -1780,6 +1780,52 @@ static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src,
1780 Eina_Value *dst) EINA_ARG_NONNULL(1, 3); 1780 Eina_Value *dst) EINA_ARG_NONNULL(1, 3);
1781 1781
1782/** 1782/**
1783 * @def EINA_VALUE_ARRAY_FOREACH
1784 * @brief Definition for the macro to iterate over an array contained in an Eina_Value.
1785 *
1786 * @param array The list to iterate over.
1787 * @param length Contain the length of the array
1788 * @param it Contain the current position walked over
1789 * @param value Contain the value at the current position.
1790 *
1791 * This macro iterates over @p array from the first element to
1792 * the last. @p value is the data related to the current element.
1793 *
1794 * It can be used like in the following example:
1795 *
1796 * @code
1797 * Eina_Value array;
1798 * Eina_Error err;
1799 * unsigned int i, len;
1800 * Eina_Value v = EINA_VALUE_EMPTY;
1801 *
1802 * // array is already filled,
1803 * // its elements are unknown,
1804 * // EINA_VALUE_ARRAY_FOREACH will be used to check if there is no error
1805 *
1806 *
1807 * EINA_VALUE_ARRAY_FOREACH(&array, len, i, &v)
1808 * {
1809 * if (v.type == EINA_VALUE_TYPE_ERROR)
1810 * {
1811 * eina_value_get(&v, &err);
1812 * fprintf(stderr, "Something has gone wrong: %s at index: %i\n", eina_error_msg_get(err), i);
1813 * abort();
1814 * }
1815 * }
1816 * @endcode
1817 *
1818 * @warning @p array and v must be a pointer to an Eina_Value
1819 */
1820#define EINA_VALUE_ARRAY_FOREACH(Array, Length, It, Value) \
1821 for (Length = eina_value_array_count(Array), \
1822 It = 0, \
1823 eina_value_array_get(Array, It, Value); \
1824 It < Length; \
1825 It++, \
1826 eina_value_array_get(Array, It, Value))
1827
1828/**
1783 * @} 1829 * @}
1784 */ 1830 */
1785 1831