* @brief Reads CSV rows from the stream into m_csvData up to kMaxCsvRows. */
| 288 | * @brief Reads CSV rows from the stream into m_csvData up to kMaxCsvRows. |
| 289 | */ |
| 290 | void 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. |