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

Method encodeDataWithObject

Core/MiniPBCoder.cpp:207–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207MMBuffer MiniPBCoder::encodeDataWithObject(const MMBuffer &obj) {
208 try {
209 auto valueSize = static_cast<uint32_t>(obj.length());
210 auto compiledSize = pbRawVarint32Size(valueSize) + valueSize;
211 MMBuffer result(compiledSize);
212 CodedOutputData output(result.getPtr(), result.length());
213 output.writeData(obj);
214 return result;
215 } catch (const std::exception &exception) {
216 MMKVError("%s", exception.what());
217 return MMBuffer();
218 } catch (...) {
219 MMKVError("prepare encode fail");
220 return MMBuffer();
221 }
222}
223
224size_t MiniPBCoder::prepareObjectForEncode(const string &str) {
225 m_encodeItems->push_back(PBEncodeItem());

Callers

nothing calls this directly

Calls 3

writeDataMethod · 0.80
pbRawVarint32SizeFunction · 0.70
MMBufferFunction · 0.70

Tested by

no test coverage detected