MCPcopy Create free account
hub / github.com/apache/fory / read_configured_list_data

Function read_configured_list_data

cpp/fory/serialization/struct_serializer.h:895–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

893template <typename Container, typename StructT, size_t Index, int8_t NodeIndex,
894 int8_t ElemNode>
895Container read_configured_list_data(ReadContext &ctx) {
896 using Elem = element_type_t<Container>;
897 uint32_t length = ctx.read_var_uint32(ctx.error());
898 Container result;
899 if (length == 0) {
900 return result;
901 }
902 if (FORY_PREDICT_FALSE(!reserve_collection(result, ctx, length))) {
903 return result;
904 }
905 uint8_t bitmap = ctx.read_uint8(ctx.error());
906 if (FORY_PREDICT_FALSE(ctx.has_error())) {
907 return result;
908 }
909 const bool is_decl_type = (bitmap & COLL_DECL_ELEMENT_TYPE) != 0;
910 const bool is_same_type = (bitmap & COLL_IS_SAME_TYPE) != 0;
911 const bool track_ref = (bitmap & COLL_TRACKING_REF) != 0;
912 const bool has_null = (bitmap & COLL_HAS_NULL) != 0;
913 if (is_same_type && !is_decl_type) {
914 (void)ctx.read_any_type_info(ctx.error());
915 if (FORY_PREDICT_FALSE(ctx.has_error())) {
916 return result;
917 }
918 }
919 const RefMode elem_ref_mode =
920 track_ref ? RefMode::Tracking
921 : (has_null ? RefMode::NullOnly : RefMode::None);
922 for (uint32_t i = 0; i < length; ++i) {
923 if constexpr (ElemNode >= 0) {
924 auto elem = read_configured_value<Elem, StructT, Index, ElemNode>(
925 ctx, elem_ref_mode, false);
926 collection_insert(result, std::move(elem));
927 } else {
928 auto elem = Serializer<Elem>::read(ctx, elem_ref_mode, false);
929 collection_insert(result, std::move(elem));
930 }
931 }
932 return result;
933}
934
935template <typename Container, typename StructT, size_t Index, int8_t NodeIndex,
936 int8_t ElemNode>

Callers

nothing calls this directly

Calls 8

reserve_collectionFunction · 0.85
collection_insertFunction · 0.85
errorMethod · 0.65
readFunction · 0.50
read_var_uint32Method · 0.45
read_uint8Method · 0.45
has_errorMethod · 0.45
read_any_type_infoMethod · 0.45

Tested by

no test coverage detected