MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / get_cbor_binary

Method get_cbor_binary

lesson6-Segmentation/json.hpp:8582–8668  ·  view source on GitHub ↗

! @brief reads a CBOR byte array This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into the byte array. Additionally, CBOR's byte arrays with indefinite lengths are supported. @param[out] result created byte array @return whether byte array creation completed */

Source from the content-addressed store, hash-verified

8580 @return whether byte array creation completed
8581 */
8582 bool get_cbor_binary(binary_t& result)
8583 {
8584 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary")))
8585 {
8586 return false;
8587 }
8588
8589 switch (current)
8590 {
8591 // Binary data (0x00..0x17 bytes follow)
8592 case 0x40:
8593 case 0x41:
8594 case 0x42:
8595 case 0x43:
8596 case 0x44:
8597 case 0x45:
8598 case 0x46:
8599 case 0x47:
8600 case 0x48:
8601 case 0x49:
8602 case 0x4A:
8603 case 0x4B:
8604 case 0x4C:
8605 case 0x4D:
8606 case 0x4E:
8607 case 0x4F:
8608 case 0x50:
8609 case 0x51:
8610 case 0x52:
8611 case 0x53:
8612 case 0x54:
8613 case 0x55:
8614 case 0x56:
8615 case 0x57:
8616 {
8617 return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
8618 }
8619
8620 case 0x58: // Binary data (one-byte uint8_t for n follows)
8621 {
8622 std::uint8_t len{};
8623 return get_number(input_format_t::cbor, len) &&
8624 get_binary(input_format_t::cbor, len, result);
8625 }
8626
8627 case 0x59: // Binary data (two-byte uint16_t for n follow)
8628 {
8629 std::uint16_t len{};
8630 return get_number(input_format_t::cbor, len) &&
8631 get_binary(input_format_t::cbor, len, result);
8632 }
8633
8634 case 0x5A: // Binary data (four-byte uint32_t for n follow)
8635 {
8636 std::uint32_t len{};
8637 return get_number(input_format_t::cbor, len) &&
8638 get_binary(input_format_t::cbor, len, result);
8639 }

Callers

nothing calls this directly

Calls 7

getFunction · 0.85
get_token_stringFunction · 0.85
createFunction · 0.85
insertMethod · 0.80
endMethod · 0.80
beginMethod · 0.80
parse_errorMethod · 0.45

Tested by

no test coverage detected