MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / get_cbor_string

Method get_cbor_string

dependencies/json/json.hpp:8556–8638  ·  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

8554 @return whether string creation completed
8555 */
8556 bool get_cbor_string(string_t& result)
8557 {
8558 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string")))
8559 {
8560 return false;
8561 }
8562
8563 switch (current)
8564 {
8565 // UTF-8 string (0x00..0x17 bytes follow)
8566 case 0x60:
8567 case 0x61:
8568 case 0x62:
8569 case 0x63:
8570 case 0x64:
8571 case 0x65:
8572 case 0x66:
8573 case 0x67:
8574 case 0x68:
8575 case 0x69:
8576 case 0x6A:
8577 case 0x6B:
8578 case 0x6C:
8579 case 0x6D:
8580 case 0x6E:
8581 case 0x6F:
8582 case 0x70:
8583 case 0x71:
8584 case 0x72:
8585 case 0x73:
8586 case 0x74:
8587 case 0x75:
8588 case 0x76:
8589 case 0x77:
8590 {
8591 return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
8592 }
8593
8594 case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
8595 {
8596 std::uint8_t len{};
8597 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8598 }
8599
8600 case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
8601 {
8602 std::uint16_t len{};
8603 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8604 }
8605
8606 case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
8607 {
8608 std::uint32_t len{};
8609 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8610 }
8611
8612 case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
8613 {

Callers

nothing calls this directly

Calls 5

getFunction · 0.70
get_token_stringFunction · 0.70
createFunction · 0.70
appendMethod · 0.45
parse_errorMethod · 0.45

Tested by

no test coverage detected