! @param[out] result determined size @param[in,out] is_ndarray for input, `true` means already inside an ndarray vector or ndarray dimension is not allowed; `false` means ndarray is allowed; for output, `true` means an ndarray is found; is_ndarray can only return `true` when its initial value is `false` @param[in] prefix type marker if already read, ot
| 11081 | @return whether size determination completed |
| 11082 | */ |
| 11083 | bool get_ubjson_size_value(std::size_t& result, bool& is_ndarray, char_int_type prefix = 0) |
| 11084 | { |
| 11085 | if (prefix == 0) |
| 11086 | { |
| 11087 | prefix = get_ignore_noop(); |
| 11088 | } |
| 11089 | |
| 11090 | switch (prefix) |
| 11091 | { |
| 11092 | case 'U': |
| 11093 | { |
| 11094 | std::uint8_t number{}; |
| 11095 | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
| 11096 | { |
| 11097 | return false; |
| 11098 | } |
| 11099 | result = static_cast<std::size_t>(number); |
| 11100 | return true; |
| 11101 | } |
| 11102 | |
| 11103 | case 'i': |
| 11104 | { |
| 11105 | std::int8_t number{}; |
| 11106 | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
| 11107 | { |
| 11108 | return false; |
| 11109 | } |
| 11110 | if (number < 0) |
| 11111 | { |
| 11112 | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, |
| 11113 | exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); |
| 11114 | } |
| 11115 | result = static_cast<std::size_t>(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char |
| 11116 | return true; |
| 11117 | } |
| 11118 | |
| 11119 | case 'I': |
| 11120 | { |
| 11121 | std::int16_t number{}; |
| 11122 | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
| 11123 | { |
| 11124 | return false; |
| 11125 | } |
| 11126 | if (number < 0) |
| 11127 | { |
| 11128 | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, |
| 11129 | exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); |
| 11130 | } |
| 11131 | result = static_cast<std::size_t>(number); |
| 11132 | return true; |
| 11133 | } |
| 11134 | |
| 11135 | case 'l': |
| 11136 | { |
| 11137 | std::int32_t number{}; |
| 11138 | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
| 11139 | { |
| 11140 | return false; |
nothing calls this directly
no test coverage detected