OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
PathResolver.hpp
Go to the documentation of this file.
1
30
31#ifndef OPENSWMM_ENGINE_PATH_RESOLVER_HPP
32#define OPENSWMM_ENGINE_PATH_RESOLVER_HPP
33
34#include <string>
35
36namespace openswmm::io {
37
38// ============================================================================
39// PathClass — outcome of a makeRelative() attempt
40// ============================================================================
41
58
59// ============================================================================
60// RelativeResult — full outcome of makeRelative()
61// ============================================================================
62
82
83// ============================================================================
84// Public API
85// ============================================================================
86
120RelativeResult makeRelative(const std::string& target_absolute,
121 const std::string& anchor_dir,
122 int max_up_levels = 16);
123
145std::string resolveRelative(const std::string& stored_token,
146 const std::string& anchor_dir);
147
160std::string normaliseSeparators(const std::string& path);
161
175std::string parentDir(const std::string& file_path);
176
177// ============================================================================
178// Test hooks — exposed for unit tests; not part of the supported API.
179// ============================================================================
180
189bool isAbsolutePath(const std::string& path) noexcept;
190
191} // namespace openswmm::io
192
193#endif // OPENSWMM_ENGINE_PATH_RESOLVER_HPP
Definition PathResolver.cpp:20
std::string resolveRelative(const std::string &stored_token, const std::string &anchor_dir)
Resolve a possibly-relative token against an anchor directory.
Definition PathResolver.cpp:190
PathClass
Classification of a makeRelative() result.
Definition PathResolver.hpp:50
@ Relative
Expressible relative to anchor; portable.
Definition PathResolver.hpp:51
@ Invalid
Empty or malformed input.
Definition PathResolver.hpp:56
@ AbsoluteSameVolume
Definition PathResolver.hpp:52
@ AbsoluteCrossVolume
Definition PathResolver.hpp:54
std::string normaliseSeparators(const std::string &path)
Convert all backslashes to forward-slashes; collapse ./ and duplicate slashes; drop trailing slash (e...
Definition PathResolver.cpp:157
bool isAbsolutePath(const std::string &path) noexcept
True iff path is absolute on the current platform.
Definition PathResolver.cpp:138
std::string parentDir(const std::string &file_path)
Parent directory portion of file_path, canonicalised for use as an anchor to makeRelative / resolveRe...
Definition PathResolver.cpp:169
RelativeResult makeRelative(const std::string &target_absolute, const std::string &anchor_dir, int max_up_levels)
Compute target_absolute expressed relative to anchor_dir.
Definition PathResolver.cpp:220
Outcome of computing target relative to anchor_dir.
Definition PathResolver.hpp:76
int up_levels
Definition PathResolver.hpp:79
PathClass classification
Definition PathResolver.hpp:78
std::string path
Definition PathResolver.hpp:77
std::string warning
Definition PathResolver.hpp:80