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

Method readNSString

Core/CodedInputDataCrypt_OSX.cpp:36–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34namespace mmkv {
35
36NSString *CodedInputDataCrypt::readNSString(KeyValueHolderCrypt &kvHolder) {
37 kvHolder.offset = static_cast<uint32_t>(m_position);
38
39 int32_t size = this->readRawVarint32(true);
40 if (size < 0) {
41 throw length_error("InvalidProtocolBuffer negativeSize");
42 }
43
44 auto s_size = static_cast<size_t>(size);
45 if (s_size <= m_size - m_position) {
46 consumeBytes(s_size);
47
48 kvHolder.keySize = static_cast<uint16_t>(s_size);
49
50 auto ptr = m_decryptBuffer + m_decryptBufferPosition;
51 NSString *result = [[NSString alloc] initWithBytes:ptr length:s_size encoding:NSUTF8StringEncoding];
52 m_position += s_size;
53 m_decryptBufferPosition += s_size;
54 return [result autorelease];
55 } else {
56 throw out_of_range("InvalidProtocolBuffer truncatedMessage");
57 }
58}
59
60} // namespace mmkv
61

Callers

nothing calls this directly

Calls 1

readRawVarint32Method · 0.95

Tested by

no test coverage detected