OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
SectionParser.hpp
Go to the documentation of this file.
1
19#pragma once
20
21#include <string>
22#include <vector>
23
24namespace openswmm::input {
25
35struct ParsedLine {
36 std::string data;
37 std::string comment;
38};
39
58inline std::vector<ParsedLine>
59parse_section(const std::vector<std::string>& raw_lines)
60{
61 std::vector<ParsedLine> result;
62 std::string pending;
63
64 for (const auto& raw : raw_lines) {
65 if (raw.empty()) continue;
66
67 if (raw[0] == ';') {
68 if (raw.size() >= 2 && raw[1] == ';') {
69 // ";;" column-header or dashes line — discard and reset pending
70 pending.clear();
71 } else {
72 // Single-';' object-comment line — append to pending
73 if (!pending.empty()) pending += "\\n";
74 pending += raw.substr(1); // strip leading ';'
75 }
76 continue;
77 }
78
79 // Data line — package with accumulated comment
80 result.push_back({raw, std::move(pending)});
81 pending.clear();
82 }
83 return result;
84}
85
86} // namespace openswmm::input
Definition CatchmentHandler.cpp:45
std::vector< ParsedLine > parse_section(const std::vector< std::string > &raw_lines)
Split raw section lines into (data, comment) pairs.
Definition SectionParser.hpp:59
One data row together with its associated object comment.
Definition SectionParser.hpp:35
std::string comment
Object comment joined with literal "\\n"; "" = none.
Definition SectionParser.hpp:37
std::string data
Stripped data line ready for tokenisation.
Definition SectionParser.hpp:36