Using PathView to pass paths to APIs
This commit is contained in:
@@ -14,9 +14,9 @@ template<typename parse_separators, typename format_separator>
|
||||
struct WindowsSystemCustom : public tl::detail::path_system::base_path_system<parse_separators, format_separator>
|
||||
{
|
||||
template<typename T>
|
||||
static T format_absolute(const tl::vector<tl::string>& members);
|
||||
static void parse_absolute(tl::vector<tl::string>& o_elements, const char* path, size_t size);
|
||||
static bool validate_abs_path(const tl::vector<tl::string>& members);
|
||||
static T format_abs(tl::span<const tl::string> members);
|
||||
static void parse_abs(tl::vector<tl::string>& o_elements, const char* path, size_t size);
|
||||
static bool validate_abs_path(tl::span<const tl::string> members);
|
||||
static bool match(const char* path, size_t size);
|
||||
};
|
||||
TL_DECLARE_STRING_VECTOR(WindowsParseSeparators, "\\", "/");
|
||||
@@ -35,8 +35,10 @@ TL_DECLARE_STRING_VECTOR(UncParseSeparators, "\\", "/");
|
||||
TL_DECLARE_STRING_LITERAL(UncFormatSeparator, "\\");
|
||||
using UncSystem = tl::simple_path_system<UncRootTag, UncParseSeparators, UncFormatSeparator>;
|
||||
|
||||
using AbsPath = tl::abs_path<tl::path_systems<WindowsSystem, PosixSystem, UncSystem> >;
|
||||
using AbsPath = tl::abs_path<tl::path_systems<WindowsSystem, PosixSystem, UncSystem>>;
|
||||
using AbsPathView = AbsPath::path_view_type;
|
||||
using RelPath = AbsPath::rel_path_type;
|
||||
using RelPathView = RelPath::path_view_type;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +50,6 @@ struct std::formatter<fs::RelPath>
|
||||
constexpr auto parse(format_parse_context& ctx) noexcept { return ctx.begin(); }
|
||||
auto format(const fs::RelPath& p, std::format_context& ctx) const
|
||||
{
|
||||
return format_to(ctx.out(), "{}", p.get_as<fs::PosixSystem>());
|
||||
return format_to(ctx.out(), "{}", p.str<fs::PosixSystem>());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user