MCPcopy Create free account
hub / github.com/InkboxSoftware/all-screen-keyboard / get_msgpack_binary

Method get_msgpack_binary

keyboard/src/json.hpp:11506–11611  ·  view source on GitHub ↗

! @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 */

Source from the content-addressed store, hash-verified

11504 @return whether byte array creation completed
11505 */
11506 bool get_msgpack_binary(binary_t& result)
11507 {
11508 // helper function to set the subtype
11509 auto assign_and_return_true = [&result](std::int8_t subtype)
11510 {
11511 result.set_subtype(static_cast<std::uint8_t>(subtype));
11512 return true;
11513 };
11514
11515 switch (current)
11516 {
11517 case 0xC4: // bin 8
11518 {
11519 std::uint8_t len{};
11520 return get_number(input_format_t::msgpack, len) &&
11521 get_binary(input_format_t::msgpack, len, result);
11522 }
11523
11524 case 0xC5: // bin 16
11525 {
11526 std::uint16_t len{};
11527 return get_number(input_format_t::msgpack, len) &&
11528 get_binary(input_format_t::msgpack, len, result);
11529 }
11530
11531 case 0xC6: // bin 32
11532 {
11533 std::uint32_t len{};
11534 return get_number(input_format_t::msgpack, len) &&
11535 get_binary(input_format_t::msgpack, len, result);
11536 }
11537
11538 case 0xC7: // ext 8
11539 {
11540 std::uint8_t len{};
11541 std::int8_t subtype{};
11542 return get_number(input_format_t::msgpack, len) &&
11543 get_number(input_format_t::msgpack, subtype) &&
11544 get_binary(input_format_t::msgpack, len, result) &&
11545 assign_and_return_true(subtype);
11546 }
11547
11548 case 0xC8: // ext 16
11549 {
11550 std::uint16_t len{};
11551 std::int8_t subtype{};
11552 return get_number(input_format_t::msgpack, len) &&
11553 get_number(input_format_t::msgpack, subtype) &&
11554 get_binary(input_format_t::msgpack, len, result) &&
11555 assign_and_return_true(subtype);
11556 }
11557
11558 case 0xC9: // ext 32
11559 {
11560 std::uint32_t len{};
11561 std::int8_t subtype{};
11562 return get_number(input_format_t::msgpack, len) &&
11563 get_number(input_format_t::msgpack, subtype) &&

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected