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

Function getMMKVWithID

Android/MMKV/mmkv/src/main/cpp/flutter-bridge.cpp:121–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121MMKV_EXPORT void *getMMKVWithID(const char *mmapID, int32_t mode, const char *cryptKey, const char *rootPath,
122 size_t expectedCapacity, bool fromNameSpace, bool aes256, int32_t enableKeyExpire,
123 int32_t expiredInSeconds, bool enableCompareBeforeSet, int32_t recover,
124 uint32_t itemSizeLimit) {
125 MMKV *kv = nullptr;
126 if (!mmapID) {
127 return kv;
128 }
129 string str = mmapID;
130
131 auto config = MMKVConfig();
132 config.mode = (MMKVMode) mode;
133 config.aes256 = aes256;
134 config.expectedCapacity = expectedCapacity;
135 if (enableKeyExpire >= 0) {
136 config.enableKeyExpire = (enableKeyExpire != 0);
137 }
138 config.expiredInSeconds = expiredInSeconds;
139 config.enableCompareBeforeSet = enableCompareBeforeSet;
140 if (recover >= 0) {
141 config.recover = static_cast<MMKVRecoverStrategic>(recover);
142 }
143 config.itemSizeLimit = itemSizeLimit;
144
145 bool done = false;
146 if (cryptKey) {
147 string crypt = cryptKey;
148 if (!crypt.empty()) {
149 config.cryptKey = &crypt;
150 if (rootPath) {
151 string path = rootPath;
152 if (fromNameSpace) {
153 auto ns = MMKV::nameSpace(path);
154 config.rootPath = &ns.getRootDir();
155 kv = ns.mmkvWithID(str, config);
156 } else {
157 config.rootPath = &path;
158 kv = MMKV::mmkvWithID(str, config);
159 }
160 } else {
161 kv = MMKV::mmkvWithID(str, config);
162 }
163 done = true;
164 }
165 }
166 if (!done) {
167 if (rootPath) {
168 string path = rootPath;
169 if (fromNameSpace) {
170 auto ns = MMKV::nameSpace(path);
171 config.rootPath = &ns.getRootDir();
172 kv = ns.mmkvWithID(str, config);
173 } else {
174 config.rootPath = &path;
175 kv = MMKV::mmkvWithID(str, config);
176 }
177 } else {
178 kv = MMKV::mmkvWithID(str, config);

Callers

nothing calls this directly

Calls 4

mmkvWithIDFunction · 0.85
MMKVConfigClass · 0.50
getRootDirMethod · 0.45
mmkvWithIDMethod · 0.45

Tested by

no test coverage detected