| 473 | |
| 474 | template <typename FieldType, typename StructT, size_t Index> |
| 475 | FORY_ALWAYS_INLINE FieldType read_configurable_int(ReadContext &ctx) { |
| 476 | static_assert(is_configurable_int_v<FieldType>, |
| 477 | "read_configurable_int requires a configurable int type"); |
| 478 | constexpr auto enc = field_int_encoding<FieldType, StructT, Index>(); |
| 479 | if constexpr (is_signed_configurable_int_v<FieldType>) { |
| 480 | if constexpr (enc == Encoding::Fixed) { |
| 481 | if constexpr (is_configurable_int32_v<FieldType>) { |
| 482 | return static_cast<FieldType>(ctx.read_int32(ctx.error())); |
| 483 | } |
| 484 | return static_cast<FieldType>(ctx.read_int64(ctx.error())); |
| 485 | } |
| 486 | if constexpr (enc == Encoding::Tagged) { |
| 487 | return static_cast<FieldType>(ctx.read_tagged_int64(ctx.error())); |
| 488 | } |
| 489 | if constexpr (is_configurable_int32_v<FieldType>) { |
| 490 | return static_cast<FieldType>(ctx.read_var_int32(ctx.error())); |
| 491 | } |
| 492 | return static_cast<FieldType>(ctx.read_var_int64(ctx.error())); |
| 493 | } else { |
| 494 | if constexpr (enc == Encoding::Fixed) { |
| 495 | if constexpr (is_configurable_int32_v<FieldType>) { |
| 496 | return static_cast<FieldType>(ctx.read_int32(ctx.error())); |
| 497 | } |
| 498 | return static_cast<FieldType>(ctx.read_uint64(ctx.error())); |
| 499 | } |
| 500 | if constexpr (enc == Encoding::Tagged) { |
| 501 | return static_cast<FieldType>(ctx.read_tagged_uint64(ctx.error())); |
| 502 | } |
| 503 | if constexpr (is_configurable_int32_v<FieldType>) { |
| 504 | return static_cast<FieldType>(ctx.read_var_uint32(ctx.error())); |
| 505 | } |
| 506 | return static_cast<FieldType>(ctx.read_var_uint64(ctx.error())); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | template <size_t... Indices, typename Func> |
| 511 | void for_each_index(std::index_sequence<Indices...>, Func &&func) { |
nothing calls this directly
no test coverage detected