Blender  V3.3
BLO_readfile.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 #pragma once
4 
5 #include "BLI_listbase.h"
6 #include "BLI_sys_types.h"
7 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 struct BHead;
18 struct BlendThumbnail;
19 struct Collection;
20 struct FileData;
21 struct LinkNode;
22 struct ListBase;
23 struct Main;
24 struct MemFile;
25 struct Object;
26 struct ReportList;
27 struct Scene;
28 struct UserDef;
29 struct View3D;
30 struct ViewLayer;
31 struct WorkSpace;
32 struct bScreen;
33 struct wmWindowManager;
34 
35 typedef struct BlendHandle BlendHandle;
36 
37 typedef struct WorkspaceConfigFileData {
38  struct Main *main; /* has to be freed when done reading file data */
39 
40  struct ListBase workspaces;
42 
43 /* -------------------------------------------------------------------- */
49 typedef enum eBlenFileType {
51  /* BLENFILETYPE_PUB = 2, */ /* UNUSED */
52  /* BLENFILETYPE_RUNTIME = 3, */ /* UNUSED */
54 
55 typedef struct BlendFileData {
56  struct Main *main;
57  struct UserDef *user;
58 
59  int fileflags;
60  int globalf;
61  char filepath[1024]; /* 1024 = FILE_MAX */
62 
63  struct bScreen *curscreen; /* TODO: think this isn't needed anymore? */
64  struct Scene *curscene;
65  struct ViewLayer *cur_view_layer; /* layer to activate in workspaces when reading without UI */
66 
69 
71  uint skip_flags : 3; /* #eBLOReadSkip */
73 
75  int undo_direction; /* #eUndoStepDir */
76 };
77 
78 typedef struct BlendFileReadReport {
79  /* General reports handling. */
81 
82  /* Timing information. */
83  struct {
84  double whole;
85  double libraries;
86  double lib_overrides;
90 
91  /* Count information. */
92  struct {
93  /* Some numbers of IDs that ended up in a specific state, or required some specific process
94  * during this file read. */
97  /* Some sub-categories of the above `missing_linked_id` counter. */
100 
101  /* Number of root override IDs that were resynced. */
103 
104  /* Number of proxies converted to library overrides. */
106  /* Number of proxies that failed to convert to library overrides. */
108  /* Number of sequencer strips that were not read because were in non-supported channels. */
110  } count;
111 
112  /* Number of libraries which had overrides that needed to be resynced, and a single linked list
113  * of those. */
118 
119 /* skip reading some data-block types (may want to skip screen data too). */
120 typedef enum eBLOReadSkip {
123  BLO_READ_SKIP_DATA = (1 << 1),
127 #define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
128 
137 BlendFileData *BLO_read_from_file(const char *filepath,
138  eBLOReadSkip skip_flags,
139  struct BlendFileReadReport *reports);
149 BlendFileData *BLO_read_from_memory(const void *mem,
150  int memsize,
151  eBLOReadSkip skip_flags,
152  struct ReportList *reports);
162 BlendFileData *BLO_read_from_memfile(struct Main *oldmain,
163  const char *filepath,
164  struct MemFile *memfile,
165  const struct BlendFileReadParams *params,
166  struct ReportList *reports);
167 
175 
178 /* -------------------------------------------------------------------- */
182 typedef struct BLODataBlockInfo {
183  char name[64]; /* MAX_NAME */
186 
194 BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct BlendFileReadReport *reports);
203  int memsize,
204  struct BlendFileReadReport *reports);
205 
217  int ofblocktype,
218 
219  bool use_assets_only,
220  int *r_tot_names);
232 struct LinkNode * /*BLODataBlockInfo */ BLO_blendhandle_get_datablock_info(BlendHandle *bh,
233  int ofblocktype,
234  bool use_assets_only,
235  int *r_tot_info_items);
245 struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev);
256  int ofblocktype,
257  const char *name);
266 
273 
276 void BLO_read_invalidate_message(BlendHandle *bh, struct Main *bmain, const char *message);
277 
287 #define BLO_read_assert_message(_check_expr, _ret_value, _bh, _bmain, _message) \
288  if (_check_expr) { \
289  BLO_read_invalidate_message((_bh), (_bmain), (_message)); \
290  return _ret_value; \
291  } \
292  (void)0
293 
296 #define BLO_GROUP_MAX 32
297 #define BLO_EMBEDDED_STARTUP_BLEND "<startup.blend>"
298 
306 bool BLO_has_bfile_extension(const char *str);
318 bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name);
319 
320 /* -------------------------------------------------------------------- */
329 typedef enum eBLOLibLinkFlags {
349 
355 typedef struct LibraryLink_Params {
357  struct Main *bmain;
359  int flag;
363  struct {
365  struct Scene *scene;
369  const struct View3D *v3d;
372 
374  struct Main *bmain,
375  int flag,
376  int id_tag_extra);
378  struct Main *bmain,
379  int flag,
380  int id_tag_extra,
381  struct Scene *scene,
382  struct ViewLayer *view_layer,
383  const struct View3D *v3d);
384 
395  const char *filepath,
396  const struct LibraryLink_Params *params);
406 struct ID *BLO_library_link_named_part(struct Main *mainl,
407  BlendHandle **bh,
408  short idcode,
409  const char *name,
410  const struct LibraryLink_Params *params);
420 void BLO_library_link_end(struct Main *mainl,
421  BlendHandle **bh,
422  const struct LibraryLink_Params *params);
423 
427 typedef struct TempLibraryContext {
429  struct Main *bmain_lib;
431  struct Main *bmain_base;
435  struct Library *lib;
436 
437  /* The ID datablock that was loaded. Is NULL if loading failed. */
438  struct ID *temp_id;
440 
442  const char *blend_file_path,
443  short idcode,
444  const char *idname,
445  struct ReportList *reports);
446 void BLO_library_temp_free(TempLibraryContext *temp_lib_ctx);
447 
450 void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
451 
452 /* internal function but we need to expose it */
457 void blo_lib_link_restore(struct Main *oldmain,
458  struct Main *newmain,
459  struct wmWindowManager *curwm,
460  struct Scene *curscene,
461  struct ViewLayer *cur_view_layer);
462 
463 typedef void (*BLOExpandDoitCallback)(void *fdhandle, struct Main *mainvar, void *idv);
464 
470 void BLO_main_expander(BLOExpandDoitCallback expand_doit_func);
478 void BLO_expand_main(void *fdhandle, struct Main *mainvar);
479 
493 void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template);
494 void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template);
495 
496 /* Disable unwanted experimental feature settings on startup. */
498 
507 struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath);
508 
509 /* datafiles (generated theme) */
510 extern const struct bTheme U_theme_default;
511 extern const struct UserDef U_default;
512 
513 #ifdef __cplusplus
514 }
515 #endif
unsigned int uint
Definition: BLI_sys_types.h:67
const struct UserDef U_default
struct TempLibraryContext TempLibraryContext
void(* BLOExpandDoitCallback)(void *fdhandle, struct Main *mainvar, void *idv)
Definition: BLO_readfile.h:463
struct PreviewImage * BLO_blendhandle_get_preview_for_id(BlendHandle *bh, int ofblocktype, const char *name)
void BLO_sanitize_experimental_features_userpref_blend(struct UserDef *userdef)
void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template)
void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template)
struct LinkNode * BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev)
BlendFileData * BLO_read_from_memfile(struct Main *oldmain, const char *filepath, struct MemFile *memfile, const struct BlendFileReadParams *params, struct ReportList *reports)
eBLOLibLinkFlags
Definition: BLO_readfile.h:329
@ BLO_LIBLINK_APPEND_RECURSIVE
Definition: BLO_readfile.h:339
@ BLO_LIBLINK_USE_PLACEHOLDERS
Definition: BLO_readfile.h:331
@ BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR
Definition: BLO_readfile.h:343
@ BLO_LIBLINK_OBDATA_INSTANCE
Definition: BLO_readfile.h:345
@ BLO_LIBLINK_APPEND_SET_FAKEUSER
Definition: BLO_readfile.h:335
@ BLO_LIBLINK_FORCE_INDIRECT
Definition: BLO_readfile.h:333
@ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE
Definition: BLO_readfile.h:341
@ BLO_LIBLINK_COLLECTION_INSTANCE
Definition: BLO_readfile.h:347
BlendHandle * BLO_blendhandle_from_file(const char *filepath, struct BlendFileReadReport *reports)
Definition: readblenentry.c:48
eBLOReadSkip
Definition: BLO_readfile.h:120
@ BLO_READ_SKIP_DATA
Definition: BLO_readfile.h:123
@ BLO_READ_SKIP_USERDEF
Definition: BLO_readfile.h:122
@ BLO_READ_SKIP_UNDO_OLD_MAIN
Definition: BLO_readfile.h:125
@ BLO_READ_SKIP_NONE
Definition: BLO_readfile.h:121
struct LinkNode * BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, bool use_assets_only, int *r_tot_names)
struct BlendHandle BlendHandle
Definition: BLO_readfile.h:35
void BLO_read_invalidate_message(BlendHandle *bh, struct Main *bmain, const char *message)
void BLO_main_expander(BLOExpandDoitCallback expand_doit_func)
Definition: readfile.c:4472
struct Main * BLO_library_link_begin(BlendHandle **bh, const char *filepath, const struct LibraryLink_Params *params)
Definition: readfile.c:4650
void BLO_library_temp_free(TempLibraryContext *temp_lib_ctx)
BlendFileData * BLO_read_from_file(const char *filepath, eBLOReadSkip skip_flags, struct BlendFileReadReport *reports)
void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
Definition: readfile.c:4787
void BLO_library_link_params_init(struct LibraryLink_Params *params, struct Main *bmain, int flag, int id_tag_extra)
Definition: readfile.c:4622
struct BLODataBlockInfo BLODataBlockInfo
void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params, struct Main *bmain, int flag, int id_tag_extra, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d)
Definition: readfile.c:4633
void BLO_expand_main(void *fdhandle, struct Main *mainvar)
Definition: readfile.c:4477
struct WorkspaceConfigFileData WorkspaceConfigFileData
void blo_lib_link_restore(struct Main *oldmain, struct Main *newmain, struct wmWindowManager *curwm, struct Scene *curscene, struct ViewLayer *cur_view_layer)
Definition: readfile.c:2819
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
Definition: readfile.c:1503
struct LinkNode * BLO_blendhandle_get_datablock_info(BlendHandle *bh, int ofblocktype, bool use_assets_only, int *r_tot_info_items)
struct ID * BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, short idcode, const char *name, const struct LibraryLink_Params *params)
Definition: readfile.c:4569
struct BlendFileReadReport BlendFileReadReport
bool BLO_has_bfile_extension(const char *str)
Definition: readfile.c:1497
struct LinkNode * BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
void * BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname)
Definition: readfile.c:4796
const struct bTheme U_theme_default
struct LibraryLink_Params LibraryLink_Params
void BLO_blendhandle_close(BlendHandle *bh)
struct BlendThumbnail * BLO_thumbnail_from_file(const char *filepath)
Definition: readfile.c:1563
BlendFileData * BLO_read_from_memory(const void *mem, int memsize, eBLOReadSkip skip_flags, struct ReportList *reports)
eBlenFileType
Definition: BLO_readfile.h:49
@ BLENFILETYPE_BLEND
Definition: BLO_readfile.h:50
TempLibraryContext * BLO_library_temp_load_id(struct Main *real_main, const char *blend_file_path, short idcode, const char *idname, struct ReportList *reports)
void BLO_blendfiledata_free(BlendFileData *bfd)
BlendHandle * BLO_blendhandle_from_memory(const void *mem, int memsize, struct BlendFileReadReport *reports)
Definition: readblenentry.c:57
struct BlendFileData BlendFileData
Scene scene
SyclQueue void void size_t num_bytes void
#define str(s)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
struct AssetMetaData * asset_data
Definition: BLO_readfile.h:184
char filepath[1024]
Definition: BLO_readfile.h:61
struct bScreen * curscreen
Definition: BLO_readfile.h:63
eBlenFileType type
Definition: BLO_readfile.h:67
struct Scene * curscene
Definition: BLO_readfile.h:64
struct ViewLayer * cur_view_layer
Definition: BLO_readfile.h:65
struct Main * main
Definition: BLO_readfile.h:56
struct UserDef * user
Definition: BLO_readfile.h:57
double lib_overrides_recursive_resync
Definition: BLO_readfile.h:88
struct ReportList * reports
Definition: BLO_readfile.h:80
bool do_resynced_lib_overrides_libraries_list
Definition: BLO_readfile.h:115
struct LinkNode * resynced_lib_overrides_libraries
Definition: BLO_readfile.h:116
int resynced_lib_overrides_libraries_count
Definition: BLO_readfile.h:114
int proxies_to_lib_overrides_failures
Definition: BLO_readfile.h:107
struct BlendFileReadReport::@134 count
double lib_overrides_resync
Definition: BLO_readfile.h:87
struct BlendFileReadReport::@133 duration
int proxies_to_lib_overrides_success
Definition: BLO_readfile.h:105
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
Definition: BKE_main.h:121
char filepath[1024]
Definition: BKE_main.h:124
struct Main * bmain_lib
Definition: BLO_readfile.h:429
struct ID * temp_id
Definition: BLO_readfile.h:438
struct LibraryLink_Params liblink_params
Definition: BLO_readfile.h:434
struct Main * bmain_base
Definition: BLO_readfile.h:431
struct Library * lib
Definition: BLO_readfile.h:435
struct BlendHandle * blendhandle
Definition: BLO_readfile.h:432
struct BlendFileReadReport bf_reports
Definition: BLO_readfile.h:433
struct ListBase workspaces
Definition: BLO_readfile.h:40
char app_template[64]
Definition: wm_files.c:1021