lynx_value_iterate_value

Introduction

Iterate through lynx_value of array or map type.

Syntax

typedef void (*lynx_value_iterator_callback)(lynx_api_env env, lynx_value key,
                                             lynx_value val, void* func,
                                             void* raw_data);
lynx_api_status lynx_value_iterate_value(
    lynx_api_env env, lynx_value object, lynx_value_iterator_callback callback,
    void* func, void* raw_data);

Parameters

KeyDescription
[in] envThe environment in which lynx value runs, typically nullptr.
[in] objectlynx_value to be iterated through.
[in] callbacklynx_value_iterator_callback function pointer.
[in] funcPass through a function pointer to handle the Callback, which is not used inside the iterator function.
[in] raw_dataPass through user-defined pointer data, which is not used inside the iterator function.

Return Value

Returns lynx_api_ok if the API succeeded.

Example

If the lynx_value being iterated is an array, the Callback's key is of type lynx_value_uint32. If the lynx_value being iterated is a map, the Callback's key is of type lynx_value_string.

static inline void LynxValueIteratorCallback(lynx_api_env env,
                                             lynx_value key,
                                             lynx_value value, void* func,
                                             void* raw_data) {
  // do something by func
}

lynx_value_iterate_value(env, val, LynxValueIteratorCallback,
                         reinterpret_cast<void*>(func), nullptr);
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.