MMKV_IO.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Tencent is pleased to support the open source community by making
  3. * MMKV available.
  4. *
  5. * Copyright (C) 2020 THL A29 Limited, a Tencent company.
  6. * All rights reserved.
  7. *
  8. * Licensed under the BSD 3-Clause License (the "License"); you may not use
  9. * this file except in compliance with the License. You may obtain a copy of
  10. * the License at
  11. *
  12. * https://opensource.org/licenses/BSD-3-Clause
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. #ifndef MMKV_IO_h
  21. #define MMKV_IO_h
  22. #ifdef __cplusplus
  23. #include "MMKV.h"
  24. MMKV_NAMESPACE_BEGIN
  25. std::string mmapedKVKey(const std::string &mmapID, const MMKVPath_t *rootPath = nullptr);
  26. MMKVPath_t mappedKVPathWithID(const std::string &mmapID, MMKVMode mode, const MMKVPath_t *rootPath);
  27. MMKVPath_t crcPathWithID(const std::string &mmapID, MMKVMode mode, const MMKVPath_t *rootPath);
  28. MMKVRecoverStrategic onMMKVCRCCheckFail(const std::string &mmapID);
  29. MMKVRecoverStrategic onMMKVFileLengthError(const std::string &mmapID);
  30. template <typename T>
  31. void clearDictionary(T *dic) {
  32. if (!dic) {
  33. return;
  34. }
  35. #ifdef MMKV_APPLE
  36. for (auto &pair : *dic) {
  37. [pair.first release];
  38. }
  39. #endif
  40. dic->clear();
  41. }
  42. enum : bool {
  43. KeepSequence = false,
  44. IncreaseSequence = true,
  45. };
  46. MMKV_NAMESPACE_END
  47. #endif
  48. #endif /* MMKV_IO_h */