| 715 | } |
| 716 | |
| 717 | bool MMKV::getString(MMKVKey_t key, string &result, bool inplaceModification) { |
| 718 | if (isKeyEmpty(key)) { |
| 719 | return false; |
| 720 | } |
| 721 | SCOPED_LOCK(m_lock); |
| 722 | SCOPED_LOCK(m_sharedProcessLock); |
| 723 | auto data = getDataForKey(key); |
| 724 | if (data.length() > 0) { |
| 725 | try { |
| 726 | CodedInputData input(data.getPtr(), data.length()); |
| 727 | if (inplaceModification) { |
| 728 | input.readString(result); |
| 729 | } else { |
| 730 | result = input.readString(); |
| 731 | } |
| 732 | return true; |
| 733 | } catch (std::exception &exception) { |
| 734 | MMKVError("%s", exception.what()); |
| 735 | } catch (...) { |
| 736 | MMKVError("decode fail"); |
| 737 | } |
| 738 | } |
| 739 | return false; |
| 740 | } |
| 741 | |
| 742 | bool MMKV::getBytes(MMKVKey_t key, mmkv::MMBuffer &result) { |
| 743 | if (isKeyEmpty(key)) { |