| 502 | |
| 503 | #ifndef MMKV_APPLE |
| 504 | void MiniPBCoder::decodeOneMap(MMKVMap &dic, size_t position, bool greedy) { |
| 505 | auto block = [position, this](MMKVMap &dictionary) { |
| 506 | if (position) { |
| 507 | m_inputData->seek(position); |
| 508 | } else { |
| 509 | m_inputData->readInt32(); |
| 510 | } |
| 511 | while (!m_inputData->isAtEnd()) { |
| 512 | KeyValueHolder kvHolder; |
| 513 | const auto &key = m_inputData->readString(kvHolder); |
| 514 | if (key.length() > 0) { |
| 515 | m_inputData->readData(kvHolder); |
| 516 | if (kvHolder.valueSize > 0) { |
| 517 | dictionary[key] = std::move(kvHolder); |
| 518 | } else { |
| 519 | auto itr = dictionary.find(key); |
| 520 | if (itr != dictionary.end()) { |
| 521 | dictionary.erase(itr); |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | }; |
| 527 | |
| 528 | if (greedy) { |
| 529 | try { |
| 530 | block(dic); |
| 531 | } catch (std::exception &exception) { |
| 532 | MMKVError("%s", exception.what()); |
| 533 | } catch (...) { |
| 534 | MMKVError("prepare encode fail"); |
| 535 | } |
| 536 | } else { |
| 537 | try { |
| 538 | MMKVMap tmpDic; |
| 539 | block(tmpDic); |
| 540 | dic.swap(tmpDic); |
| 541 | } catch (std::exception &exception) { |
| 542 | MMKVError("%s", exception.what()); |
| 543 | } catch (...) { |
| 544 | MMKVError("prepare encode fail"); |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | # ifndef MMKV_DISABLE_CRYPT |
| 550 |
no test coverage detected