MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / parseOneof

Method parseOneof

app/src/DataModel/Importers/ProtoImporter.cpp:446–465  ·  view source on GitHub ↗

* @brief Parses a `oneof Name { fields }` block; fields are appended as plain fields. */

Source from the content-addressed store, hash-verified

444 * @brief Parses a `oneof Name { fields }` block; fields are appended as plain fields.
445 */
446bool Parser::parseOneof(DataModel::ProtoMessage& msg, ParseError& err)
447{
448 if (m_cur.type != Tok::Ident) {
449 err = {m_cur.line, QObject::tr("Expected oneof name")};
450 return false;
451 }
452 advance();
453 if (!expect(Tok::LBrace, QStringLiteral("'{'"), err))
454 return false;
455
456 while (m_cur.type != Tok::Eof && m_cur.type != Tok::RBrace) {
457 if (m_cur.type == Tok::Ident && m_cur.text == QLatin1String("option")) {
458 skipToSemicolon();
459 continue;
460 }
461 if (!parseField(msg, err))
462 return false;
463 }
464 return expect(Tok::RBrace, QStringLiteral("'}'"), err);
465}
466
467/**
468 * @brief Reads the current IntLit token as a protobuf field tag and validates its range.

Callers

nothing calls this directly

Calls 1

expectFunction · 0.85

Tested by

no test coverage detected