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

Method readString

Core/CodedInputDataCrypt.cpp:220–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220string CodedInputDataCrypt::readString(KeyValueHolderCrypt &kvHolder) {
221 kvHolder.offset = static_cast<uint32_t>(m_position);
222
223 int32_t size = this->readRawVarint32(true);
224 if (size < 0) {
225 throw length_error("InvalidProtocolBuffer negativeSize");
226 }
227
228 auto s_size = static_cast<size_t>(size);
229 if (s_size <= m_size - m_position) {
230 consumeBytes(s_size);
231
232 kvHolder.keySize = static_cast<uint16_t>(s_size);
233
234 string result((char *) (m_decryptBuffer + m_decryptBufferPosition), s_size);
235 m_position += s_size;
236 m_decryptBufferPosition += s_size;
237 return result;
238 } else {
239 throw out_of_range("InvalidProtocolBuffer truncatedMessage");
240 }
241}
242
243void CodedInputDataCrypt::readData(KeyValueHolderCrypt &kvHolder) {
244 int32_t size = this->readRawVarint32();

Callers

nothing calls this directly

Calls 1

readRawVarint32Method · 0.95

Tested by

no test coverage detected