| 1419 | |
| 1420 | template <typename ResultType, typename Convert> |
| 1421 | ResultType 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 |
nothing calls this directly
no test coverage detected