SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
externalcolumnfilecore.h File Reference

Multi-column series file (CSV/TSV/TSF) — pure-C++ parsing core. More...

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
Include dependency graph for externalcolumnfilecore.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmmvis::ui::extcol::DateTimeParts
 Calendar components produced by parseSeriesDateTime(). More...
 

Namespaces

namespace  openswmmvis
 
namespace  openswmmvis::ui
 
namespace  openswmmvis::ui::extcol
 

Functions

std::string openswmmvis::ui::extcol::cellTrim (const std::string &s)
 Trim ASCII whitespace and one surrounding pair of double quotes. Mirrors the engine's cell_trim.
 
std::vector< std::string > openswmmvis::ui::extcol::splitCells (const std::string &line, char delim)
 Quote-aware split on a single-character delimiter (engine cell_split).
 
bool openswmmvis::ui::extcol::iequals (const std::string &a, const std::string &b)
 Case-insensitive equality (engine csv_iequals).
 
void openswmmvis::ui::extcol::normalizeLine (std::string &line, bool firstLine)
 Strip a UTF-8 BOM (first line only) and a trailing '\r'.
 
bool openswmmvis::ui::extcol::isBlankOrComment (const std::string &line)
 True for empty/all-whitespace lines and ';'/'#' comment lines.
 
bool openswmmvis::ui::extcol::isTsfHeader (const std::string &line)
 True when the (normalized) line starts a PCSWMM .tsf header — case-insensitive "IDs:" prefix, per the engine's format sniff.
 
char openswmmvis::ui::extcol::sniffDelimiter (const std::string &headerLine)
 Sniff the cell delimiter from the header row. The engine rule is "tab when tabs > 0 and tabs >= commas, else comma"; the GUI additionally recognizes semicolon-delimited files (io::guessDelimiter), so that extension is preserved here — the two agree on every engine-loadable file.
 
int openswmmvis::ui::extcol::trailingMeridiem (const std::string &cell)
 0 = none, 1 = AM, 2 = PM — from the cell's trailing token (engine trailing_meridiem).
 
bool openswmmvis::ui::extcol::parseSeriesDateTime (const std::string &cell, DateTimeParts &out)
 Parse a series timestamp cell into calendar components.
 
void openswmmvis::ui::extcol::splitPathColumn (const std::string &token, std::string &pathOut, std::string &columnOut)
 Split a "path[:column]" token into its parts.
 
std::string openswmmvis::ui::extcol::composePathColumn (const std::string &path, const std::string &column)
 Compose the "path:column" token (empty column → bare path). The GUI always builds this token itself — the user never types the colon.
 
int openswmmvis::ui::extcol::findColumn (const std::vector< std::string > &valueHeaders, const std::string &name)
 Resolve a column selector against a value-column name list (0-based, time column excluded). Case-insensitive, mirroring the engine's find_column. Returns -1 when name matches nothing.
 
std::string openswmmvis::ui::extcol::fabricatedColumnName (std::size_t oneBasedIndex)
 Display name the GUI shows for value column oneBasedIndex of a headerless file. Single definition of the convention.
 

Detailed Description

Multi-column series file (CSV/TSV/TSF) — pure-C++ parsing core.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026
License\n GPL-3.0-or-later

Header-only, deliberately Qt-free so the format rules can be compiled and exercised standalone (tests/standalone_externalcolumn/) and shared by non-widget code (TimeseriesRegistry's path:col token handling). The Qt wrapper lives in ui/util/externalcolumnfile.{h,cpp}.

Every rule here mirrors the engine so the GUI preview and the run agree:

  • TSF detection / cell handling: openswmm.engine src/engine/input/MultiColumnSeriesFile.cpp (istarts_with "IDs:", quote-aware tab/comma split, BOM + '\r' strip, ';'/'#' comments).
  • Datetime grammar: MultiColumnSeriesFile.cpp parse_series_datetime (ISO-8601, US M/D/Y, optional trailing AM/PM as used by PCSWMM .tsf).
  • path:col split: the unified last-colon rule now shared by both engine readers (CatchmentHandler.cpp readGage FILE token and PostParseResolver.cpp's timeseries token) — see splitPathColumn(). Delimiter sniffing keeps the GUI's semicolon extension on top of the engine's tab-vs-comma rule, and skips quoted regions like the cell splitter (see sniffDelimiter()).