OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
PathResolver.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
46
47#ifndef OPENSWMM_ENGINE_PATH_RESOLVER_HPP
48#define OPENSWMM_ENGINE_PATH_RESOLVER_HPP
49
50#include <string>
51
52namespace openswmm::io {
53
54// ============================================================================
55// PathClass — outcome of a makeRelative() attempt
56// ============================================================================
57
74
75// ============================================================================
76// RelativeResult — full outcome of makeRelative()
77// ============================================================================
78
98
99// ============================================================================
100// Public API
101// ============================================================================
102
122RelativeResult makeRelative(const std::string& target_absolute, const std::string& anchor_dir,
123 int max_up_levels = 16);
124
138std::string resolveRelative(const std::string& stored_token, const std::string& anchor_dir);
139
150std::string normaliseSeparators(const std::string& path);
151
162std::string parentDir(const std::string& file_path);
163
164// ============================================================================
165// Test hooks — exposed for unit tests; not part of the supported API.
166// ============================================================================
167
178bool isAbsolutePath(const std::string& path) noexcept;
179
180} // namespace openswmm::io
181
182#endif // OPENSWMM_ENGINE_PATH_RESOLVER_HPP
Definition AtomicOutputFile.hpp:25
std::string resolveRelative(const std::string &stored_token, const std::string &anchor_dir)
Join a stored token to a directory anchor using lexical normalization.
Definition PathResolver.cpp:264
PathClass
Classification of a makeRelative() result.
Definition PathResolver.hpp:66
@ Relative
Expressible relative to anchor; portable.
Definition PathResolver.hpp:67
@ Invalid
Empty or malformed input.
Definition PathResolver.hpp:72
@ AbsoluteSameVolume
Definition PathResolver.hpp:68
@ AbsoluteCrossVolume
Definition PathResolver.hpp:70
std::string normaliseSeparators(const std::string &path)
Normalize separator and dot spelling without resolving parent segments.
Definition PathResolver.cpp:225
bool isAbsolutePath(const std::string &path) noexcept
Recognize platform-neutral absolute-looking path syntax.
Definition PathResolver.cpp:205
std::string parentDir(const std::string &file_path)
Extract a directory token using normalized separator text.
Definition PathResolver.cpp:238
RelativeResult makeRelative(const std::string &target_absolute, const std::string &anchor_dir, int max_up_levels)
Compute a lexical relative token or return a classified absolute fallback.
Definition PathResolver.cpp:294
Outcome of computing target relative to anchor_dir.
Definition PathResolver.hpp:92
int up_levels
Definition PathResolver.hpp:95
PathClass classification
Definition PathResolver.hpp:94
std::string path
Definition PathResolver.hpp:93
std::string warning
Definition PathResolver.hpp:96