! @brief reads a UBJSON string This function is either called after reading the 'S' byte explicitly indicating a string, or in case of an object key where the 'S' byte can be left out. @param[out] result created string @param[in] get_char whether a new character should be retrieved from the
| 9415 | @return whether string creation completed |
| 9416 | */ |
| 9417 | bool get_ubjson_string(string_t& result, const bool get_char = true) |
| 9418 | { |
| 9419 | if (get_char) |
| 9420 | { |
| 9421 | get(); // TODO(niels): may we ignore N here? |
| 9422 | } |
| 9423 | |
| 9424 | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) |
| 9425 | { |
| 9426 | return false; |
| 9427 | } |
| 9428 | |
| 9429 | switch (current) |
| 9430 | { |
| 9431 | case 'U': |
| 9432 | { |
| 9433 | std::uint8_t len{}; |
| 9434 | return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); |
| 9435 | } |
| 9436 | |
| 9437 | case 'i': |
| 9438 | { |
| 9439 | std::int8_t len{}; |
| 9440 | return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); |
| 9441 | } |
| 9442 | |
| 9443 | case 'I': |
| 9444 | { |
| 9445 | std::int16_t len{}; |
| 9446 | return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); |
| 9447 | } |
| 9448 | |
| 9449 | case 'l': |
| 9450 | { |
| 9451 | std::int32_t len{}; |
| 9452 | return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); |
| 9453 | } |
| 9454 | |
| 9455 | case 'L': |
| 9456 | { |
| 9457 | std::int64_t len{}; |
| 9458 | return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); |
| 9459 | } |
| 9460 | |
| 9461 | default: |
| 9462 | auto last_token = get_token_string(); |
| 9463 | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"))); |
| 9464 | } |
| 9465 | } |
| 9466 | |
| 9467 | /*! |
| 9468 | @param[out] result determined size |
nothing calls this directly
no test coverage detected