![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Pure-function path normalisation and relative-path math. More...
#include <string>Go to the source code of this file.
Classes | |
| struct | openswmm::io::RelativeResult |
Outcome of computing target relative to anchor_dir. More... | |
Namespaces | |
| namespace | openswmm |
| namespace | openswmm::io |
Enumerations | |
| enum class | openswmm::io::PathClass : int { openswmm::io::Relative = 0 , openswmm::io::AbsoluteSameVolume = 1 , openswmm::io::AbsoluteCrossVolume = 2 , openswmm::io::Invalid = 3 } |
| Classification of a makeRelative() result. More... | |
Functions | |
| RelativeResult | openswmm::io::makeRelative (const std::string &target_absolute, const std::string &anchor_dir, int max_up_levels=16) |
Compute target_absolute expressed relative to anchor_dir. | |
| std::string | openswmm::io::resolveRelative (const std::string &stored_token, const std::string &anchor_dir) |
| Resolve a possibly-relative token against an anchor directory. | |
| std::string | openswmm::io::normaliseSeparators (const std::string &path) |
Convert all backslashes to forward-slashes; collapse ./ and duplicate slashes; drop trailing slash (except for filesystem roots like / or C:/). | |
| std::string | openswmm::io::parentDir (const std::string &file_path) |
Parent directory portion of file_path, canonicalised for use as an anchor to makeRelative / resolveRelative. | |
| bool | openswmm::io::isAbsolutePath (const std::string &path) noexcept |
True iff path is absolute on the current platform. | |
Pure-function path normalisation and relative-path math.
Foundation of the IO portability work (see openswmm.gui/docs/IO_PORTABILITY_PLAN.md §3.1). Three jobs:
target expressed relative to an anchor directory, classifying the result so callers can fall back to absolute when relative is impossible (cross-volume, UNC, beyond depth cap).addAbsolutePath() semantics in src/legacy/engine/swmm5.c:2820./ and \ on read — the SWMM .inp text format is platform-neutral, the in-memory representation is platform-native.All functions are pure, allocation-only, and thread-safe. They use std::filesystem::path for parsing but never throw on missing files (no canonical() calls).