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

Method parse_string

src/toml.hpp:13799–13839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13797 TOML_NODISCARD
13798 TOML_NEVER_INLINE
13799 parsed_string parse_string()
13800 {
13801 return_if_error({});
13802 assert_not_eof();
13803 TOML_ASSERT_ASSUME(is_string_delimiter(*cp));
13804 push_parse_scope("string"sv);
13805
13806 // get the first three characters to determine the string type
13807 const auto first = cp->value;
13808 advance_and_return_if_error_or_eof({});
13809 const auto second = cp->value;
13810 advance_and_return_if_error({});
13811 const auto third = cp ? cp->value : U'\0';
13812
13813 // if we were eof at the third character then first and second need to be
13814 // the same string character (otherwise it's an unterminated string)
13815 if (is_eof())
13816 {
13817 if (second == first)
13818 return {};
13819
13820 set_error_and_return_default("encountered end-of-file"sv);
13821 }
13822
13823 // if the first three characters are all the same string delimiter then
13824 // it's a multi-line string.
13825 else if (first == second && first == third)
13826 {
13827 return { first == U'\'' ? parse_literal_string(true) : parse_basic_string(true), true };
13828 }
13829
13830 // otherwise it's just a regular string.
13831 else
13832 {
13833 // step back two characters so that the current
13834 // character is the string delimiter
13835 go_back(2u);
13836
13837 return { first == U'\'' ? parse_literal_string(false) : parse_basic_string(false), false };
13838 }
13839 }
13840
13841 TOML_NODISCARD
13842 TOML_NEVER_INLINE

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected