MCPcopy Create free account
hub / github.com/aixed/WeChat-Hook / get_msgpack_binary

Method get_msgpack_binary

include/json/json.hpp:10651–10756  ·  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

10649 @return whether byte array creation completed
10650 */
10651 bool get_msgpack_binary(binary_t& result)
10652 {
10653 // helper function to set the subtype
10654 auto assign_and_return_true = [&result](std::int8_t subtype)
10655 {
10656 result.set_subtype(static_cast<std::uint8_t>(subtype));
10657 return true;
10658 };
10659
10660 switch (current)
10661 {
10662 case 0xC4: // bin 8
10663 {
10664 std::uint8_t len{};
10665 return get_number(input_format_t::msgpack, len) &&
10666 get_binary(input_format_t::msgpack, len, result);
10667 }
10668
10669 case 0xC5: // bin 16
10670 {
10671 std::uint16_t len{};
10672 return get_number(input_format_t::msgpack, len) &&
10673 get_binary(input_format_t::msgpack, len, result);
10674 }
10675
10676 case 0xC6: // bin 32
10677 {
10678 std::uint32_t len{};
10679 return get_number(input_format_t::msgpack, len) &&
10680 get_binary(input_format_t::msgpack, len, result);
10681 }
10682
10683 case 0xC7: // ext 8
10684 {
10685 std::uint8_t len{};
10686 std::int8_t subtype{};
10687 return get_number(input_format_t::msgpack, len) &&
10688 get_number(input_format_t::msgpack, subtype) &&
10689 get_binary(input_format_t::msgpack, len, result) &&
10690 assign_and_return_true(subtype);
10691 }
10692
10693 case 0xC8: // ext 16
10694 {
10695 std::uint16_t len{};
10696 std::int8_t subtype{};
10697 return get_number(input_format_t::msgpack, len) &&
10698 get_number(input_format_t::msgpack, subtype) &&
10699 get_binary(input_format_t::msgpack, len, result) &&
10700 assign_and_return_true(subtype);
10701 }
10702
10703 case 0xC9: // ext 32
10704 {
10705 std::uint32_t len{};
10706 std::int8_t subtype{};
10707 return get_number(input_format_t::msgpack, len) &&
10708 get_number(input_format_t::msgpack, subtype) &&

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected