Blender
V3.3
|
#include <BKE_asset_catalog_path.hh>
Public Types | |
using | ComponentIteratorFn = FunctionRef< void(StringRef component_name, bool is_last_component)> |
Static Public Attributes | |
static const char | SEPARATOR = '/' |
Static Protected Member Functions | |
static std::string | cleanup_component (StringRef component_name) |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const AssetCatalogPath &path_to_append) |
Location of an Asset Catalog in the catalog tree, denoted by slash-separated path components.
Each path component is a string that is not allowed to have slashes or colons. The latter is to make things easy to save in the colon-delimited Catalog Definition File format.
The path of a catalog determines where in the catalog hierarchy the catalog is shown. Examples are "Characters/Ellie/Poses/Hand" or "Kit_bash/City/Skyscrapers". The path looks like a file-system path, with a few differences:
See https://wiki.blender.org/wiki/Source/Architecture/Asset_System/Catalogs
Paths are stored as byte sequences, and assumed to be UTF-8.
Definition at line 38 of file BKE_asset_catalog_path.hh.
using blender::bke::AssetCatalogPath::ComponentIteratorFn = FunctionRef<void(StringRef component_name, bool is_last_component)> |
Call the callback function for each path component, in left-to-right order.
Definition at line 121 of file BKE_asset_catalog_path.hh.
|
default |
Referenced by cleanup(), operator/(), parent(), and rebase().
blender::bke::AssetCatalogPath::AssetCatalogPath | ( | StringRef | path | ) |
Definition at line 19 of file asset_catalog_path.cc.
blender::bke::AssetCatalogPath::AssetCatalogPath | ( | const std::string & | path | ) |
Definition at line 15 of file asset_catalog_path.cc.
blender::bke::AssetCatalogPath::AssetCatalogPath | ( | const char * | path | ) |
Definition at line 23 of file asset_catalog_path.cc.
|
default |
|
noexcept |
Definition at line 27 of file asset_catalog_path.cc.
|
default |
const char * blender::bke::AssetCatalogPath::c_str | ( | ) | const |
C-string representation of the path.
Definition at line 43 of file asset_catalog_path.cc.
Referenced by blender::ed::asset_browser::AssetCatalogTreeViewItem::build_context_menu(), blender::ed::asset_browser::AssetCatalogTreeViewItem::build_row(), and ED_asset_catalog_move().
AssetCatalogPath blender::bke::AssetCatalogPath::cleanup | ( | ) | const |
Clean up the path. This ensures:
Definition at line 104 of file asset_catalog_path.cc.
References AssetCatalogPath(), cleanup_component(), iterate_components(), and SEPARATOR.
Referenced by ED_asset_catalog_move(), ED_asset_catalog_rename(), blender::bke::AssetCatalog::from_path(), blender::bke::AssetCatalogDefinitionFile::parse_catalog_line(), and blender::bke::tests::TEST().
|
staticprotected |
Strip leading/trailing spaces and replace disallowed characters.
Definition at line 132 of file asset_catalog_path.cc.
References component().
Referenced by cleanup().
uint64_t blender::bke::AssetCatalogPath::hash | ( | ) | const |
Definition at line 32 of file asset_catalog_path.cc.
bool blender::bke::AssetCatalogPath::is_contained_in | ( | const AssetCatalogPath & | other_path | ) | const |
True: "some/path/there" is contained in "some/path" and "some". False: "path/there" is not contained in "some/path/there".
Note that non-cleaned-up paths (so for example starting or ending with a slash) are not supported, and result in undefined behavior.
Definition at line 140 of file asset_catalog_path.cc.
References length(), SEPARATOR, and blender::StringRefBase::startswith().
Referenced by blender::ed::asset_browser::AssetCatalogDropController::can_drop(), blender::bke::AssetCatalogService::create_catalog_filter(), blender::bke::AssetCatalogService::prune_catalogs_by_path(), rebase(), and blender::bke::tests::TEST().
void blender::bke::AssetCatalogPath::iterate_components | ( | ComponentIteratorFn | callback | ) | const |
Definition at line 177 of file asset_catalog_path.cc.
References BLI_path_slash_find(), and callback.
Referenced by cleanup(), blender::bke::AssetCatalogTree::insert_item(), and blender::bke::tests::TEST().
uint64_t blender::bke::AssetCatalogPath::length | ( | ) | const |
Definition at line 38 of file asset_catalog_path.cc.
Referenced by is_contained_in(), rebase(), and blender::bke::tests::TEST().
StringRefNull blender::bke::AssetCatalogPath::name | ( | ) | const |
Definition at line 53 of file asset_catalog_path.cc.
References SEPARATOR.
Referenced by blender::bke::tests::AssetCatalogTest::assert_expected_item(), and ED_asset_catalog_move().
blender::bke::AssetCatalogPath::operator bool | ( | ) | const |
Definition at line 93 of file asset_catalog_path.cc.
bool blender::bke::AssetCatalogPath::operator!= | ( | const AssetCatalogPath & | other_path | ) | const |
Definition at line 68 of file asset_catalog_path.cc.
AssetCatalogPath blender::bke::AssetCatalogPath::operator/ | ( | const AssetCatalogPath & | path_to_append | ) | const |
Concatenate two paths, returning the new path.
Definition at line 78 of file asset_catalog_path.cc.
References AssetCatalogPath(), and SEPARATOR.
bool blender::bke::AssetCatalogPath::operator< | ( | const AssetCatalogPath & | other_path | ) | const |
Definition at line 73 of file asset_catalog_path.cc.
|
default |
|
default |
bool blender::bke::AssetCatalogPath::operator== | ( | const AssetCatalogPath & | other_path | ) | const |
Definition at line 63 of file asset_catalog_path.cc.
AssetCatalogPath blender::bke::AssetCatalogPath::parent | ( | ) | const |
Definition at line 165 of file asset_catalog_path.cc.
References AssetCatalogPath(), and SEPARATOR.
Referenced by blender::ed::asset_browser::AssetCatalogDropController::can_drop(), blender::bke::AssetCatalogService::create_missing_catalogs(), ED_asset_catalog_rename(), and blender::bke::tests::TEST().
AssetCatalogPath blender::bke::AssetCatalogPath::rebase | ( | const AssetCatalogPath & | from_path, |
const AssetCatalogPath & | to_path | ||
) | const |
Change the initial part of the path from from_path
to to_path
. If this path does not start with from_path
, return an empty path as result.
Example:
AssetCatalogPath path("some/path/to/some/catalog"); path.rebase("some/path", "new/base") -> "new/base/to/some/catalog"
Definition at line 199 of file asset_catalog_path.cc.
References AssetCatalogPath(), is_contained_in(), length(), and blender::StringRefBase::substr().
Referenced by blender::bke::tests::TEST(), and blender::bke::AssetCatalogService::update_catalog_path().
const std::string & blender::bke::AssetCatalogPath::str | ( | ) | const |
Definition at line 48 of file asset_catalog_path.cc.
Referenced by blender::bke::tests::AssetCatalogTest::assert_expected_item(), blender::bke::AssetCatalogTree::insert_item(), blender::bke::AssetCatalog::sensible_simple_name_for_path(), blender::bke::tests::TEST(), and blender::bke::tests::TEST_F().
|
friend |
Output the path as string.
Definition at line 98 of file asset_catalog_path.cc.
|
static |
Definition at line 48 of file BKE_asset_catalog_path.hh.
Referenced by blender::bke::tests::AssetCatalogTest::assert_expected_item(), cleanup(), is_contained_in(), name(), operator/(), parent(), and blender::bke::AssetCatalog::sensible_simple_name_for_path().