26 : path_(std::move(other_path.path_))
32 std::hash<std::string> hasher{};
38 return path_.length();
54 if (last_sep_index == std::string::npos) {
63 return path_ == other_path.path_;
68 return !(*
this == other_path);
73 return path_ < other_path.path_;
80 return path_to_append;
82 if (!path_to_append) {
86 std::stringstream new_path;
87 new_path << path_ <<
SEPARATOR << path_to_append.path_;
91AssetCatalogPath::operator bool()
const
93 return !path_.empty();
98 stream << path_to_append.path_;
109 std::stringstream clean_components;
110 bool first_component_seen =
false;
116 if (clean_component.empty()) {
124 if (first_component_seen) {
127 first_component_seen =
true;
129 clean_components << clean_component;
137 std::string cleaned = component_name.
trim();
139 std::replace(cleaned.begin(), cleaned.end(),
':',
'-');
150 if (path_ == other_path.path_) {
163 const bool prefix_ok = this_path.
startswith(other_path.path_);
164 const char next_char = this_path[other_path.
length()];
165 return prefix_ok && next_char ==
SEPARATOR;
173 std::string::size_type last_sep_index = path_.rfind(
SEPARATOR);
174 if (last_sep_index == std::string::npos) {
182 const char *next_slash_ptr;
184 for (
const char *path_component = path_.data(); path_component && path_component[0];
186 path_component = next_slash_ptr ? next_slash_ptr + 1 :
nullptr)
192 const bool is_last_component = next_slash_ptr ==
nullptr;
194 const StringRef component_name = is_last_component ?
197 next_slash_ptr - path_component);
199 callback(component_name, is_last_component);
210 return to_path / *
this;
217 if (*
this == from_path) {
225 return to_path / path_suffix;
constexpr StringRefNull()
AssetCatalogPath parent() const
const std::string & str() const
AssetCatalogPath cleanup() const
static AssetCatalogPath from_user_input(const char *path)
const char * c_str() const
AssetCatalogPath rebase(const AssetCatalogPath &from_path, const AssetCatalogPath &to_path) const
AssetCatalogPath operator/(const AssetCatalogPath &path_to_append) const
AssetCatalogPath()=default
bool operator==(const AssetCatalogPath &other_path) const
bool operator!=(const AssetCatalogPath &other_path) const
FunctionRef< void(StringRef component_name, bool is_last_component)> ComponentIteratorFn
bool is_contained_in(const AssetCatalogPath &other_path) const
void iterate_components(ComponentIteratorFn callback) const
friend std::ostream & operator<<(std::ostream &stream, const AssetCatalogPath &path_to_append)
static const char SEPARATOR
StringRefNull name() const
bool operator<(const AssetCatalogPath &other_path) const
static std::string cleanup_component(StringRef component_name)
constexpr StringRef trim() const
constexpr int64_t rfind(char c, int64_t pos=INT64_MAX) const
constexpr bool startswith(StringRef prefix) const
constexpr StringRef substr(int64_t start, int64_t size) const
unsigned __int64 uint64_t
const char * BLI_path_slash_find(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT