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

Method parseCsvRows

app/src/CSV/Player.cpp:290–311  ·  view source on GitHub ↗

* @brief Reads CSV rows from the stream into m_csvData up to kMaxCsvRows. */

Source from the content-addressed store, hash-verified

288 * @brief Reads CSV rows from the stream into m_csvData up to kMaxCsvRows.
289 */
290void CSV::Player::parseCsvRows(QTextStream& stream)
291{
292 Q_ASSERT(stream.device() != nullptr);
293 Q_ASSERT(stream.device()->isOpen());
294
295 constexpr int kMaxCsvRows = 10'000'000;
296
297 while (!stream.atEnd() && m_csvData.size() < kMaxCsvRows) {
298 const QString line = stream.readLine();
299 QStringList row = DataModel::splitReplayRow(line);
300
301 bool isRowValid =
302 !row.isEmpty()
303 && std::any_of(row.cbegin(), row.cend(), [](const QString& item) { return !item.isEmpty(); });
304
305 if (isRowValid)
306 m_csvData.append(row);
307 }
308
309 if (m_csvData.size() >= kMaxCsvRows) [[unlikely]]
310 qWarning() << "[CSV::Player] Row limit reached:" << kMaxCsvRows << "-- file may be truncated";
311}
312
313/**
314 * @brief Detects the CSV timestamp format and initializes the cache.

Callers

nothing calls this directly

Calls 7

isEmptyMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
isOpenMethod · 0.45
atEndMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected