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

Method buildTableNames

app/src/DataModel/Importers/DBCImporter.cpp:387–406  ·  view source on GitHub ↗

* @brief Assigns one collision-free data-table name per message (the message name, with the * frame id appended when a DBC reuses a name). */

Source from the content-addressed store, hash-verified

385 * frame id appended when a DBC reuses a name).
386 */
387void DataModel::DBCImporter::buildTableNames(const QList<QCanMessageDescription>& messages)
388{
389 m_tableNames.clear();
390
391 QSet<QString> used;
392 for (const auto& message : messages) {
393 const auto id = static_cast<quint32>(message.uniqueId()) & 0x1FFFFFFF;
394 const auto hex = QString::number(id, 16).toUpper();
395
396 QString name = message.name().simplified();
397 if (name.isEmpty())
398 name = QStringLiteral("Message 0x%1").arg(hex);
399
400 if (used.contains(name))
401 name += QStringLiteral(" @ 0x%1").arg(hex);
402
403 used.insert(name);
404 m_tableNames.insert(id, name);
405 }
406}
407
408/**
409 * @brief Returns the data-table name assigned to the message by buildTableNames().

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
clearMethod · 0.45
nameMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected