Wildmeshing Toolkit
Loading...
Searching...
No Matches
PathResolver.hpp
Go to the documentation of this file.
1#pragma once
2#include <filesystem>
3#include <memory>
4#include <nlohmann/json_fwd.hpp>
5#include <vector>
6#include "json_macros.hpp"
7
9
10
11// a more portable abstraction of the resolve_path class
13{
14public:
15 // defaults to the path ".", i.e the working directory
17 PathResolver(const std::filesystem::path& path);
23
24 void add_path(const std::filesystem::path& path);
25 void clear_paths();
26
27 // always returns a weakly_canonical upon success
28 std::pair<std::filesystem::path, bool> resolve(const std::filesystem::path& path) const;
29
30 std::vector<std::filesystem::path> get_paths() const;
31
32 // always returns a weakly_canonical path upon success
33 static std::pair<std::filesystem::path, bool> try_resolving_path(
34 const std::filesystem::path& potential_base,
35 const std::filesystem::path& path);
36
37 // json expects either a single string or an array of strings
39
40private:
41 struct Impl;
42 std::unique_ptr<Impl> m_impl;
43};
44} // namespace wmtk::components::utils
void add_path(const std::filesystem::path &path)
static std::pair< std::filesystem::path, bool > try_resolving_path(const std::filesystem::path &potential_base, const std::filesystem::path &path)
std::vector< std::filesystem::path > get_paths() const
std::pair< std::filesystem::path, bool > resolve(const std::filesystem::path &path) const
PathResolver & operator=(PathResolver &&)
#define WMTK_NLOHMANN_JSON_FRIEND_DECLARATION(Type)