| 33 | namespace py = pybind11; |
| 34 | |
| 35 | static MMKVConfig pyArgsToConfig(MMKVMode mode, const string &cryptKey, const MMKVPath_t &rootDir, |
| 36 | size_t expectedCapacity, bool aes256, std::optional<bool> enableKeyExpire, |
| 37 | uint32_t expiredInSeconds, bool enableCompareBeforeSet, |
| 38 | std::optional<MMKVRecoverStrategic> recover, uint32_t itemSizeLimit) { |
| 39 | MMKVConfig config; |
| 40 | config.mode = mode; |
| 41 | config.aes256 = aes256; |
| 42 | config.cryptKey = (cryptKey.length() > 0) ? (string *) &cryptKey : nullptr; |
| 43 | config.rootPath = (rootDir.length() > 0) ? (MMKVPath_t *) &rootDir : nullptr; |
| 44 | config.expectedCapacity = expectedCapacity; |
| 45 | config.enableKeyExpire = enableKeyExpire; |
| 46 | config.expiredInSeconds = expiredInSeconds; |
| 47 | config.enableCompareBeforeSet = enableCompareBeforeSet; |
| 48 | config.recover = recover; |
| 49 | config.itemSizeLimit = itemSizeLimit; |
| 50 | return config; |
| 51 | } |
| 52 | |
| 53 | static MMBuffer pyBytes2MMBuffer(const py::bytes &bytes) { |
| 54 | char *buffer = nullptr; |