Symisc Systems

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


Star Follow @symisc

Syntax

libcox_value * libcox_array_fetch(libcox_value *pArray,unsigned int nIndex);

libcox_value * libcox_array_fetch_by_key(libcox_value *pArray,const char *zKey,int nByte);


Extract array entry using its index/key.

Description

These routines are used to extract an array entry value from a given Libcox array. 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.

If the given index/key does not refer to a valid entry then NULL is returned. Otherwise the entry value is returned on success. This value can be modified using one these interfaces and the change is immediately seen in the target array:

libcox_value_int()
libcox_value_int64()
libcox_value_bool()
libcox_value_null()
libcox_value_double()
libcox_value_string()
libcox_value_string_format()

The fetched entry value could be extracted via these interfaces:

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

Note: These routine are not thread-safe.


Parameters

pArray

Target libcox_value which must be of type array.

nIndex

Index of the target record (Zero based indexes).

zKey

A pointer to a nul terminated string holding the entry key.

nByte

zKey length.


Return value

If the given key does not refer to a valid array record or the given libcox_value is not of type array then NULL is returned. Otherwise the entry value is returned on success.


See also

libcox_array_next_elem, libcox_array_walk, libcox_array_insert.