! @brief reads a MessagePack byte array This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into a byte array. @param[out] result created byte array @return whether byte array creation completed */
| 9227 | @return whether byte array creation completed |
| 9228 | */ |
| 9229 | bool get_msgpack_binary(binary_t& result) |
| 9230 | { |
| 9231 | // helper function to set the subtype |
| 9232 | auto assign_and_return_true = [&result](std::int8_t subtype) |
| 9233 | { |
| 9234 | result.set_subtype(static_cast<std::uint8_t>(subtype)); |
| 9235 | return true; |
| 9236 | }; |
| 9237 | |
| 9238 | switch (current) |
| 9239 | { |
| 9240 | case 0xC4: // bin 8 |
| 9241 | { |
| 9242 | std::uint8_t len{}; |
| 9243 | return get_number(input_format_t::msgpack, len) && |
| 9244 | get_binary(input_format_t::msgpack, len, result); |
| 9245 | } |
| 9246 | |
| 9247 | case 0xC5: // bin 16 |
| 9248 | { |
| 9249 | std::uint16_t len{}; |
| 9250 | return get_number(input_format_t::msgpack, len) && |
| 9251 | get_binary(input_format_t::msgpack, len, result); |
| 9252 | } |
| 9253 | |
| 9254 | case 0xC6: // bin 32 |
| 9255 | { |
| 9256 | std::uint32_t len{}; |
| 9257 | return get_number(input_format_t::msgpack, len) && |
| 9258 | get_binary(input_format_t::msgpack, len, result); |
| 9259 | } |
| 9260 | |
| 9261 | case 0xC7: // ext 8 |
| 9262 | { |
| 9263 | std::uint8_t len{}; |
| 9264 | std::int8_t subtype{}; |
| 9265 | return get_number(input_format_t::msgpack, len) && |
| 9266 | get_number(input_format_t::msgpack, subtype) && |
| 9267 | get_binary(input_format_t::msgpack, len, result) && |
| 9268 | assign_and_return_true(subtype); |
| 9269 | } |
| 9270 | |
| 9271 | case 0xC8: // ext 16 |
| 9272 | { |
| 9273 | std::uint16_t len{}; |
| 9274 | std::int8_t subtype{}; |
| 9275 | return get_number(input_format_t::msgpack, len) && |
| 9276 | get_number(input_format_t::msgpack, subtype) && |
| 9277 | get_binary(input_format_t::msgpack, len, result) && |
| 9278 | assign_and_return_true(subtype); |
| 9279 | } |
| 9280 | |
| 9281 | case 0xC9: // ext 32 |
| 9282 | { |
| 9283 | std::uint32_t len{}; |
| 9284 | std::int8_t subtype{}; |
| 9285 | return get_number(input_format_t::msgpack, len) && |
| 9286 | get_number(input_format_t::msgpack, subtype) && |
nothing calls this directly
no test coverage detected