! @brief reads a CBOR byte array This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into the byte array. Additionally, CBOR's byte arrays with indefinite lengths are supported. @param[out] result created byte array @return whether byte array creation completed */
| 10079 | @return whether byte array creation completed |
| 10080 | */ |
| 10081 | bool get_cbor_binary(binary_t& result) |
| 10082 | { |
| 10083 | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) |
| 10084 | { |
| 10085 | return false; |
| 10086 | } |
| 10087 | |
| 10088 | switch (current) |
| 10089 | { |
| 10090 | // Binary data (0x00..0x17 bytes follow) |
| 10091 | case 0x40: |
| 10092 | case 0x41: |
| 10093 | case 0x42: |
| 10094 | case 0x43: |
| 10095 | case 0x44: |
| 10096 | case 0x45: |
| 10097 | case 0x46: |
| 10098 | case 0x47: |
| 10099 | case 0x48: |
| 10100 | case 0x49: |
| 10101 | case 0x4A: |
| 10102 | case 0x4B: |
| 10103 | case 0x4C: |
| 10104 | case 0x4D: |
| 10105 | case 0x4E: |
| 10106 | case 0x4F: |
| 10107 | case 0x50: |
| 10108 | case 0x51: |
| 10109 | case 0x52: |
| 10110 | case 0x53: |
| 10111 | case 0x54: |
| 10112 | case 0x55: |
| 10113 | case 0x56: |
| 10114 | case 0x57: |
| 10115 | { |
| 10116 | return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result); |
| 10117 | } |
| 10118 | |
| 10119 | case 0x58: // Binary data (one-byte uint8_t for n follows) |
| 10120 | { |
| 10121 | std::uint8_t len{}; |
| 10122 | return get_number(input_format_t::cbor, len) && |
| 10123 | get_binary(input_format_t::cbor, len, result); |
| 10124 | } |
| 10125 | |
| 10126 | case 0x59: // Binary data (two-byte uint16_t for n follow) |
| 10127 | { |
| 10128 | std::uint16_t len{}; |
| 10129 | return get_number(input_format_t::cbor, len) && |
| 10130 | get_binary(input_format_t::cbor, len, result); |
| 10131 | } |
| 10132 | |
| 10133 | case 0x5A: // Binary data (four-byte uint32_t for n follow) |
| 10134 | { |
| 10135 | std::uint32_t len{}; |
| 10136 | return get_number(input_format_t::cbor, len) && |
| 10137 | get_binary(input_format_t::cbor, len, result); |
| 10138 | } |
nothing calls this directly
no test coverage detected