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.
9397 {
9398 if (JSON_HEDLEY_UNLIKELY(!
unexpect_eof(input_format_t::cbor,
"binary")))
9399 {
9400 return false;
9401 }
9402
9404 {
9405
9406 case 0x40:
9407 case 0x41:
9408 case 0x42:
9409 case 0x43:
9410 case 0x44:
9411 case 0x45:
9412 case 0x46:
9413 case 0x47:
9414 case 0x48:
9415 case 0x49:
9416 case 0x4A:
9417 case 0x4B:
9418 case 0x4C:
9419 case 0x4D:
9420 case 0x4E:
9421 case 0x4F:
9422 case 0x50:
9423 case 0x51:
9424 case 0x52:
9425 case 0x53:
9426 case 0x54:
9427 case 0x55:
9428 case 0x56:
9429 case 0x57:
9430 {
9431 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(
current) & 0x1Fu, result);
9432 }
9433
9434 case 0x58:
9435 {
9436 std::uint8_t len{};
9437 return get_number(input_format_t::cbor, len) &&
9438 get_binary(input_format_t::cbor, len, result);
9439 }
9440
9441 case 0x59:
9442 {
9443 std::uint16_t len{};
9444 return get_number(input_format_t::cbor, len) &&
9445 get_binary(input_format_t::cbor, len, result);
9446 }
9447
9448 case 0x5A:
9449 {
9450 std::uint32_t len{};
9451 return get_number(input_format_t::cbor, len) &&
9452 get_binary(input_format_t::cbor, len, result);
9453 }
9454
9455 case 0x5B:
9456 {
9457 std::uint64_t len{};
9458 return get_number(input_format_t::cbor, len) &&
9459 get_binary(input_format_t::cbor, len, result);
9460 }
9461
9462 case 0x5F:
9463 {
9464 while (
get() != 0xFF)
9465 {
9466 binary_t chunk;
9467
9469 {
9470 return false;
9471 }
9472
9473 result.insert(result.end(), chunk.begin(), chunk.end());
9474 }
9475
9476 return true;
9477 }
9478
9479 default:
9480 {
9483 }
9484 }
9485 }
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
bool unexpect_eof(const input_format_t format, const char *context) const
std::string get_token_string() const
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
std::size_t chars_read
the number of characters read
char_int_type current
the current character
json_sax_t * sax
the SAX parser
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
char_int_type get()
get next character from the input
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception