OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::gpkg::formats Namespace Reference

Classes

struct  ClimateRow
 One row of a climate file (user CSV form). More...
 
struct  FormatResult
 Lightweight outcome for format parse / materialise calls. More...
 
struct  HotstartHeader
 HSF header / counts (matches legacy hotstart.c layout). More...
 
struct  HotstartLinkState
 Per-link routing state snapshot. More...
 
struct  HotstartNodeState
 Per-node routing state snapshot. More...
 
struct  HotstartSnapshot
 Top-level snapshot — header plus per-object vectors. More...
 
struct  HotstartSubcatchState
 Per-subcatchment routing state snapshot (HSF v3+). More...
 
struct  HsfLayout
 What the model says about a file's layout that the file does not. More...
 
struct  RaingageRow
 One row of a raingage data file ("Standard" SWMM columnar). More...
 
struct  RoutingInterfaceMetadata
 Header / metadata captured at the top of a routing interface file. More...
 
struct  RoutingInterfaceRow
 One per-object record in a routing interface file. More...
 
struct  TimeseriesRow
 One row of a timeseries (SWMM-native text format). More...
 

Functions

FormatResult parseClimateCsv (const std::string &path, std::vector< ClimateRow > &rows)
 Append daily records from the user climate CSV subset.
 
FormatResult writeClimateCsv (const std::string &path, const std::vector< ClimateRow > &rows)
 Overwrite a daily climate CSV with the fixed seven-column header.
 
FormatResult ok ()
 Create a successful format-adapter outcome.
 
FormatResult fail (std::string message)
 Create a failed format-adapter outcome with an owned explanation.
 
FormatResult parseHotstartHsf (const std::string &path, HotstartSnapshot &snapshot, const HsfLayout &layout={})
 Read legacy-layout hot-start records and preserve raw runoff/trailer bytes.
 
FormatResult writeHotstartHsf (const std::string &path, const HotstartSnapshot &snapshot)
 Write retained legacy hot-start routing records and opaque raw sections.
 
FormatResult parseRaingageStd (const std::string &path, std::vector< RaingageRow > &rows)
 Append standard SWMM station/date/time/rain records.
 
FormatResult writeRaingageStd (const std::string &path, const std::vector< RaingageRow > &rows)
 Overwrite a standard SWMM station precipitation text file.
 
FormatResult parseRoutingInterfaceText (const std::string &path, RoutingInterfaceMetadata &meta, std::vector< RoutingInterfaceRow > &rows)
 Parse a SWMM5 routing-interface text file into metadata + rows.
 
FormatResult writeRoutingInterfaceText (const std::string &path, const RoutingInterfaceMetadata &meta, const std::vector< RoutingInterfaceRow > &rows)
 Overwrite a SWMM5 text routing interface from retained metadata and rows.
 
FormatResult parseTimeseriesText (const std::string &path, std::vector< TimeseriesRow > &rows)
 Parse a SWMM-native timeseries text file at path into rows.
 
FormatResult writeTimeseriesText (const std::string &path, const std::vector< TimeseriesRow > &rows)
 Overwrite dated time-series text from raw samples.
 

Function Documentation

◆ fail()

FormatResult openswmm::gpkg::formats::fail ( std::string message)
inline

Create a failed format-adapter outcome with an owned explanation.

Parameters
[in]messageDiagnostic passed by value and moved into the result; may be empty.
Returns
Value with ok=false and the supplied text; no logging, rollback or exception.
Here is the caller graph for this function:

◆ ok()

FormatResult openswmm::gpkg::formats::ok ( )
inline

Create a successful format-adapter outcome.

Returns
Value with ok=true and empty diagnostic.
Here is the caller graph for this function:

◆ parseClimateCsv()

FormatResult openswmm::gpkg::formats::parseClimateCsv ( const std::string & path,
std::vector< ClimateRow > & rows )

Append daily records from the user climate CSV subset.

Uses 2048-byte line reads, comma splitting without CSV quoting, trimmed case-insensitive headers and # comments. Date text remains unvalidated; absent/unparseable numbers become zero (stod prefixes accepted). No unit conversion, sort, duplicate/finite/range check or late ferror/close reporting; allocation exceptions can escape.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in,out]rowsCaller-owned destination appended in file order; not cleared, and earlier rows remain on failure.
Returns
Failure for open refusal or a nonempty header lacking date; otherwise success, including an empty file.
Here is the call graph for this function:

◆ parseHotstartHsf()

FormatResult openswmm::gpkg::formats::parseHotstartHsf ( const std::string & path,
HotstartSnapshot & snapshot,
const HsfLayout & layout = {} )

Read legacy-layout hot-start records and preserve raw runoff/trailer bytes.

Reads a 15-byte SWMM5 stamp and six native int32 counts in the v4-compatible layout regardless of parsed suffix. Caller supplies nonnegative representable counts/size products and matching storage layout; the parser has no global count/memory or finite-value cap. Native floats store feet/cfs and concentrations; runoff/trailer retained verbatim, subcatch_state not decoded. No checksum/model-fingerprint validation or whole-destination rollback; allocation/callback exceptions can escape.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in,out]snapshotDestination overwritten incrementally, with prior/partial fields retained on failure; caller normally starts fresh.
[in]layoutBorrowed model-dependent runoff-length callback and storage-node mask; correct aligned dimensions required to locate routing records.
Returns
Failure on guarded open/stamp/count/read/layout refusal; otherwise success.
Here is the call graph for this function:

◆ parseRaingageStd()

FormatResult openswmm::gpkg::formats::parseRaingageStd ( const std::string & path,
std::vector< RaingageRow > & rows )

Append standard SWMM station/date/time/rain records.

Uses 512-byte line reads and sscanf; comments/short malformed rows skip. No station filter, start-date clipping, unit/rain-type conversion, monotonic/finite validation or late IO checking. Timestamp validity follows permissive datetime encoders.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in,out]rowsCaller-owned destination appended with station ID, OADate and raw rainfall values.
Returns
Failure on open refusal, otherwise success even if no row parses.
Here is the call graph for this function:

◆ parseRoutingInterfaceText()

FormatResult openswmm::gpkg::formats::parseRoutingInterfaceText ( const std::string & path,
RoutingInterfaceMetadata & meta,
std::vector< RoutingInterfaceRow > & rows )

Parse a SWMM5 routing-interface text file into metadata + rows.

Parameters
pathFilesystem path to read.
metaOutput metadata (title, step, units, pollutants, objects). Pollutant_values length on each row equals meta.pollutant_ids.size().
rowsOutput data rows (appended; caller clears if needed).
Here is the call graph for this function:

◆ parseTimeseriesText()

FormatResult openswmm::gpkg::formats::parseTimeseriesText ( const std::string & path,
std::vector< TimeseriesRow > & rows )

Parse a SWMM-native timeseries text file at path into rows.

Parameters
pathFilesystem path to read.
rowsOutput rows (appended; caller must clear if needed).
Returns
FormatResult — ok on success; error carries open / parse diagnostics on failure.
Here is the call graph for this function:

◆ writeClimateCsv()

FormatResult openswmm::gpkg::formats::writeClimateCsv ( const std::string & path,
const std::vector< ClimateRow > & rows )

Overwrite a daily climate CSV with the fixed seven-column header.

Writes numbers with four decimals, unescaped date text and row order unchanged. Does not check fprintf/fclose errors, atomically stage output, create directories or validate dates/units.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in]rowsBorrowed date/tmin/tmax/evap/wind/sky/humidity rows in retained source-unit conventions.
Returns
Failure only when opening output fails; otherwise success.
Here is the call graph for this function:

◆ writeHotstartHsf()

FormatResult openswmm::gpkg::formats::writeHotstartHsf ( const std::string & path,
const HotstartSnapshot & snapshot )

Write retained legacy hot-start routing records and opaque raw sections.

Checks node/link vector counts and pollutant widths before opening. Writes v2..v4 stamp according to file_version, otherwise v4, using the same six-count native layout; empty runoff writes subcatch count zero. Values narrow to native floats; HRT is written whenever has_hrt even if version is older, so caller supplies compatible flags. Ignores derived overflow/volume/timing fields. Direct truncation, no atomic stage, finite validation or CRC; trailer preserved.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in]snapshotCoherent header/counts and node/link concentration arrays, with matching runoff bytes and storage HRT flags.
Returns
Failure on guarded shape/open/write refusal; success after attempted close (close errors ignored).
Here is the call graph for this function:

◆ writeRaingageStd()

FormatResult openswmm::gpkg::formats::writeRaingageStd ( const std::string & path,
const std::vector< RaingageRow > & rows )

Overwrite a standard SWMM station precipitation text file.

Emits station, calendar date and hour/minute with rainfall four decimals; seconds are dropped. No escaping, sorting, format/range validation, staging or fprintf/fclose status propagation.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in]rowsBorrowed station/OADate/raw-rain rows; rainfall remains its source unit convention.
Returns
Failure only on open refusal, otherwise success.
Here is the call graph for this function:

◆ writeRoutingInterfaceText()

FormatResult openswmm::gpkg::formats::writeRoutingInterfaceText ( const std::string & path,
const RoutingInterfaceMetadata & meta,
const std::vector< RoutingInterfaceRow > & rows )

Overwrite a SWMM5 text routing interface from retained metadata and rows.

Emits missing pollutant-unit labels as empty strings, and each row's entire concentration vector without shape validation against metadata. Does not reorder/group periods, validate IDs/clocks, convert units, escape text or check late write/close errors. Direct truncation, no atomic stage.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in]metaBorrowed title/report-step/flow-unit/pollutant/object metadata; counts must be int-representable.
[in]rowsBorrowed object/OADate/flow/concentration rows, already in the units named by metadata.
Returns
Failure on open refusal, otherwise success.
Here is the call graph for this function:

◆ writeTimeseriesText()

FormatResult openswmm::gpkg::formats::writeTimeseriesText ( const std::string & path,
const std::vector< TimeseriesRow > & rows )

Overwrite dated time-series text from raw samples.

Writes MM/DD/YYYY HH:MM:SS and six-decimal values. Does not transform units, sort/validate dates or values, create directories, atomically stage or propagate late fprintf/fclose errors.

Parameters
[in]pathUTF-8 filesystem path; caller supplies parent directories and owns destination/source lifetime.
[in]rowsBorrowed OADate/value samples, preserved in input order and source value units.
Returns
Failure on open refusal, otherwise success.
Here is the call graph for this function: