OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::input::InputReader Class Reference

Reads and parses a SWMM .inp file into a SimulationContext. More...

#include <InputReader.hpp>

Collaboration diagram for openswmm::input::InputReader:

Public Member Functions

 InputReader (SectionRegistry &registry)
 Borrow a pre-populated handler registry.
 
bool read (const std::string &path, SimulationContext &ctx)
 Open a UTF-8 input path and parse its section stream.
 
bool read_stream (std::istream &stream, SimulationContext &ctx)
 Read section batches and replay deferred rows once.
 
int lines_read () const noexcept
 Read the physical-line counter from the most recent stream parse.
 
const std::vector< std::string > & skipped_sections () const noexcept
 Borrow unrecognized, unhandled section tags from the last stream parse.
 

Detailed Description

Reads and parses a SWMM .inp file into a SimulationContext.

Constructor & Destructor Documentation

◆ InputReader()

openswmm::input::InputReader::InputReader ( SectionRegistry & registry)
explicit

Borrow a pre-populated handler registry.

No handlers are registered automatically by this constructor. Caller serializes reader, registry and context access.

Parameters
[in]registryMutable registry reference that must outlive the reader and all synchronous reads.

Member Function Documentation

◆ lines_read()

int openswmm::input::InputReader::lines_read ( ) const
inlinenoexcept

Read the physical-line counter from the most recent stream parse.

Returns
Number of getline successes, including blank/comment/header lines. An open failure in read() leaves the previous counter unchanged.

◆ read()

bool openswmm::input::InputReader::read ( const std::string & path,
SimulationContext & ctx )

Open a UTF-8 input path and parse its section stream.

Open failure sets error_code=2, an error message and ERROR_STATE. On success delegates read_stream(); allocation/handler exceptions propagate. Does not perform post-parse cross-reference resolution or full model validation itself.

Parameters
[in]pathBorrowed input filename; copied into ctx.inp_file_path only after successful open.
[in,out]ctxCaller-owned model context; handlers mutate it directly. This reader does not clear prior objects, errors or error_code and does not roll back partial input.
Returns
False for open failure or nonzero ctx.error_code after parsing; true otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_stream()

bool openswmm::input::InputReader::read_stream ( std::istream & stream,
SimulationContext & ctx )

Read section batches and replay deferred rows once.

Resets reader counters/skipped sections and ctx.unknown_section_headers, sets report object selections to NONE, preserves object comment rows and TITLE prose, ignores data before the first header. Existing objects/errors remain. Does not distinguish EOF from a stream read failure or call PostParseResolver.

Parameters
[in,out]streamBorrowed open stream read from its current position until getline stops; no seek/close is performed.
[in,out]ctxCaller-owned model context; handlers mutate it directly. This reader does not clear prior objects, errors or error_code and does not roll back partial input.
Returns
Whether ctx.error_code equals zero at the end; appended ctx.errors alone do not force false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipped_sections()

const std::vector< std::string > & openswmm::input::InputReader::skipped_sections ( ) const
inlinenoexcept

Borrow unrecognized, unhandled section tags from the last stream parse.

Tags are unique in encounter order; known legacy prefixes without handlers are silently omitted.

Returns
Owned vector reference, invalidated by the next read_stream() or reader destruction.
Here is the caller graph for this function:

The documentation for this class was generated from the following files: