MCPcopy Create free account
hub / github.com/KTH-RPL/dufomap / parse_basic_string

Method parse_basic_string

src/toml.hpp:13454–13692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13452 TOML_NODISCARD
13453 TOML_NEVER_INLINE
13454 std::string_view parse_basic_string(bool multi_line)
13455 {
13456 return_if_error({});
13457 assert_not_eof();
13458 TOML_ASSERT_ASSUME(*cp == U'"');
13459 push_parse_scope("string"sv);
13460
13461 // skip the '"'
13462 advance_and_return_if_error_or_eof({});
13463
13464 // multi-line strings ignore a single line ending right at the beginning
13465 if (multi_line)
13466 {
13467 consume_line_break();
13468 return_if_error({});
13469 set_error_and_return_if_eof({});
13470 }
13471
13472 auto& str = string_buffer;
13473 str.clear();
13474 bool escaped = false;
13475 bool skipping_whitespace = false;
13476 do
13477 {
13478 if (escaped)
13479 {
13480 escaped = false;
13481
13482 // handle 'line ending slashes' in multi-line mode
13483 if (multi_line && is_whitespace(*cp))
13484 {
13485 consume_leading_whitespace();
13486
13487 if TOML_UNLIKELY(!consume_line_break())
13488 set_error_and_return_default(
13489 "line-ending backslashes must be the last non-whitespace character on the line"sv);
13490
13491 skipping_whitespace = true;
13492 return_if_error({});
13493 continue;
13494 }
13495
13496 bool skip_escaped_codepoint = true;
13497 assert_not_eof();
13498 switch (const auto escaped_codepoint = *cp)
13499 {
13500 // 'regular' escape codes
13501 case U'b': str += '\b'; break;
13502 case U'f': str += '\f'; break;
13503 case U'n': str += '\n'; break;
13504 case U'r': str += '\r'; break;
13505 case U't': str += '\t'; break;
13506 case U'"': str += '"'; break;
13507 case U'\\': str += '\\'; break;
13508
13509#if TOML_LANG_UNRELEASED // toml/pull/790 (\e shorthand for \x1B)
13510 case U'e': str += '\x1B'; break;
13511#else

Callers

nothing calls this directly

Calls 3

appendMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected