Symisc Systems

Libcox C/C++ API Reference - Array Type Processing


Star Follow @symisc

Syntax

int libcox_array_reset(libcox_value *pArray);

libcox_value * libcox_array_next_elem(libcox_value *pArray);


Iterate over the elements of a given array.

Description

libcox_array_next_elem() return the current array entry pointed by the internal cursor and automatically advance it (i.e. the cursor) to the next element. Use the following interfaces to cast the object value returned by this interface to the desired type:

libcox_value_to_int()
libcox_value_to_bool()
libcox_value_to_int64()
libcox_value_to_double()
libcox_value_to_string()


If the array is empty or the end of the list is reached (i.e. No more entries to return) then this routine return NULL instead. libcox_array_reset() reset the internal cursor to point to the first array entry.

The libcox_value must be of type array obtained by a prior successful call to libcox_context_new_array() or passed as parameter to the foreign command.

Call libcox_value_is_array() to check if the given libcox_value is of the expected type.

Note: These routines are not thread-safe.


Parameters

pArray

libcox_value to iterate over which must be of type array.


Return value

Current array entry (libcox_value pointer) on success or NULL when no more entries.


See also

libcox_array_walk, libcox_array_insert, libcox_array_fetch.