MCPcopy Create free account
hub / github.com/apache/brpc / end_array

Method end_array

src/mcpack2pb/serializer.cpp:780–814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778}
779
780void 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

Callers 3

AppendErrorFunction · 0.80
SerializeUbrpcRequestFunction · 0.80

Calls 10

pop_group_infoFunction · 0.85
add_pending_nullsFunction · 0.85
backupMethod · 0.80
goodMethod · 0.45
set_badMethod · 0.45
pushed_bytesMethod · 0.45
set_typeMethod · 0.45
assignMethod · 0.45
set_name_sizeMethod · 0.45
set_value_sizeMethod · 0.45

Tested by

no test coverage detected