! @brief reads a CBOR string This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string. Additionally, CBOR's strings with indefinite lengths are supported. @param[out] result created string @return whether string creation completed */
| 9983 | @return whether string creation completed |
| 9984 | */ |
| 9985 | bool get_cbor_string(string_t& result) |
| 9986 | { |
| 9987 | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) |
| 9988 | { |
| 9989 | return false; |
| 9990 | } |
| 9991 | |
| 9992 | switch (current) |
| 9993 | { |
| 9994 | // UTF-8 string (0x00..0x17 bytes follow) |
| 9995 | case 0x60: |
| 9996 | case 0x61: |
| 9997 | case 0x62: |
| 9998 | case 0x63: |
| 9999 | case 0x64: |
| 10000 | case 0x65: |
| 10001 | case 0x66: |
| 10002 | case 0x67: |
| 10003 | case 0x68: |
| 10004 | case 0x69: |
| 10005 | case 0x6A: |
| 10006 | case 0x6B: |
| 10007 | case 0x6C: |
| 10008 | case 0x6D: |
| 10009 | case 0x6E: |
| 10010 | case 0x6F: |
| 10011 | case 0x70: |
| 10012 | case 0x71: |
| 10013 | case 0x72: |
| 10014 | case 0x73: |
| 10015 | case 0x74: |
| 10016 | case 0x75: |
| 10017 | case 0x76: |
| 10018 | case 0x77: |
| 10019 | { |
| 10020 | return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result); |
| 10021 | } |
| 10022 | |
| 10023 | case 0x78: // UTF-8 string (one-byte uint8_t for n follows) |
| 10024 | { |
| 10025 | std::uint8_t len{}; |
| 10026 | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
| 10027 | } |
| 10028 | |
| 10029 | case 0x79: // UTF-8 string (two-byte uint16_t for n follow) |
| 10030 | { |
| 10031 | std::uint16_t len{}; |
| 10032 | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
| 10033 | } |
| 10034 | |
| 10035 | case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) |
| 10036 | { |
| 10037 | std::uint32_t len{}; |
| 10038 | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
| 10039 | } |
| 10040 | |
| 10041 | case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) |
| 10042 | { |
nothing calls this directly
no test coverage detected