| 778 | } |
| 779 | |
| 780 | void Serializer::end_array() { |
| 781 | if (!_stream->good()) { |
| 782 | return; |
| 783 | } |
| 784 | GroupInfo & group_info = peek_group_info(); |
| 785 | if (FIELD_ARRAY != group_info.type) { |
| 786 | CHECK(false) << "end_array() is called on " << group_info; |
| 787 | return _stream->set_bad(); |
| 788 | } |
| 789 | if (group_info.item_count == 0 && group_info.pending_null_count == 0) { |
| 790 | // Remove the heading. This is a must because idl cannot load an empty |
| 791 | // array only with header. |
| 792 | _stream->backup(_stream->pushed_bytes() - group_info.output_offset); |
| 793 | pop_group_info(_ndepth); |
| 794 | --peek_group_info().item_count; |
| 795 | return; |
| 796 | } |
| 797 | // Reset lhead/items_head |
| 798 | FieldLongHead lhead; |
| 799 | if (group_info.isomorphic) { |
| 800 | lhead.set_type(FIELD_ISOARRAY); |
| 801 | } else { |
| 802 | lhead.set_type(FIELD_ARRAY); |
| 803 | if (group_info.pending_null_count) { |
| 804 | add_pending_nulls(_stream, group_info); |
| 805 | } |
| 806 | const ItemsHead items_head = { group_info.item_count }; |
| 807 | _stream->assign(group_info.items_head_area, &items_head); |
| 808 | } |
| 809 | lhead.set_name_size(group_info.name_size); |
| 810 | lhead.set_value_size(_stream->pushed_bytes() - group_info.output_offset |
| 811 | - group_info.name_size - sizeof(FieldLongHead)); |
| 812 | _stream->assign(group_info.head_area, &lhead); |
| 813 | pop_group_info(_ndepth); |
| 814 | } |
| 815 | |
| 816 | } // namespace mcpack2pb |
no test coverage detected