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

Function read_converted

cpp/fory/serialization/compatible_scalar.cc:1421–1435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1419
1420template <typename ResultType, typename Convert>
1421ResultType read_converted(ReadContext &ctx, uint32_t remote_type_id,
1422 uint32_t local_type_id, std::string_view field,
1423 Convert convert, ResultType fallback = ResultType{}) {
1424 ScalarValue value = read_scalar(ctx, remote_type_id);
1425 if (FORY_PREDICT_FALSE(ctx.has_error())) {
1426 return fallback;
1427 }
1428 ResultType out{};
1429 if (!convert(value, out)) {
1430 conversion_error(ctx, remote_type_id, local_type_id, field,
1431 "value is not lossless");
1432 return fallback;
1433 }
1434 return out;
1435}
1436
1437} // namespace
1438

Callers

nothing calls this directly

Calls 4

read_scalarFunction · 0.85
convertFunction · 0.85
conversion_errorFunction · 0.70
has_errorMethod · 0.45

Tested by

no test coverage detected