Added path views for abs and rel paths
This commit is contained in:
+15
-14
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "tl/detail/prologue.h"
|
||||
#include <tl/span.h>
|
||||
#include <tl/vector.h>
|
||||
#include <tl/fixed_vector.h>
|
||||
#include "tl/string.h"
|
||||
@@ -60,11 +61,11 @@ template <typename... Systems>
|
||||
struct path_systems
|
||||
{
|
||||
template<typename T>
|
||||
static T format_absolute(int type_id, const tl::vector<string>& members) noexcept;
|
||||
static void parse_absolute(tl::vector<string>& o_elements, int type_id, const char* path, size_t size) noexcept;
|
||||
static T format_abs(int type_id, tl::span<const string> members) noexcept;
|
||||
static void parse_abs(tl::vector<string>& o_elements, int type_id, const char* path, size_t size) noexcept;
|
||||
static void parse_relative(tl::vector<string>& o_elements, const char* path, size_t size) noexcept;
|
||||
static int deduce_system_type(const char* path, size_t size) noexcept;
|
||||
static bool validate_abs_path(int type_id, const tl::vector<string>& members) noexcept;
|
||||
static bool validate_abs_path(int type_id, tl::span<const string> members) noexcept;
|
||||
static const tl::vector<tl::vector<const char*> >& get_all_parse_separators() noexcept;
|
||||
|
||||
template <typename TypeToCheck>
|
||||
@@ -84,9 +85,9 @@ template<typename root_tag, typename parse_separators, typename format_separator
|
||||
struct simple_path_system : public detail::path_system::base_path_system<parse_separators, format_separator>
|
||||
{
|
||||
template<typename T>
|
||||
static T format_absolute(const tl::vector<string>& members) noexcept;
|
||||
static void parse_absolute(tl::vector<string>& o_elements, const char* path, size_t size) noexcept;
|
||||
static bool validate_abs_path(const tl::vector<string>& members) noexcept;
|
||||
static T format_abs(tl::span<const string> members) noexcept;
|
||||
static void parse_abs(tl::vector<string>& o_elements, const char* path, size_t size) noexcept;
|
||||
static bool validate_abs_path(tl::span<const string> members) noexcept;
|
||||
static bool match(const char* path, size_t size) noexcept;
|
||||
};
|
||||
|
||||
@@ -105,19 +106,19 @@ namespace tl
|
||||
|
||||
template <typename... Systems>
|
||||
template<typename T>
|
||||
T path_systems<Systems...>::format_absolute(int type_id, const tl::vector<string>& members) noexcept
|
||||
T path_systems<Systems...>::format_abs(int type_id, tl::span<const string> members) noexcept
|
||||
{
|
||||
TL_PLAIN_ASSERT(type_id >= 0, "Error: trying to format an unknown path system type.");
|
||||
return detail::path_system::path_system_getter<0, Systems...>::template format_absolute<T>(type_id, members);
|
||||
return detail::path_system::path_system_getter<0, Systems...>::template format_abs<T>(type_id, members);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename... Systems>
|
||||
void path_systems<Systems...>::parse_absolute(tl::vector<string>& o_elements, int type_id, const char* path, size_t size) noexcept
|
||||
void path_systems<Systems...>::parse_abs(tl::vector<string>& o_elements, int type_id, const char* path, size_t size) noexcept
|
||||
{
|
||||
TL_PLAIN_ASSERT(type_id >= 0, "Error: trying to parse an unknown path system type.");
|
||||
detail::path_system::path_system_getter<0, Systems...>::parse_absolute(o_elements, type_id, path, size);
|
||||
detail::path_system::path_system_getter<0, Systems...>::parse_abs(o_elements, type_id, path, size);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -131,7 +132,7 @@ int path_systems<Systems...>::deduce_system_type(const char* path, size_t size)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename... Systems>
|
||||
bool path_systems<Systems...>::validate_abs_path(int type_id, const tl::vector<string>& members) noexcept
|
||||
bool path_systems<Systems...>::validate_abs_path(int type_id, tl::span<const string> members) noexcept
|
||||
{
|
||||
TL_PLAIN_ASSERT(type_id >= 0, "Error: trying to validate an unknown path system type.");
|
||||
return detail::path_system::path_system_getter<0, Systems...>::validate_abs_path(type_id, members);
|
||||
@@ -232,7 +233,7 @@ bool path_systems<Systems...>::is(int type_id) noexcept
|
||||
|
||||
template<typename root_tag, typename parse_separators, typename format_separator>
|
||||
template<typename T>
|
||||
T simple_path_system<root_tag, parse_separators, format_separator>::format_absolute(const tl::vector<string>& members) noexcept
|
||||
T simple_path_system<root_tag, parse_separators, format_separator>::format_abs(tl::span<const string> members) noexcept
|
||||
{
|
||||
if constexpr (is_same_v<T, string>)
|
||||
{
|
||||
@@ -252,7 +253,7 @@ T simple_path_system<root_tag, parse_separators, format_separator>::format_absol
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename root_tag, typename parse_separators, typename format_separator>
|
||||
void simple_path_system<root_tag, parse_separators, format_separator>::parse_absolute(tl::vector<string>& o_elements, const char* path, size_t size) noexcept
|
||||
void simple_path_system<root_tag, parse_separators, format_separator>::parse_abs(tl::vector<string>& o_elements, const char* path, size_t size) noexcept
|
||||
{
|
||||
detail::path_system::simple_parse_path(o_elements, path, size, root_tag::value(), parse_separators::vector());
|
||||
}
|
||||
@@ -268,7 +269,7 @@ bool simple_path_system<root_tag, parse_separators, format_separator>::match(con
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename root_tag, typename parse_separators, typename format_separator>
|
||||
bool simple_path_system<root_tag, parse_separators, format_separator>::validate_abs_path(const tl::vector<string>& /*members*/) noexcept
|
||||
bool simple_path_system<root_tag, parse_separators, format_separator>::validate_abs_path(tl::span<const string> /*members*/) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user