write object using prepared m_encodeItems[]
| 66 | |
| 67 | // write object using prepared m_encodeItems[] |
| 68 | void MiniPBCoder::writeRootObject() { |
| 69 | for (size_t index = 0, total = m_encodeItems->size(); index < total; index++) { |
| 70 | PBEncodeItem *encodeItem = &(*m_encodeItems)[index]; |
| 71 | switch (encodeItem->type) { |
| 72 | case PBEncodeItemType_Data: { |
| 73 | m_outputData->writeData(*(encodeItem->value.bufferValue)); |
| 74 | break; |
| 75 | } |
| 76 | case PBEncodeItemType_Container: { |
| 77 | m_outputData->writeUInt32(encodeItem->valueSize); |
| 78 | break; |
| 79 | } |
| 80 | #ifdef MMKV_HAS_CPP20 |
| 81 | case PBEncodeItemType_Int32: { |
| 82 | m_outputData->writeInt32(encodeItem->value.int32Value); |
| 83 | break; |
| 84 | } |
| 85 | case PBEncodeItemType_UInt32: { |
| 86 | m_outputData->writeUInt32(encodeItem->value.uint32Value); |
| 87 | break; |
| 88 | } |
| 89 | case PBEncodeItemType_Int64: { |
| 90 | m_outputData->writeInt64(encodeItem->value.int64Value); |
| 91 | break; |
| 92 | } |
| 93 | case PBEncodeItemType_UInt64: { |
| 94 | m_outputData->writeUInt64(encodeItem->value.uint64Value); |
| 95 | break; |
| 96 | } |
| 97 | #endif // MMKV_HAS_CPP20 |
| 98 | case PBEncodeItemType_String: { |
| 99 | m_outputData->writeString(*(encodeItem->value.strValue)); |
| 100 | break; |
| 101 | } |
| 102 | #ifdef MMKV_APPLE |
| 103 | case PBEncodeItemType_NSString: { |
| 104 | m_outputData->writeUInt32(encodeItem->valueSize); |
| 105 | if (encodeItem->valueSize > 0 && encodeItem->value.tmpObjectValue != nullptr) { |
| 106 | auto obj = (__bridge NSData *) encodeItem->value.tmpObjectValue; |
| 107 | MMBuffer buffer(obj, MMBufferNoCopy); |
| 108 | m_outputData->writeRawData(buffer); |
| 109 | } |
| 110 | break; |
| 111 | } |
| 112 | case PBEncodeItemType_NSData: { |
| 113 | m_outputData->writeUInt32(encodeItem->valueSize); |
| 114 | if (encodeItem->valueSize > 0 && encodeItem->value.objectValue != nullptr) { |
| 115 | auto obj = (__bridge NSData *) encodeItem->value.objectValue; |
| 116 | MMBuffer buffer(obj, MMBufferNoCopy); |
| 117 | m_outputData->writeRawData(buffer); |
| 118 | } |
| 119 | break; |
| 120 | } |
| 121 | case PBEncodeItemType_NSDate: { |
| 122 | NSDate *oDate = (__bridge NSDate *) encodeItem->value.objectValue; |
| 123 | m_outputData->writeDouble(oDate.timeIntervalSince1970); |
| 124 | break; |
| 125 | } |
nothing calls this directly
no test coverage detected