![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Multi-delimiter tokenizer for SWMM input files. More...
#include <string>#include <string_view>#include <vector>Go to the source code of this file.
Classes | |
| class | openswmm::input::Tokenizer |
| Stateless multi-delimiter tokenizer for SWMM input lines. More... | |
Namespaces | |
| namespace | openswmm |
| namespace | openswmm::input |
Multi-delimiter tokenizer for SWMM input files.
Replaces the legacy space-only tokenizer in src/solver/input.c. Whitespace always delimits; a comma delimits only where it cannot be part of a name. This allows input files to be formatted as:
The comma rule is positional, not dialect-wide, because the two readings genuinely collide. Legacy splits on " \t\n\r" only, so a comma is an ordinary name character — and real decks depend on it: S-2-M20-L109/link2,6-201-9(u) is ONE subcatchment outlet. Treating every comma as a delimiter truncated that reference, read the name fragment after it as the subcatchment's area, and produced a trailing token the legacy reader then rejected as an undefined object.
So: a comma separates when it sits at a token boundary — adjacent to whitespace or at a line edge — or when the line carries no whitespace at all outside quotes and is therefore pure CSV. A comma with non-whitespace on both sides, in an otherwise whitespace-delimited line, belongs to its token. A value that genuinely contains a comma AND sits in a CSV row must be quoted, which is the ordinary CSV convention.
| Feature | Legacy (input.c) | New Tokenizer |
|---|---|---|
| Delimiters | Space, tab, CR/LF | Same, plus comma at a token boundary |
| Comment char | ; (semicolon) | ; or ;; |
| Quoted strings | Filenames only | Whole tokens or embedded key="value" (double-quotes) |
| Performance | sscanf-based | Reusable view vector avoids per-token copies |