MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / get_ubjson_string

Method get_ubjson_string

native/thirdpart/json/json.hpp:6534–6582  ·  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

6532 @return whether string creation completed
6533 */
6534 bool get_ubjson_string(string_t& result, const bool get_char = true)
6535 {
6536 if (get_char)
6537 {
6538 get(); // TODO(niels): may we ignore N here?
6539 }
6540
6541 if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value")))
6542 {
6543 return false;
6544 }
6545
6546 switch (current)
6547 {
6548 case 'U':
6549 {
6550 std::uint8_t len;
6551 return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6552 }
6553
6554 case 'i':
6555 {
6556 std::int8_t len;
6557 return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6558 }
6559
6560 case 'I':
6561 {
6562 std::int16_t len;
6563 return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6564 }
6565
6566 case 'l':
6567 {
6568 std::int32_t len;
6569 return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6570 }
6571
6572 case 'L':
6573 {
6574 std::int64_t len;
6575 return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6576 }
6577
6578 default:
6579 auto last_token = get_token_string();
6580 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")));
6581 }
6582 }
6583
6584 /*!
6585 @param[out] result determined size

Callers

nothing calls this directly

Calls 3

getFunction · 0.85
createFunction · 0.85
parse_errorMethod · 0.45

Tested by

no test coverage detected