MCPcopy Create free account
hub / github.com/Tencent/MMKV / decodeArray

Function decodeArray

OpenHarmony/MMKV/src/main/cpp/native_bridge.cpp:1202–1218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1200
1201template <typename T>
1202napi_value decodeArray(napi_env env, napi_callback_info info) {
1203 size_t argc = 3;
1204 napi_value args[3] = {nullptr};
1205 NAPI_CALL(napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));
1206
1207 auto handle = NValueToUInt64(env, args[0]);
1208 auto key = NValueToString(env, args[1]);
1209 MMKV *kv = reinterpret_cast<MMKV *>(handle);
1210 if (kv && key.length() > 0) {
1211 std::vector<T> vec;
1212 if (kv->getVector(key, vec)) {
1213 MMBuffer result(vec.data(), vec.size() * sizeof(T));
1214 return MMBufferToNValue(env, std::move(result));
1215 }
1216 }
1217 return args[2];
1218}
1219
1220static napi_value encodeInt32Array(napi_env env, napi_callback_info info) {
1221 return encodeArray<int32_t>(env, info);

Callers

nothing calls this directly

Calls 4

NValueToUInt64Function · 0.85
MMBufferToNValueFunction · 0.85
NValueToStringFunction · 0.70
getVectorMethod · 0.45

Tested by

no test coverage detected