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

Method get_ubjson_string

dependencies/json/json.hpp:9487–9535  ·  view source on GitHub ↗

! @brief reads a UBJSON string This function is either called after reading the 'S' byte explicitly indicating a string, or in case of an object key where the 'S' byte can be left out. @param[out] result created string @param[in] get_char whether a new character should be retrieved from the input (true, default) or whether the last read

Source from the content-addressed store, hash-verified

9485 @return whether string creation completed
9486 */
9487 bool get_ubjson_string(string_t& result, const bool get_char = true)
9488 {
9489 if (get_char)
9490 {
9491 get(); // TODO(niels): may we ignore N here?
9492 }
9493
9494 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value")))
9495 {
9496 return false;
9497 }
9498
9499 switch (current)
9500 {
9501 case 'U':
9502 {
9503 std::uint8_t len{};
9504 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9505 }
9506
9507 case 'i':
9508 {
9509 std::int8_t len{};
9510 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9511 }
9512
9513 case 'I':
9514 {
9515 std::int16_t len{};
9516 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9517 }
9518
9519 case 'l':
9520 {
9521 std::int32_t len{};
9522 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9523 }
9524
9525 case 'L':
9526 {
9527 std::int64_t len{};
9528 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9529 }
9530
9531 default:
9532 auto last_token = get_token_string();
9533 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string")));
9534 }
9535 }
9536
9537 /*!
9538 @param[out] result determined size

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected