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

Function write_configured_list_data

cpp/fory/serialization/struct_serializer.h:862–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

860template <typename Container, typename StructT, size_t Index, int8_t NodeIndex,
861 int8_t ElemNode>
862void write_configured_list_data(const Container &coll, WriteContext &ctx) {
863 using Elem = element_type_t<Container>;
864 ctx.write_var_uint32(static_cast<uint32_t>(coll.size()));
865 if (coll.empty()) {
866 return;
867 }
868 uint8_t header = COLL_DECL_ELEMENT_TYPE | COLL_IS_SAME_TYPE;
869 bool has_null = false;
870 if constexpr (is_nullable_v<Elem>) {
871 for (const auto &elem : coll) {
872 if (is_null_value(elem)) {
873 has_null = true;
874 break;
875 }
876 }
877 if (has_null) {
878 header |= COLL_HAS_NULL;
879 }
880 }
881 ctx.write_uint8(header);
882 const RefMode elem_ref_mode = has_null ? RefMode::NullOnly : RefMode::None;
883 for (const auto &elem : coll) {
884 if constexpr (ElemNode >= 0) {
885 write_configured_value<Elem, StructT, Index, ElemNode>(
886 elem, ctx, elem_ref_mode, false, true);
887 } else {
888 Serializer<Elem>::write(elem, ctx, elem_ref_mode, false);
889 }
890 }
891}
892
893template <typename Container, typename StructT, size_t Index, int8_t NodeIndex,
894 int8_t ElemNode>

Callers

nothing calls this directly

Calls 6

is_null_valueFunction · 0.85
writeFunction · 0.50
write_var_uint32Method · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
write_uint8Method · 0.45

Tested by

no test coverage detected