OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
InpWriter.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
31
32#ifndef OPENSWMM_INP_WRITER_HPP
33#define OPENSWMM_INP_WRITER_HPP
34
35#include <cstdio>
36#include <functional>
37#include <string>
38#include <vector>
39
40namespace openswmm {
41
43
44namespace inp_writer {
45
57std::string groundwaterSections(const SimulationContext& ctx);
58
96int writeInpFile(const SimulationContext& ctx, const std::string& path,
97 std::vector<std::string>* warnings = nullptr);
98
124 enum class Profile { Full, Swmm5, Swmm5Stock };
126 // Internal container serialization: borrowed stream, no mesh sidecar writes.
127 FILE* stream = nullptr;
128 bool internal_units = false;
129 bool inline_mesh = false;
131 enum class OutputKind { Model = 0, Mesh = 1, Component = 2 };
132 // Final paths remain the reference anchor. Every actual output is sent
133 // here before opening; an empty mapped path refuses that output.
134 // The caller owns staging cleanup, validation and publication.
135 std::function<std::string(const std::string&, OutputKind)> map_output;
136};
137
138int writeInpFile(const SimulationContext& ctx, const std::string& path,
139 std::vector<std::string>* warnings, const InpWriteOptions& opts);
140
141// Complete native text, anchored at a container destination. No model/mesh files
142// are created. internal_units is used only for GeoPackage supplemental sections.
143std::string modelText(const SimulationContext& ctx, const std::string& anchor,
144 bool internal_units = false);
145
146} // namespace inp_writer
147} // namespace openswmm
148
149#endif // OPENSWMM_INP_WRITER_HPP
Definition InpWriter.cpp:104
std::string groundwaterSections(const SimulationContext &ctx)
Render the authored groundwater chemistry/aquifer reactor sections as text.
Definition InpWriter.cpp:1050
int writeInpFile(const SimulationContext &ctx, const std::string &path, std::vector< std::string > *warnings)
Write the full model to a SWMM .inp file.
Definition InpWriter.cpp:1813
std::string modelText(const SimulationContext &ctx, const std::string &anchor, bool internal_units)
Definition InpWriter.cpp:5012
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Write profile: which engine the file is written for.
Definition InpWriter.hpp:123
OutputKind
Definition InpWriter.hpp:131
std::function< std::string(const std::string &, OutputKind)> map_output
Definition InpWriter.hpp:135
bool internal_units
Definition InpWriter.hpp:128
bool skip_component_files
Definition InpWriter.hpp:130
Profile
Definition InpWriter.hpp:124
@ Swmm5Stock
Definition InpWriter.hpp:124
bool inline_mesh
Definition InpWriter.hpp:129
Profile profile
Definition InpWriter.hpp:125
FILE * stream
Definition InpWriter.hpp:127