30 AssetPath() =
default;
32 AssetPath(std::string_view path)
37 AssetPath(
const char* path)
38 : AssetPath(std::string_view(path ? path :
""))
42 AssetPath(
const std::string& path)
43 : AssetPath(std::string_view(path))
48 : AssetPath(path.logical_path())
52 [[nodiscard]]
static bool IsValid(std::string_view path)
54 return filesystem::is_valid_asset_logical_path(path);
57 [[nodiscard]]
static std::optional<AssetPath> TryCreate(std::string_view path)
64 return AssetPath(path, TrustedTag{});
67 [[nodiscard]]
const char* c_str()
const noexcept
69 return logical_path_.c_str();
72 [[nodiscard]]
const std::string& logical_path()
const noexcept
77 [[nodiscard]]
bool empty()
const noexcept
79 return logical_path_.empty();
82 [[nodiscard]] std::string_view extension()
const noexcept
84 const std::size_t last_forward_slash = logical_path_.rfind(
'/');
85 const std::size_t segment_start = last_forward_slash == std::string::npos ? 0u : last_forward_slash + 1u;
86 const std::size_t dot_position = logical_path_.rfind(
'.');
87 if (dot_position != std::string::npos && dot_position >= segment_start)
89 return std::string_view(logical_path_).substr(dot_position);
91 return std::string_view{};
94 [[nodiscard]]
bool has_extension(
const std::string_view ext)
const noexcept
96 return extension() == ext;
106 return AsVirtualPath();
114 AssetPath(std::string_view path, TrustedTag)
115 : logical_path_(path)
119 void AssignTrusted(std::string_view path)
121 ASSERT(IsValid(path),
"Invalid authored asset path '{}'", path);
122 logical_path_ = path;
126 std::string logical_path_;