MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / get_cbor_string

Method get_cbor_string

Source/Utils/json.hpp:8486–8568  ·  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

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

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