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

Method get_ubjson_string

lesson6-Segmentation/json.hpp:9418–9466  ·  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

9416 @return whether string creation completed
9417 */
9418 bool get_ubjson_string(string_t& result, const bool get_char = true)
9419 {
9420 if (get_char)
9421 {
9422 get(); // TODO(niels): may we ignore N here?
9423 }
9424
9425 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value")))
9426 {
9427 return false;
9428 }
9429
9430 switch (current)
9431 {
9432 case 'U':
9433 {
9434 std::uint8_t len{};
9435 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9436 }
9437
9438 case 'i':
9439 {
9440 std::int8_t len{};
9441 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9442 }
9443
9444 case 'I':
9445 {
9446 std::int16_t len{};
9447 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9448 }
9449
9450 case 'l':
9451 {
9452 std::int32_t len{};
9453 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9454 }
9455
9456 case 'L':
9457 {
9458 std::int64_t len{};
9459 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9460 }
9461
9462 default:
9463 auto last_token = get_token_string();
9464 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")));
9465 }
9466 }
9467
9468 /*!
9469 @param[out] result determined size

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