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

Method getString

Core/MMKV.cpp:717–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

715}
716
717bool 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
742bool MMKV::getBytes(MMKVKey_t key, mmkv::MMBuffer &result) {
743 if (isKeyEmpty(key)) {

Callers 15

test_expected_capacityFunction · 0.95
test_compare_before_setFunction · 0.95
test_importFunction · 0.95
brutleTestFunction · 0.45
functionalTestFunction · 0.45
testImportFunction · 0.45
functionalTestFunction · 0.45
decodeStringFunction · 0.45
test_stringFunction · 0.45
PYBIND11_MODULEFunction · 0.45
functional_test_impFunction · 0.45
functionalTestFunction · 0.45

Calls 2

isKeyEmptyFunction · 0.85
readStringMethod · 0.45

Tested by 7

test_expected_capacityFunction · 0.76
test_compare_before_setFunction · 0.76
test_importFunction · 0.76
test_stringFunction · 0.36
testStringFunction · 0.36
testRemoveFunction · 0.36
functionalTestFunction · 0.36