Blender V4.3
blender::asset_system::AssetCatalogPath Class Reference

#include <AS_asset_catalog_path.hh>

Public Types

using ComponentIteratorFn = FunctionRef<void(StringRef component_name, bool is_last_component)>
 

Public Member Functions

 AssetCatalogPath ()=default
 
 AssetCatalogPath (StringRef path)
 
 AssetCatalogPath (std::string path)
 
 AssetCatalogPath (const char *path)
 
 AssetCatalogPath (const AssetCatalogPath &other_path)=default
 
 AssetCatalogPath (AssetCatalogPath &&other_path) noexcept
 
 ~AssetCatalogPath ()=default
 
uint64_t hash () const
 
uint64_t length () const
 
const char * c_str () const
 
const std::string & str () const
 
StringRefNull name () const
 
bool operator== (const AssetCatalogPath &other_path) const
 
bool operator!= (const AssetCatalogPath &other_path) const
 
bool operator< (const AssetCatalogPath &other_path) const
 
AssetCatalogPathoperator= (const AssetCatalogPath &other_path)=default
 
AssetCatalogPathoperator= (AssetCatalogPath &&other_path)=default
 
AssetCatalogPath operator/ (const AssetCatalogPath &path_to_append) const
 
 operator bool () const
 
AssetCatalogPath cleanup () const
 
bool is_contained_in (const AssetCatalogPath &other_path) const
 
AssetCatalogPath parent () const
 
AssetCatalogPath rebase (const AssetCatalogPath &from_path, const AssetCatalogPath &to_path) const
 
void iterate_components (ComponentIteratorFn callback) const
 

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)
 

Detailed Description

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:

  • Only slashes are used as path component separators.
  • All paths are absolute, so there is no need for a leading slash.

See https://developer.blender.org/docs/features/asset_system/backend/asset_catalogs/

Paths are stored as byte sequences, and assumed to be UTF-8.

Definition at line 36 of file AS_asset_catalog_path.hh.

Member Typedef Documentation

◆ ComponentIteratorFn

using blender::asset_system::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 118 of file AS_asset_catalog_path.hh.

Constructor & Destructor Documentation

◆ AssetCatalogPath() [1/6]

blender::asset_system::AssetCatalogPath::AssetCatalogPath ( )
default

Referenced by cleanup(), operator/(), parent(), and rebase().

◆ AssetCatalogPath() [2/6]

blender::asset_system::AssetCatalogPath::AssetCatalogPath ( StringRef path)

Definition at line 21 of file asset_catalog_path.cc.

◆ AssetCatalogPath() [3/6]

blender::asset_system::AssetCatalogPath::AssetCatalogPath ( std::string path)

Definition at line 19 of file asset_catalog_path.cc.

◆ AssetCatalogPath() [4/6]

blender::asset_system::AssetCatalogPath::AssetCatalogPath ( const char * path)

Definition at line 23 of file asset_catalog_path.cc.

◆ AssetCatalogPath() [5/6]

blender::asset_system::AssetCatalogPath::AssetCatalogPath ( const AssetCatalogPath & other_path)
default

◆ AssetCatalogPath() [6/6]

blender::asset_system::AssetCatalogPath::AssetCatalogPath ( AssetCatalogPath && other_path)
noexcept

Definition at line 25 of file asset_catalog_path.cc.

◆ ~AssetCatalogPath()

blender::asset_system::AssetCatalogPath::~AssetCatalogPath ( )
default

Member Function Documentation

◆ c_str()

◆ cleanup()

AssetCatalogPath blender::asset_system::AssetCatalogPath::cleanup ( ) const
nodiscard

Clean up the path. This ensures:

  • Every path component is stripped of its leading/trailing spaces.
  • Empty components (caused by double slashes or leading/trailing slashes) are removed.
  • Invalid characters are replaced with valid ones.

Definition at line 102 of file asset_catalog_path.cc.

References AssetCatalogPath(), cleanup_component(), iterate_components(), and SEPARATOR.

Referenced by blender::ed::asset::catalog_move(), blender::ed::asset::catalog_rename(), blender::asset_system::AssetCatalog::from_path(), blender::asset_system::AssetCatalogDefinitionFile::parse_catalog_line(), and blender::asset_system::tests::TEST().

◆ cleanup_component()

std::string blender::asset_system::AssetCatalogPath::cleanup_component ( StringRef component_name)
staticprotected

Strip leading/trailing spaces and replace disallowed characters.

Definition at line 130 of file asset_catalog_path.cc.

References blender::StringRefBase::trim().

Referenced by cleanup().

◆ hash()

uint64_t blender::asset_system::AssetCatalogPath::hash ( ) const

Definition at line 30 of file asset_catalog_path.cc.

◆ is_contained_in()

bool blender::asset_system::AssetCatalogPath::is_contained_in ( const AssetCatalogPath & other_path) const
Returns
true only if the given path is a parent of this catalog's path. When this catalog's path is equal to the given path, return true as well. In other words, this defines a weak subset.

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 138 of file asset_catalog_path.cc.

References length(), SEPARATOR, and blender::StringRefBase::startswith().

Referenced by blender::ed::asset_browser::AssetCatalogDropTarget::can_drop(), blender::asset_system::AssetCatalogService::create_catalog_filter(), blender::asset_system::AssetCatalogService::prune_catalogs_by_path(), rebase(), and blender::asset_system::tests::TEST().

◆ iterate_components()

void blender::asset_system::AssetCatalogPath::iterate_components ( ComponentIteratorFn callback) const

◆ length()

uint64_t blender::asset_system::AssetCatalogPath::length ( ) const

◆ name()

StringRefNull blender::asset_system::AssetCatalogPath::name ( ) const

◆ operator bool()

blender::asset_system::AssetCatalogPath::operator bool ( ) const

Definition at line 91 of file asset_catalog_path.cc.

◆ operator!=()

bool blender::asset_system::AssetCatalogPath::operator!= ( const AssetCatalogPath & other_path) const

Definition at line 66 of file asset_catalog_path.cc.

◆ operator/()

AssetCatalogPath blender::asset_system::AssetCatalogPath::operator/ ( const AssetCatalogPath & path_to_append) const

Concatenate two paths, returning the new path.

Definition at line 76 of file asset_catalog_path.cc.

References AssetCatalogPath(), and SEPARATOR.

◆ operator<()

bool blender::asset_system::AssetCatalogPath::operator< ( const AssetCatalogPath & other_path) const

Definition at line 71 of file asset_catalog_path.cc.

◆ operator=() [1/2]

AssetCatalogPath & blender::asset_system::AssetCatalogPath::operator= ( AssetCatalogPath && other_path)
default

◆ operator=() [2/2]

AssetCatalogPath & blender::asset_system::AssetCatalogPath::operator= ( const AssetCatalogPath & other_path)
default

◆ operator==()

bool blender::asset_system::AssetCatalogPath::operator== ( const AssetCatalogPath & other_path) const

Definition at line 61 of file asset_catalog_path.cc.

◆ parent()

AssetCatalogPath blender::asset_system::AssetCatalogPath::parent ( ) const

◆ rebase()

AssetCatalogPath blender::asset_system::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 198 of file asset_catalog_path.cc.

References AssetCatalogPath(), is_contained_in(), length(), and blender::StringRefBase::substr().

Referenced by blender::asset_system::tests::TEST(), and blender::asset_system::AssetCatalogService::update_catalog_path().

◆ str()

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const AssetCatalogPath & path_to_append )
friend

Output the path as string.

Definition at line 96 of file asset_catalog_path.cc.

Member Data Documentation

◆ SEPARATOR

const char blender::asset_system::AssetCatalogPath::SEPARATOR = '/'
static

The documentation for this class was generated from the following files: