TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ get_ubjson_string()

template<typename BasicJsonType , typename InputAdapterType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_string ( string_t &  result,
const bool  get_char = true 
)
inlineprivate

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.

Parameters
[out]resultcreated string
[in]get_charwhether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead
Returns
whether string creation completed

Definition at line 10247 of file json.hpp.

10248 {
10249 if (get_char)
10250 {
10251 get(); // TODO(niels): may we ignore N here?
10252 }
10253
10254 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value")))
10255 {
10256 return false;
10257 }
10258
10259 switch (current)
10260 {
10261 case 'U':
10262 {
10263 std::uint8_t len{};
10264 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
10265 }
10266
10267 case 'i':
10268 {
10269 std::int8_t len{};
10270 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
10271 }
10272
10273 case 'I':
10274 {
10275 std::int16_t len{};
10276 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
10277 }
10278
10279 case 'l':
10280 {
10281 std::int32_t len{};
10282 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
10283 }
10284
10285 case 'L':
10286 {
10287 std::int64_t len{};
10288 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
10289 }
10290
10291 default:
10292 auto last_token = get_token_string();
10293 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"), BasicJsonType()));
10294 }
10295 }
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:10849
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:10914
std::string get_token_string() const
Definition: json.hpp:10928
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:10941
std::size_t chars_read
the number of characters read
Definition: json.hpp:10981
char_int_type current
the current character
Definition: json.hpp:10978
json_sax_t * sax
the SAX parser
Definition: json.hpp:10987
char_int_type get()
get next character from the input
Definition: json.hpp:10769
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
Definition: json.hpp:2800