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

Method parse_table_header

src/toml.hpp:15232–15454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15230 TOML_NODISCARD
15231 TOML_NEVER_INLINE
15232 table* parse_table_header()
15233 {
15234 return_if_error({});
15235 assert_not_eof();
15236 TOML_ASSERT_ASSUME(*cp == U'[');
15237 push_parse_scope("table header"sv);
15238
15239 const source_position header_begin_pos = cp->position;
15240 source_position header_end_pos;
15241 bool is_arr = false;
15242
15243 // parse header
15244 {
15245 // skip first '['
15246 advance_and_return_if_error_or_eof({});
15247
15248 // skip past any whitespace that followed the '['
15249 const bool had_leading_whitespace = consume_leading_whitespace();
15250 set_error_and_return_if_eof({});
15251
15252 // skip second '[' (if present)
15253 if (*cp == U'[')
15254 {
15255 if (had_leading_whitespace)
15256 set_error_and_return_default(
15257 "[[array-of-table]] brackets must be contiguous (i.e. [ [ this ] ] is prohibited)"sv);
15258
15259 is_arr = true;
15260 advance_and_return_if_error_or_eof({});
15261
15262 // skip past any whitespace that followed the '['
15263 consume_leading_whitespace();
15264 set_error_and_return_if_eof({});
15265 }
15266
15267 // check for a premature closing ']'
15268 if (*cp == U']')
15269 set_error_and_return_default("tables with blank bare keys are explicitly prohibited"sv);
15270
15271 // get the actual key
15272 start_recording();
15273 parse_key();
15274 stop_recording(1u);
15275 return_if_error({});
15276
15277 // skip past any whitespace that followed the key
15278 consume_leading_whitespace();
15279 return_if_error({});
15280 set_error_and_return_if_eof({});
15281
15282 // consume the closing ']'
15283 if (*cp != U']')
15284 set_error_and_return_default("expected ']', saw '"sv, to_sv(*cp), "'"sv);
15285 if (is_arr)
15286 {
15287 advance_and_return_if_error_or_eof({});
15288 if (*cp != U']')
15289 set_error_and_return_default("expected ']', saw '"sv, to_sv(*cp), "'"sv);

Callers

nothing calls this directly

Calls 5

findFunction · 0.85
moveFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected