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

Method readData

Core/CodedInputData.cpp:144–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144MMBuffer CodedInputData::readData(bool copy, bool exactly) {
145 int32_t size = this->readRawVarint32();
146 if (size < 0) {
147 throw length_error("InvalidProtocolBuffer negativeSize");
148 }
149
150 auto s_size = static_cast<size_t>(size);
151 bool isSizeValid = exactly ? (s_size == m_size - m_position) : (s_size <= m_size - m_position);
152 if (isSizeValid) {
153 size_t pos = m_position;
154 m_position += s_size;
155 auto copyFlag = copy ? MMBufferCopy : MMBufferNoCopy;
156 return MMBuffer(((int8_t *) m_ptr) + pos, s_size, copyFlag);
157 } else {
158 throw out_of_range("InvalidProtocolBuffer truncatedMessage");
159 }
160}
161
162void CodedInputData::readData(KeyValueHolder &kvHolder) {
163 int32_t size = this->readRawVarint32();

Callers 4

getBytesMethod · 0.45
readRealDataMethod · 0.45
decodeOneMapMethod · 0.45

Calls 2

readRawVarint32Method · 0.95
MMBufferFunction · 0.70

Tested by

no test coverage detected