| 193 | // Gets a map value and writes it in JSON format. |
| 194 | template <class JsonStream> |
| 195 | void ComplexValueWriter<JsonStream>::MapValueToJSON(const CollectionValue& map_value, |
| 196 | const TupleDescriptor* item_tuple_desc) { |
| 197 | DCHECK(item_tuple_desc != nullptr); |
| 198 | |
| 199 | const int item_byte_size = item_tuple_desc->byte_size(); |
| 200 | const vector<SlotDescriptor*>& slot_descs = item_tuple_desc->slots(); |
| 201 | |
| 202 | DCHECK(slot_descs.size() == 2); |
| 203 | DCHECK(slot_descs[0] != nullptr); |
| 204 | DCHECK(slot_descs[1] != nullptr); |
| 205 | |
| 206 | writer_->StartObject(); |
| 207 | |
| 208 | for (int i = 0; i < map_value.num_tuples; ++i) { |
| 209 | Tuple* item_tuple = reinterpret_cast<Tuple*>( |
| 210 | map_value.ptr + i * item_byte_size); |
| 211 | // Print key. |
| 212 | const SlotDescriptor& key_slot_desc = *slot_descs[0]; |
| 213 | CollectionElementToJSON(item_tuple, key_slot_desc, true); |
| 214 | |
| 215 | // Print the value. |
| 216 | const SlotDescriptor& value_slot_desc = *slot_descs[1]; |
| 217 | CollectionElementToJSON(item_tuple, value_slot_desc, false); |
| 218 | } |
| 219 | |
| 220 | writer_->EndObject(); |
| 221 | } |
| 222 | |
| 223 | template <class JsonStream> |
| 224 | ComplexValueWriter<JsonStream>::ComplexValueWriter(rapidjson::Writer<JsonStream>* writer, |
nothing calls this directly
no test coverage detected