MCPcopy Create free account
hub / github.com/dobin/RedEdr / get_msgpack_binary

Method get_msgpack_binary

RedEdrShared/json.hpp:10836–10941  ·  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

10834 @return whether byte array creation completed
10835 */
10836 bool get_msgpack_binary(binary_t& result)
10837 {
10838 // helper function to set the subtype
10839 auto assign_and_return_true = [&result](std::int8_t subtype)
10840 {
10841 result.set_subtype(static_cast<std::uint8_t>(subtype));
10842 return true;
10843 };
10844
10845 switch (current)
10846 {
10847 case 0xC4: // bin 8
10848 {
10849 std::uint8_t len{};
10850 return get_number(input_format_t::msgpack, len) &&
10851 get_binary(input_format_t::msgpack, len, result);
10852 }
10853
10854 case 0xC5: // bin 16
10855 {
10856 std::uint16_t len{};
10857 return get_number(input_format_t::msgpack, len) &&
10858 get_binary(input_format_t::msgpack, len, result);
10859 }
10860
10861 case 0xC6: // bin 32
10862 {
10863 std::uint32_t len{};
10864 return get_number(input_format_t::msgpack, len) &&
10865 get_binary(input_format_t::msgpack, len, result);
10866 }
10867
10868 case 0xC7: // ext 8
10869 {
10870 std::uint8_t len{};
10871 std::int8_t subtype{};
10872 return get_number(input_format_t::msgpack, len) &&
10873 get_number(input_format_t::msgpack, subtype) &&
10874 get_binary(input_format_t::msgpack, len, result) &&
10875 assign_and_return_true(subtype);
10876 }
10877
10878 case 0xC8: // ext 16
10879 {
10880 std::uint16_t len{};
10881 std::int8_t subtype{};
10882 return get_number(input_format_t::msgpack, len) &&
10883 get_number(input_format_t::msgpack, subtype) &&
10884 get_binary(input_format_t::msgpack, len, result) &&
10885 assign_and_return_true(subtype);
10886 }
10887
10888 case 0xC9: // ext 32
10889 {
10890 std::uint32_t len{};
10891 std::int8_t subtype{};
10892 return get_number(input_format_t::msgpack, len) &&
10893 get_number(input_format_t::msgpack, subtype) &&

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected