Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/asset.cc
| Show All 20 Lines | |||||
| #include <cstring> | #include <cstring> | ||||
| #include "DNA_ID.h" | #include "DNA_ID.h" | ||||
| #include "DNA_asset_types.h" | #include "DNA_asset_types.h" | ||||
| #include "DNA_defaults.h" | #include "DNA_defaults.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_string_ref.hh" | |||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_asset.h" | #include "BKE_asset.h" | ||||
| #include "BKE_icons.h" | #include "BKE_icons.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BLO_read_write.h" | #include "BLO_read_write.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| using namespace blender; | |||||
| AssetMetaData *BKE_asset_metadata_create(void) | AssetMetaData *BKE_asset_metadata_create(void) | ||||
| { | { | ||||
| AssetMetaData *asset_data = (AssetMetaData *)MEM_callocN(sizeof(*asset_data), __func__); | AssetMetaData *asset_data = (AssetMetaData *)MEM_callocN(sizeof(*asset_data), __func__); | ||||
| memcpy(asset_data, DNA_struct_default_get(AssetMetaData), sizeof(*asset_data)); | memcpy(asset_data, DNA_struct_default_get(AssetMetaData), sizeof(*asset_data)); | ||||
| return asset_data; | return asset_data; | ||||
| } | } | ||||
| void BKE_asset_metadata_free(AssetMetaData **asset_data) | void BKE_asset_metadata_free(AssetMetaData **asset_data) | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | void BKE_asset_metadata_tag_remove(AssetMetaData *asset_data, AssetTag *tag) | ||||
| BLI_assert(BLI_listbase_count(&asset_data->tags) == asset_data->tot_tags); | BLI_assert(BLI_listbase_count(&asset_data->tags) == asset_data->tot_tags); | ||||
| } | } | ||||
| void BKE_asset_library_reference_init_default(AssetLibraryReference *library_ref) | void BKE_asset_library_reference_init_default(AssetLibraryReference *library_ref) | ||||
| { | { | ||||
| memcpy(library_ref, DNA_struct_default_get(AssetLibraryReference), sizeof(*library_ref)); | memcpy(library_ref, DNA_struct_default_get(AssetLibraryReference), sizeof(*library_ref)); | ||||
| } | } | ||||
| void BKE_asset_metadata_catalog_id_set(struct AssetMetaData *asset_data, const char *catalog_id) | |||||
| { | |||||
| constexpr size_t max_catalog_id_length = sizeof(asset_data->catalog_id); | |||||
| /* The substr() call is necessary to make copy() copy the first characters (instead of refusing | |||||
| * to copy and producing an empty string). */ | |||||
| StringRef trimmed_id = StringRef(catalog_id).trim().substr(0, max_catalog_id_length - 1); | |||||
| trimmed_id.copy(asset_data->catalog_id, max_catalog_id_length); | |||||
| /* Replace whitespace in the catalog ID with dashes. */ | |||||
| BLI_str_replace_char(asset_data->catalog_id, ' ', '-'); | |||||
| } | |||||
| /* Queries -------------------------------------------- */ | /* Queries -------------------------------------------- */ | ||||
| PreviewImage *BKE_asset_metadata_preview_get_from_id(const AssetMetaData *UNUSED(asset_data), | PreviewImage *BKE_asset_metadata_preview_get_from_id(const AssetMetaData *UNUSED(asset_data), | ||||
| const ID *id) | const ID *id) | ||||
| { | { | ||||
| return BKE_previewimg_id_get(id); | return BKE_previewimg_id_get(id); | ||||
| } | } | ||||
| Show All 31 Lines | |||||