! @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 input (true, default) or whether the last read character should be considered inste
| 10921 | @return whether string creation completed |
| 10922 | */ |
| 10923 | bool get_ubjson_string(string_t& result, const bool get_char = true) |
| 10924 | { |
| 10925 | if (get_char) |
| 10926 | { |
| 10927 | get(); // TODO(niels): may we ignore N here? |
| 10928 | } |
| 10929 | |
| 10930 | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) |
| 10931 | { |
| 10932 | return false; |
| 10933 | } |
| 10934 | |
| 10935 | switch (current) |
| 10936 | { |
| 10937 | case 'U': |
| 10938 | { |
| 10939 | std::uint8_t len{}; |
| 10940 | return get_number(input_format, len) && get_string(input_format, len, result); |
| 10941 | } |
| 10942 | |
| 10943 | case 'i': |
| 10944 | { |
| 10945 | std::int8_t len{}; |
| 10946 | return get_number(input_format, len) && get_string(input_format, len, result); |
| 10947 | } |
| 10948 | |
| 10949 | case 'I': |
| 10950 | { |
| 10951 | std::int16_t len{}; |
| 10952 | return get_number(input_format, len) && get_string(input_format, len, result); |
| 10953 | } |
| 10954 | |
| 10955 | case 'l': |
| 10956 | { |
| 10957 | std::int32_t len{}; |
| 10958 | return get_number(input_format, len) && get_string(input_format, len, result); |
| 10959 | } |
| 10960 | |
| 10961 | case 'L': |
| 10962 | { |
| 10963 | std::int64_t len{}; |
| 10964 | return get_number(input_format, len) && get_string(input_format, len, result); |
| 10965 | } |
| 10966 | |
| 10967 | case 'u': |
| 10968 | { |
| 10969 | if (input_format != input_format_t::bjdata) |
| 10970 | { |
| 10971 | break; |
| 10972 | } |
| 10973 | std::uint16_t len{}; |
| 10974 | return get_number(input_format, len) && get_string(input_format, len, result); |
| 10975 | } |
| 10976 | |
| 10977 | case 'm': |
| 10978 | { |
| 10979 | if (input_format != input_format_t::bjdata) |
| 10980 | { |
nothing calls this directly
no test coverage detected