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

Function encodeString

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

Source from the content-addressed store, hash-verified

981}
982
983static napi_value encodeString(napi_env env, napi_callback_info info) {
984 size_t argc = 4;
985 napi_value args[4] = {nullptr};
986 NAPI_CALL(napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));
987
988 auto handle = NValueToUInt64(env, args[0]);
989 auto key = NValueToString(env, args[1]);
990 MMKV *kv = reinterpret_cast<MMKV *>(handle);
991 if (kv && key.length() > 0) {
992 auto value = NValueToString(env, args[2]);
993 if (IsNValueUndefined(env, args[3])) {
994 auto ret = kv->set(value, key);
995 return BoolToNValue(env, ret);
996 }
997 uint32_t expiration = NValueToUInt32(env, args[3]);
998 auto ret = kv->set(value, key, expiration);
999 return BoolToNValue(env, ret);
1000 }
1001 return BoolToNValue(env, false);
1002}
1003
1004static napi_value decodeString(napi_env env, napi_callback_info info) {
1005 size_t argc = 3;

Callers

nothing calls this directly

Calls 6

NValueToUInt64Function · 0.85
NValueToUInt32Function · 0.85
NValueToStringFunction · 0.70
IsNValueUndefinedFunction · 0.70
BoolToNValueFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected