| 185 | } |
| 186 | |
| 187 | MMBuffer MiniPBCoder::writePreparedItems(size_t index) { |
| 188 | try { |
| 189 | PBEncodeItem *oItem = (index < m_encodeItems->size()) ? &(*m_encodeItems)[index] : nullptr; |
| 190 | if (oItem && oItem->compiledSize > 0) { |
| 191 | m_outputBuffer = new MMBuffer(oItem->compiledSize); |
| 192 | m_outputData = new CodedOutputData(m_outputBuffer->getPtr(), m_outputBuffer->length()); |
| 193 | |
| 194 | writeRootObject(); |
| 195 | } |
| 196 | |
| 197 | return std::move(*m_outputBuffer); |
| 198 | } catch (const std::exception &exception) { |
| 199 | MMKVError("%s", exception.what()); |
| 200 | return MMBuffer(); |
| 201 | } catch (...) { |
| 202 | MMKVError("encode fail"); |
| 203 | return MMBuffer(); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | MMBuffer MiniPBCoder::encodeDataWithObject(const MMBuffer &obj) { |
| 208 | try { |
nothing calls this directly
no test coverage detected