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

Method get_cbor_string

lesson6-Segmentation/json.hpp:8487–8569  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

8485 @return whether string creation completed
8486 */
8487 bool get_cbor_string(string_t& result)
8488 {
8489 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string")))
8490 {
8491 return false;
8492 }
8493
8494 switch (current)
8495 {
8496 // UTF-8 string (0x00..0x17 bytes follow)
8497 case 0x60:
8498 case 0x61:
8499 case 0x62:
8500 case 0x63:
8501 case 0x64:
8502 case 0x65:
8503 case 0x66:
8504 case 0x67:
8505 case 0x68:
8506 case 0x69:
8507 case 0x6A:
8508 case 0x6B:
8509 case 0x6C:
8510 case 0x6D:
8511 case 0x6E:
8512 case 0x6F:
8513 case 0x70:
8514 case 0x71:
8515 case 0x72:
8516 case 0x73:
8517 case 0x74:
8518 case 0x75:
8519 case 0x76:
8520 case 0x77:
8521 {
8522 return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
8523 }
8524
8525 case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
8526 {
8527 std::uint8_t len{};
8528 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8529 }
8530
8531 case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
8532 {
8533 std::uint16_t len{};
8534 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8535 }
8536
8537 case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
8538 {
8539 std::uint32_t len{};
8540 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8541 }
8542
8543 case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
8544 {

Callers

nothing calls this directly

Calls 4

getFunction · 0.85
get_token_stringFunction · 0.85
createFunction · 0.85
parse_errorMethod · 0.45

Tested by

no test coverage detected