diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-09-30 17:29:14 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-09-30 17:29:14 +0300 |
commit | 628fab696cfaefdd2ac758849c8a1e9a3a0beef0 (patch) | |
tree | d24db3bab2e501ef702dc87cddb732ffd61fb1a4 /source/blender/editors/asset | |
parent | 5d42ea036999a7e82dbc03947968f4ad61093d06 (diff) |
Asset Catalog: introduce `AssetCatalogPath` class
So far we have used `std::string` for asset catalog paths. Some
operations are better described on a dedicated class for this, though.
This commits switches catalog paths from using `std::string` to a
dedicated `blender::bke::AssetCatalogPath` class.
The `using CatalogPath = AssetCatalogPath` alias is still there, and
will be removed in a following cleanup commit.
New `AssetCatalogPath` code reviewed by @severin in D12710.
Diffstat (limited to 'source/blender/editors/asset')
-rw-r--r-- | source/blender/editors/asset/intern/asset_catalog.cc | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/source/blender/editors/asset/intern/asset_catalog.cc b/source/blender/editors/asset/intern/asset_catalog.cc index 68f11d77f44..c3e5a888796 100644 --- a/source/blender/editors/asset/intern/asset_catalog.cc +++ b/source/blender/editors/asset/intern/asset_catalog.cc @@ -19,6 +19,7 @@ */ #include "BKE_asset_catalog.hh" +#include "BKE_asset_catalog_path.hh" #include "BKE_asset_library.hh" #include "BLI_string_utils.h" @@ -33,17 +34,10 @@ struct CatalogUniqueNameFnData { StringRef parent_path; }; -static std::string to_full_path(StringRef parent_path, StringRef name) -{ - return parent_path.is_empty() ? - std::string(name) : - std::string(parent_path) + AssetCatalogService::PATH_SEPARATOR + name; -} - static bool catalog_name_exists_fn(void *arg, const char *name) { CatalogUniqueNameFnData &fn_data = *static_cast<CatalogUniqueNameFnData *>(arg); - std::string fullpath = to_full_path(fn_data.parent_path, name); + CatalogPath fullpath = CatalogPath(fn_data.parent_path) / name; return fn_data.catalog_service.find_catalog_by_path(fullpath); } @@ -70,7 +64,7 @@ AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library, } std::string unique_name = catalog_name_ensure_unique(*catalog_service, name, parent_path); - std::string fullpath = to_full_path(parent_path, unique_name); + CatalogPath fullpath = CatalogPath(parent_path) / unique_name; return catalog_service->create_catalog(fullpath); } |