| 548 | template <typename MapType, typename SpecProvider, int8_t KeyNode, |
| 549 | int8_t ValueNode> |
| 550 | MapType read_union_configured_map_data(ReadContext &ctx) { |
| 551 | using Key = key_type_t<MapType>; |
| 552 | using Value = mapped_type_t<MapType>; |
| 553 | uint32_t length = ctx.read_var_uint32(ctx.error()); |
| 554 | MapType result; |
| 555 | if (length == 0) { |
| 556 | return result; |
| 557 | } |
| 558 | if (FORY_PREDICT_FALSE(!reserve_map(result, ctx, length))) { |
| 559 | return result; |
| 560 | } |
| 561 | uint32_t read_count = 0; |
| 562 | while (read_count < length && !ctx.has_error()) { |
| 563 | uint8_t header = ctx.read_uint8(ctx.error()); |
| 564 | uint8_t chunk_size = ctx.read_uint8(ctx.error()); |
| 565 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 566 | return result; |
| 567 | } |
| 568 | const bool key_decl = (header & DECL_KEY_TYPE) != 0; |
| 569 | const bool value_decl = (header & DECL_VALUE_TYPE) != 0; |
| 570 | if (!key_decl) { |
| 571 | (void)ctx.read_any_type_info(ctx.error()); |
| 572 | } |
| 573 | if (!value_decl) { |
| 574 | (void)ctx.read_any_type_info(ctx.error()); |
| 575 | } |
| 576 | for (uint8_t i = 0; i < chunk_size && read_count < length; ++i) { |
| 577 | Key key = [&]() { |
| 578 | if constexpr (KeyNode >= 0) { |
| 579 | return read_union_configured_value<Key, SpecProvider, KeyNode>( |
| 580 | ctx, RefMode::None, false); |
| 581 | } else { |
| 582 | return Serializer<Key>::read_data(ctx); |
| 583 | } |
| 584 | }(); |
| 585 | Value value = [&]() { |
| 586 | if constexpr (ValueNode >= 0) { |
| 587 | return read_union_configured_value<Value, SpecProvider, ValueNode>( |
| 588 | ctx, RefMode::None, false); |
| 589 | } else { |
| 590 | return Serializer<Value>::read_data(ctx); |
| 591 | } |
| 592 | }(); |
| 593 | result.emplace(std::move(key), std::move(value)); |
| 594 | ++read_count; |
| 595 | } |
| 596 | } |
| 597 | return result; |
| 598 | } |
| 599 | |
| 600 | template <typename ValueType, typename SpecProvider, int8_t NodeIndex> |
| 601 | void write_union_configured_value(const ValueType &value, WriteContext &ctx, |
nothing calls this directly
no test coverage detected