MCPcopy Create free account
hub / github.com/3DBAG/roofer / parse_basic_string

Method parse_basic_string

apps/external/toml.hpp:12155–12392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12153 TOML_NODISCARD
12154 TOML_NEVER_INLINE
12155 std::string_view parse_basic_string(bool multi_line) {
12156 return_if_error({});
12157 assert_not_eof();
12158 TOML_ASSERT_ASSUME(*cp == U'"');
12159 push_parse_scope("string"sv);
12160
12161 // skip the '"'
12162 advance_and_return_if_error_or_eof({});
12163
12164 // multi-line strings ignore a single line ending right at the beginning
12165 if (multi_line) {
12166 consume_line_break();
12167 return_if_error({});
12168 set_error_and_return_if_eof({});
12169 }
12170
12171 auto& str = string_buffer;
12172 str.clear();
12173 bool escaped = false;
12174 bool skipping_whitespace = false;
12175 do {
12176 if (escaped) {
12177 escaped = false;
12178
12179 // handle 'line ending slashes' in multi-line mode
12180 if (multi_line && is_whitespace(*cp)) {
12181 consume_leading_whitespace();
12182
12183 if TOML_UNLIKELY (!consume_line_break())
12184 set_error_and_return_default(
12185 "line-ending backslashes must be the last non-whitespace character on the line"sv);
12186
12187 skipping_whitespace = true;
12188 return_if_error({});
12189 continue;
12190 }
12191
12192 bool skip_escaped_codepoint = true;
12193 assert_not_eof();
12194 switch (const auto escaped_codepoint = *cp) {
12195 // 'regular' escape codes
12196 case U'b':
12197 str += '\b';
12198 break;
12199 case U'f':
12200 str += '\f';
12201 break;
12202 case U'n':
12203 str += '\n';
12204 break;
12205 case U'r':
12206 str += '\r';
12207 break;
12208 case U't':
12209 str += '\t';
12210 break;
12211 case U'"':
12212 str += '"';

Callers

nothing calls this directly

Calls 3

appendMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected