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