| 183 | } |
| 184 | |
| 185 | MMKV_EXPORT void *getDefaultMMKV(int32_t mode, const char *cryptKey, bool aes256, size_t expectedCapacity, |
| 186 | int32_t enableKeyExpire, int32_t expiredInSeconds, bool enableCompareBeforeSet, |
| 187 | int32_t recover, uint32_t itemSizeLimit) { |
| 188 | MMKV *kv = nullptr; |
| 189 | |
| 190 | auto config = MMKVConfig(); |
| 191 | config.mode = (MMKVMode) mode; |
| 192 | config.aes256 = aes256; |
| 193 | config.expectedCapacity = expectedCapacity; |
| 194 | if (enableKeyExpire >= 0) { |
| 195 | config.enableKeyExpire = (enableKeyExpire != 0); |
| 196 | } |
| 197 | config.expiredInSeconds = expiredInSeconds; |
| 198 | config.enableCompareBeforeSet = enableCompareBeforeSet; |
| 199 | if (recover >= 0) { |
| 200 | config.recover = static_cast<MMKVRecoverStrategic>(recover); |
| 201 | } |
| 202 | config.itemSizeLimit = itemSizeLimit; |
| 203 | |
| 204 | if (cryptKey) { |
| 205 | string crypt = cryptKey; |
| 206 | if (crypt.length() > 0) { |
| 207 | config.cryptKey = &crypt; |
| 208 | kv = MMKV::defaultMMKV(config); |
| 209 | } |
| 210 | } |
| 211 | if (!kv) { |
| 212 | kv = MMKV::defaultMMKV(config); |
| 213 | } |
| 214 | |
| 215 | return kv; |
| 216 | } |
| 217 | |
| 218 | MMKV_EXPORT const char *mmapID(void *handle) { |
| 219 | MMKV *kv = static_cast<MMKV *>(handle); |