Blender V4.3
BLO_read_write.hh File Reference
#include "dna_type_offsets.h"
#include "DNA_windowmanager_types.h"
#include "BLI_function_ref.hh"
#include "BLI_implicit_sharing.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 

Functions

Blend Read Lib API

This API does almost the same as the Blend Read Data API. However, now only pointers to ID data blocks are updated.

IDBLO_read_get_new_id_address (BlendLibReader *reader, ID *self_id, const bool is_linked_only, ID *id) ATTR_NONNULL(2)
 
IDBLO_read_get_new_id_address_from_session_uid (BlendLibReader *reader, uint session_uid) ATTR_NONNULL(1)
 
bool BLO_read_lib_is_undo (BlendLibReader *reader)
 
MainBLO_read_lib_get_main (BlendLibReader *reader)
 
BlendFileReadReportBLO_read_lib_reports (BlendLibReader *reader)
 
Report API
void BLO_reportf_wrap (BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
 

Blend Write API

Most functions fall into one of two categories. Either they write a DNA struct or a raw memory buffer to the .blend file.

It is safe to pass NULL as data_ptr. In this case nothing will be stored.

DNA Struct Writing

Functions dealing with DNA structs begin with BLO_write_struct_*.

DNA struct types can be identified in different ways:

  • Run-time Name: The name is provided as const char *.
  • Compile-time Name: The name is provided at compile time. This is more efficient.
  • Struct ID: Every DNA struct type has an integer ID that can be queried with BLO_get_struct_id_by_name. Providing this ID can be a useful optimization when many structs of the same type are stored AND if those structs are not in a continuous array.

Often only a single instance of a struct is written at once. However, sometimes it is necessary to write arrays or linked lists. Separate functions for that are provided as well.

There is a special macro for writing id structs: BLO_write_id_struct. Those are handled differently from other structs.

Raw Data Writing

At the core there is BLO_write_raw, which can write arbitrary memory buffers to the file. The code that reads this data might have to correct its byte-order. For the common cases there are convenience functions that write and read arrays of simple types such as int32. Those will correct endianness automatically.

#define BLO_get_struct_id(writer, struct_name)   SDNA_TYPE_FROM_STRUCT(struct_name)
 
#define BLO_write_struct(writer, struct_name, data_ptr)    BLO_write_struct_by_id(writer, BLO_get_struct_id(writer, struct_name), data_ptr)
 
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
 
#define BLO_write_struct_at_address_with_filecode(writer, filecode, struct_name, address, data_ptr)
 
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
 
#define BLO_write_struct_array_at_address(writer, struct_name, array_size, address, data_ptr)
 
#define BLO_write_struct_list(writer, struct_name, list_ptr)    BLO_write_struct_list_by_id(writer, BLO_get_struct_id(writer, struct_name), list_ptr)
 
#define BLO_write_id_struct(writer, struct_name, id_address, id)    blo_write_id_struct(writer, BLO_get_struct_id(writer, struct_name), id_address, id)
 
int BLO_get_struct_id_by_name (const BlendWriter *writer, const char *struct_name)
 
void BLO_write_struct_by_name (BlendWriter *writer, const char *struct_name, const void *data_ptr)
 
void BLO_write_struct_by_id (BlendWriter *writer, int struct_id, const void *data_ptr)
 
void BLO_write_struct_at_address_by_id (BlendWriter *writer, int struct_id, const void *address, const void *data_ptr)
 
void BLO_write_struct_at_address_by_id_with_filecode (BlendWriter *writer, int filecode, int struct_id, const void *address, const void *data_ptr)
 
void BLO_write_struct_array_by_name (BlendWriter *writer, const char *struct_name, int array_size, const void *data_ptr)
 
void BLO_write_struct_array_by_id (BlendWriter *writer, int struct_id, int array_size, const void *data_ptr)
 
void BLO_write_struct_array_at_address_by_id (BlendWriter *writer, int struct_id, int array_size, const void *address, const void *data_ptr)
 
void BLO_write_struct_list_by_name (BlendWriter *writer, const char *struct_name, ListBase *list)
 
void BLO_write_struct_list_by_id (BlendWriter *writer, int struct_id, const ListBase *list)
 
void blo_write_id_struct (BlendWriter *writer, int struct_id, const void *id_address, const ID *id)
 
BLO_Write_IDBufferBLO_write_allocate_id_buffer ()
 
void BLO_write_init_id_buffer_from_id (BLO_Write_IDBuffer *id_buffer, ID *id, const bool is_undo)
 
IDBLO_write_get_id_buffer_temp_id (BLO_Write_IDBuffer *id_buffer)
 
void BLO_write_destroy_id_buffer (BLO_Write_IDBuffer **id_buffer)
 
void BLO_write_raw (BlendWriter *writer, size_t size_in_bytes, const void *data_ptr)
 
void BLO_write_char_array (BlendWriter *writer, uint num, const char *data_ptr)
 
void BLO_write_int8_array (BlendWriter *writer, uint num, const int8_t *data_ptr)
 
void BLO_write_uint8_array (BlendWriter *writer, uint num, const uint8_t *data_ptr)
 
void BLO_write_int32_array (BlendWriter *writer, uint num, const int32_t *data_ptr)
 
void BLO_write_uint32_array (BlendWriter *writer, uint num, const uint32_t *data_ptr)
 
void BLO_write_float_array (BlendWriter *writer, uint num, const float *data_ptr)
 
void BLO_write_double_array (BlendWriter *writer, uint num, const double *data_ptr)
 
void BLO_write_float3_array (BlendWriter *writer, uint num, const float *data_ptr)
 
void BLO_write_pointer_array (BlendWriter *writer, uint num, const void *data_ptr)
 
void BLO_write_string (BlendWriter *writer, const char *data_ptr)
 
void BLO_write_shared (BlendWriter *writer, const void *data, size_t approximate_size_in_bytes, const blender::ImplicitSharingInfo *sharing_info, blender::FunctionRef< void()> write_fn)
 
bool BLO_write_is_undo (BlendWriter *writer)
 

Blend Read Data API

Generally, for every BLO_write_* call there should be a corresponding BLO_read_* call.

Most BLO_read_* functions get a pointer to a pointer as argument. That allows the function to update the pointer to its new value.

When the given pointer points to a memory buffer that was not stored in the file, the pointer is updated to be NULL. When it was pointing to NULL before, it will stay that way.

Examples of matching calls:

BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms);
BLO_read_struct(reader, ClothSimSettings, &clmd->sim_parms);
BLO_write_struct_list(writer, TimeMarker, &action->markers);
BLO_read_struct_list(reader, TimeMarker, &action->markers);
BLO_write_int32_array(writer, hmd->totindex, hmd->indexar);
BLO_read_int32_array(reader, hmd->totindex, &hmd->indexar);
void BLO_write_int32_array(BlendWriter *writer, uint num, const int32_t *data_ptr)
void BLO_read_int32_array(BlendDataReader *reader, int array_size, int32_t **ptr_p)
Definition readfile.cc:4947
#define BLO_write_struct(writer, struct_name, data_ptr)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_write_struct_list(writer, struct_name, list_ptr)
#define BLO_read_struct(reader, struct_name, ptr_p)

Avoid using the generic BLO_read_data_address (and low-level API like BLO_read_get_new_data_address) when possible, use the typed functions instead. Only data written with BLO_write_raw should typically be read with BLO_read_data_address.

#define BLO_read_data_address(reader, ptr_p)    *((void **)ptr_p) = BLO_read_get_new_data_address((reader), *(ptr_p))
 
#define BLO_read_struct(reader, struct_name, ptr_p)
 
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
 
#define BLO_read_struct_list(reader, struct_name, list)    BLO_read_struct_list_with_size(reader, sizeof(struct_name), list)
 
void * BLO_read_get_new_data_address (BlendDataReader *reader, const void *old_address)
 
void * BLO_read_get_new_data_address_no_us (BlendDataReader *reader, const void *old_address, size_t expected_size)
 
void * BLO_read_struct_array_with_size (BlendDataReader *reader, const void *old_address, size_t expected_size)
 
void * BLO_read_struct_by_name_array (BlendDataReader *reader, const char *struct_name, uint32_t items_num, const void *old_address)
 
void BLO_read_struct_list_with_size (BlendDataReader *reader, size_t expected_elem_size, ListBase *list)
 
void BLO_read_char_array (BlendDataReader *reader, int array_size, char **ptr_p)
 
void BLO_read_int8_array (BlendDataReader *reader, int array_size, int8_t **ptr_p)
 
void BLO_read_uint8_array (BlendDataReader *reader, int array_size, uint8_t **ptr_p)
 
void BLO_read_int32_array (BlendDataReader *reader, int array_size, int32_t **ptr_p)
 
void BLO_read_uint32_array (BlendDataReader *reader, int array_size, uint32_t **ptr_p)
 
void BLO_read_float_array (BlendDataReader *reader, int array_size, float **ptr_p)
 
void BLO_read_float3_array (BlendDataReader *reader, int array_size, float **ptr_p)
 
void BLO_read_double_array (BlendDataReader *reader, int array_size, double **ptr_p)
 
void BLO_read_pointer_array (BlendDataReader *reader, int array_size, void **ptr_p)
 
void BLO_read_string (BlendDataReader *reader, char **ptr_p)
 
void BLO_read_string (BlendDataReader *reader, char *const *ptr_p)
 
blender::ImplicitSharingInfoAndData blo_read_shared_impl (BlendDataReader *reader, const void **ptr_p, blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn)
 
template<typename T >
const blender::ImplicitSharingInfoBLO_read_shared (BlendDataReader *reader, T **data_ptr, blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn)
 
int BLO_read_fileversion_get (BlendDataReader *reader)
 
bool BLO_read_requires_endian_switch (BlendDataReader *reader)
 
bool BLO_read_data_is_undo (BlendDataReader *reader)
 
void BLO_read_data_globmap_add (BlendDataReader *reader, void *oldaddr, void *newaddr)
 
void BLO_read_glob_list (BlendDataReader *reader, ListBase *list)
 
BlendFileReadReportBLO_read_data_reports (BlendDataReader *reader)
 
struct LibraryBLO_read_data_current_library (BlendDataReader *reader)
 

Detailed Description

This file contains an API that allows different parts of Blender to define what data is stored in .blend files.

Four callbacks have to be provided to fully implement .blend I/O for a piece of data. One of those is related to file writing and three for file reading. Reading requires multiple callbacks, due to the way linking between files works.

Brief description of the individual callbacks:

  • Blend Write: Define which structs and memory buffers are saved.
  • Blend Read Data: Loads structs and memory buffers from file and updates pointers them.
  • Blend Read Lib: Updates pointers to ID data blocks.
  • Blend Expand: Defines which other data blocks should be loaded (possibly from other files). Note, this is now handled as part of the foreach-id iteration. This needs to be implemented for DNA data that has references to data-blocks.

Each of these callbacks uses a different API functions.

Some parts of Blender, e.g. modifiers, don't require you to implement all four callbacks. Instead only the first two are necessary. The other two are handled by general ID management. In the future, we might want to get rid of those two callbacks entirely, but for now they are necessary.

Definition in file BLO_read_write.hh.

Macro Definition Documentation

◆ BLO_get_struct_id

#define BLO_get_struct_id ( writer,
struct_name )   SDNA_TYPE_FROM_STRUCT(struct_name)

Definition at line 89 of file BLO_read_write.hh.

◆ BLO_read_data_address

◆ BLO_read_struct

#define BLO_read_struct ( reader,
struct_name,
ptr_p )
Value:
*((void **)ptr_p) = BLO_read_struct_array_with_size( \
reader, *((void **)ptr_p), sizeof(struct_name))
void * BLO_read_struct_array_with_size(BlendDataReader *reader, const void *old_address, size_t expected_size)
Definition readfile.cc:4865

Definition at line 287 of file BLO_read_write.hh.

Referenced by blender::bke::action_blend_read_data(), armature_blend_read_data(), BKE_animdata_blend_read_data(), BKE_asset_metadata_read(), BKE_collection_blend_read_data(), BKE_color_managed_view_settings_blend_read_data(), BKE_constraint_blend_read_data(), BKE_fcurve_blend_read_data(), BKE_gpencil_blend_read_data(), BKE_gpencil_modifier_blend_read_data(), BKE_lightprobe_cache_blend_read(), BKE_modifier_blend_read_data(), BKE_packedfile_blend_read(), BKE_paint_blend_read_data(), BKE_particle_system_blend_read_data(), BKE_pose_blend_read_data(), BKE_ptcache_blend_read_data(), BKE_screen_area_map_blend_read_data(), BKE_screen_blend_read_data(), BKE_screen_view3d_shading_blend_read_data(), BKE_view_layer_blend_read_data(), blend_read(), blend_read(), blend_read(), blend_read(), blend_read(), blend_read(), blender::blend_read(), blo_read_asset_data_block(), brush_blend_read_data(), curve_blend_read_data(), CustomData_blend_read(), direct_link_area(), direct_link_bone_collection(), direct_link_bones(), direct_link_id_common(), direct_link_id_embedded_id(), direct_link_keymapitem(), direct_link_layer_collections(), direct_link_linestyle_alpha_modifier(), direct_link_linestyle_color_modifier(), direct_link_linestyle_thickness_modifier(), direct_link_moviePlaneTracks(), blender::bke::direct_link_node_socket(), direct_link_paint_helper(), direct_link_region(), file_space_blend_read_data(), graph_space_blend_read_data(), image_blend_read_data(), ipo_blend_read_data(), blender::bke::node_interface::item_types::item_read_data(), light_blend_read_data(), linestyle_blend_read_data(), mask_blend_read_data(), material_blend_read_data(), movieclip_blend_read_data(), nla_space_blend_read_data(), blender::ed::space_node::node_space_blend_read_data(), blender::bke::node_tree_blend_read_data(), object_blend_read_data(), particle_settings_blend_read_data(), read_drawing_array(), blender::modifier::greasepencil::read_influence_data(), read_layer_tree(), read_ui_data(), read_userdef(), blender::ed::asset::shelf::regiondata_blend_read_data(), scene_blend_read_data(), SEQ_modifier_blend_read_data(), seq_read_data_cb(), shapekey_blend_read_data(), blender::ed::spreadsheet::spreadsheet_blend_read_data(), text_blend_read_data(), texture_blend_read_data(), view3d_space_blend_read_data(), window_manager_blend_read_data(), workspace_blend_read_data(), and world_blend_read_data().

◆ BLO_read_struct_array

#define BLO_read_struct_array ( reader,
struct_name,
array_size,
ptr_p )
Value:
*((void **)ptr_p) = BLO_read_struct_array_with_size( \
reader, *((void **)ptr_p), sizeof(struct_name) * (array_size))

Definition at line 290 of file BLO_read_write.hh.

Referenced by animviz_motionpath_blend_read_data(), BKE_curvemapping_blend_read(), BKE_curveprofile_blend_read(), BKE_defvert_blend_read(), BKE_fcurve_blend_read_data(), BKE_fmodifiers_blend_read_data(), BKE_gpencil_blend_read_data(), BKE_gpencil_modifier_blend_read_data(), BKE_particle_system_blend_read_data(), blend_read(), blend_read(), blender::blend_read(), blender::nodes::BakeItemsAccessor::blend_read_data(), blender::nodes::CaptureAttributeItemsAccessor::blend_read_data(), blender::nodes::ForeachGeometryElementGenerationItemsAccessor::blend_read_data(), blender::nodes::ForeachGeometryElementInputItemsAccessor::blend_read_data(), blender::nodes::ForeachGeometryElementMainItemsAccessor::blend_read_data(), blender::nodes::IndexSwitchItemsAccessor::blend_read_data(), blender::nodes::MenuSwitchItemsAccessor::blend_read_data(), blender::nodes::RepeatItemsAccessor::blend_read_data(), blender::nodes::SimulationItemsAccessor::blend_read_data(), blend_read_layer_data(), curve_blend_read_data(), CustomData_blend_read(), direct_link_moviePlaneTracks(), direct_link_movieReconstruction(), direct_link_movieTracks(), direct_link_pointcache_mem(), IDP_DirectLinkIDPArray(), ipo_blend_read_data(), lattice_blend_read_data(), lightprobe_grid_cache_frame_blend_read(), mask_blend_read_data(), mesh_blend_read_data(), blender::bke::node_tree_blend_read_data(), paint_curve_blend_read_data(), read_layer(), read_ui_data(), seq_read_data_cb(), and blender::ed::spreadsheet::spreadsheet_blend_read_data().

◆ BLO_read_struct_list

#define BLO_read_struct_list ( reader,
struct_name,
list )    BLO_read_struct_list_with_size(reader, sizeof(struct_name), list)

Definition at line 314 of file BLO_read_write.hh.

Referenced by blender::bke::action_blend_read_data(), armature_blend_read_data(), BKE_animdata_blend_read_data(), BKE_asset_catalog_path_list_blend_read_data(), BKE_asset_metadata_read(), BKE_collection_blend_read_data(), BKE_constraint_blend_read_data(), BKE_fcurve_blend_read_data(), BKE_gpencil_blend_read_data(), BKE_gpencil_modifier_blend_read_data(), BKE_keyingsets_blend_read_data(), BKE_modifier_blend_read_data(), BKE_nla_blend_read_data(), BKE_paint_blend_read_data(), BKE_particle_system_blend_read_data(), BKE_pose_blend_read_data(), BKE_ptcache_blend_read_data(), BKE_screen_area_map_blend_read_data(), BKE_shaderfx_blend_read_data(), BKE_view_layer_blend_read_data(), BKE_viewer_path_blend_read_data(), blend_data_read_nla_strips(), blender::bke::CurvesGeometry::blend_read(), cache_file_blend_read_data(), camera_blend_read_data(), console_blend_read_data(), curve_blend_read_data(), direct_link_area(), direct_link_bone_collection(), direct_link_bones(), direct_link_id_common(), direct_link_id_override_property(), direct_link_layer_collections(), direct_link_moviePlaneTracks(), direct_link_movieTracks(), direct_link_nlastrips(), direct_link_panel_list(), direct_link_pointcache(), direct_link_pointcache_mem(), direct_link_region(), grease_pencil_blend_read_data(), IDP_DirectLinkGroup(), image_blend_read_data(), ipo_blend_read_data(), lattice_blend_read_data(), linestyle_blend_read_data(), link_recurs_seq(), mask_blend_read_data(), mesh_blend_read_data(), metaball_blend_read_data(), movieclip_blend_read_data(), blender::ed::space_node::node_space_blend_read_data(), blender::bke::node_tree_blend_read_data(), object_blend_read_data(), palette_blend_read_data(), particle_settings_blend_read_data(), read_bone_collections(), read_layer(), read_layer_tree_group(), read_userdef(), blender::ed::asset::shelf::regiondata_blend_read_data(), scene_blend_read_data(), SEQ_modifier_blend_read_data(), seq_read_data_cb(), shapekey_blend_read_data(), blender::ed::spreadsheet::spreadsheet_blend_read_data(), text_blend_read_data(), window_manager_blend_read_data(), and workspace_blend_read_data().

◆ BLO_write_id_struct

◆ BLO_write_struct

#define BLO_write_struct ( writer,
struct_name,
data_ptr )    BLO_write_struct_by_id(writer, BLO_get_struct_id(writer, struct_name), data_ptr)

Definition at line 96 of file BLO_read_write.hh.

Referenced by blender::bke::action_blend_write(), action_space_blend_write(), animviz_motionpath_blend_write(), BKE_animdata_blend_write(), BKE_asset_catalog_path_list_blend_write(), BKE_asset_metadata_write(), BKE_asset_weak_reference_write(), BKE_collection_blend_write_nolib(), BKE_constraint_blend_write(), BKE_curvemapping_blend_write(), BKE_curveprofile_blend_write(), BKE_defbase_blend_write(), BKE_fcurve_blend_write_data(), BKE_gpencil_modifier_blend_write(), BKE_id_blend_write(), BKE_keyingsets_blend_write(), BKE_lightprobe_cache_blend_write(), BKE_modifier_blend_write(), BKE_nla_blend_write(), BKE_packedfile_blend_write(), BKE_particle_system_blend_write(), BKE_pose_blend_write(), BKE_ptcache_blend_write(), BKE_screen_area_map_blend_write(), BKE_view_layer_blend_write(), BKE_viewer_path_blend_write(), blend_write(), blend_write(), blend_write(), blend_write(), blend_write(), blender::blend_write(), brush_blend_write(), buttons_space_blend_write(), cache_file_blend_write(), camera_blend_write(), clip_space_blend_write(), console_space_blend_write(), curve_blend_write(), CustomData_blend_write(), file_space_blend_write(), graph_space_blend_write(), greasepencil_blend_write(), IDP_BlendWrite(), image_blend_write(), image_space_blend_write(), info_space_blend_write(), blender::bke::node_interface::item_types::item_write_struct(), linestyle_blend_write(), mask_blend_write(), material_blend_write(), metaball_blend_write(), movieclip_blend_write(), nla_space_blend_write(), blender::ed::space_node::node_space_blend_write(), blender::bke::node_tree_blend_write(), object_blend_write(), particle_settings_blend_write(), blender::ed::asset::shelf::regiondata_blend_write(), scene_blend_write(), script_space_blend_write(), SEQ_modifier_blend_write(), seq_write_data_cb(), sequencer_space_blend_write(), blender::ed::asset::shelf::settings_blend_write(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::bke::node_interface::socket_types::socket_data_write_impl(), blender::ed::spreadsheet::spreadsheet_blend_write(), statusbar_space_blend_write(), text_blend_write(), text_space_blend_write(), texture_blend_write(), topbar_space_blend_write(), userpref_space_blend_write(), view3d_space_blend_write(), window_manager_blend_write(), world_blend_write(), write_area(), write_boid_state(), write_bone(), write_bone_collection(), write_drawing_array(), write_keymapitem(), write_layer(), write_layer_collections(), write_layer_tree_group(), write_linestyle_color_modifiers(), write_moviePlaneTracks(), write_movieTracks(), blender::bke::write_node_socket(), blender::bke::write_node_socket_default_value(), blender::bke::forward_compat::write_node_socket_interface(), write_panel_list(), write_region(), blender::ed::outliner::write_space_outliner(), write_ui_data(), write_uilist(), and write_userdef().

◆ BLO_write_struct_array

#define BLO_write_struct_array ( writer,
struct_name,
array_size,
data_ptr )
Value:
writer, BLO_get_struct_id(writer, struct_name), array_size, data_ptr)
#define BLO_get_struct_id(writer, struct_name)
void BLO_write_struct_array_by_id(BlendWriter *writer, int struct_id, int array_size, const void *data_ptr)

Definition at line 131 of file BLO_read_write.hh.

Referenced by animviz_motionpath_blend_write(), BKE_curvemapping_curves_blend_write(), BKE_curveprofile_blend_write(), BKE_defvert_blend_write(), BKE_fcurve_blend_write_data(), BKE_fmodifiers_blend_write(), BKE_gpencil_modifier_blend_write(), BKE_particle_system_blend_write(), BKE_ptcache_blend_write(), blend_write(), blend_write(), blender::blend_write(), blender::nodes::BakeItemsAccessor::blend_write(), blender::nodes::CaptureAttributeItemsAccessor::blend_write(), blender::nodes::ForeachGeometryElementGenerationItemsAccessor::blend_write(), blender::nodes::ForeachGeometryElementInputItemsAccessor::blend_write(), blender::nodes::ForeachGeometryElementMainItemsAccessor::blend_write(), blender::nodes::IndexSwitchItemsAccessor::blend_write(), blender::nodes::MenuSwitchItemsAccessor::blend_write(), blender::nodes::RepeatItemsAccessor::blend_write(), blender::nodes::SimulationItemsAccessor::blend_write(), curve_blend_write(), greasepencil_blend_write(), IDP_WriteIDPArray(), lattice_blend_write(), lightprobe_grid_cache_frame_blend_write(), mask_blend_write(), mesh_blend_write(), blender::bke::node_tree_blend_write(), paint_curve_blend_write(), seq_write_data_cb(), blender::ed::spreadsheet::spreadsheet_blend_write(), write_grid_paint_mask(), write_layer(), write_mdisps(), write_moviePlaneTracks(), write_movieReconstruction(), write_movieTracks(), and write_ui_data().

◆ BLO_write_struct_array_at_address

#define BLO_write_struct_array_at_address ( writer,
struct_name,
array_size,
address,
data_ptr )
Value:
writer, BLO_get_struct_id(writer, struct_name), array_size, address, data_ptr)
void BLO_write_struct_array_at_address_by_id(BlendWriter *writer, int struct_id, int array_size, const void *address, const void *data_ptr)

Definition at line 140 of file BLO_read_write.hh.

Referenced by CustomData_blend_write(), and blender::ed::outliner::write_space_outliner().

◆ BLO_write_struct_at_address

#define BLO_write_struct_at_address ( writer,
struct_name,
address,
data_ptr )
Value:
writer, BLO_get_struct_id(writer, struct_name), address, data_ptr)
void BLO_write_struct_at_address_by_id(BlendWriter *writer, int struct_id, const void *address, const void *data_ptr)

Definition at line 106 of file BLO_read_write.hh.

Referenced by BKE_previewimg_blend_write(), blend_write(), blend_write(), blend_write(), blend_write(), light_blend_write(), linestyle_blend_write(), material_blend_write(), scene_blend_write(), shapekey_blend_write(), texture_blend_write(), world_blend_write(), and blender::ed::outliner::write_space_outliner().

◆ BLO_write_struct_at_address_with_filecode

#define BLO_write_struct_at_address_with_filecode ( writer,
filecode,
struct_name,
address,
data_ptr )
Value:
writer, filecode, BLO_get_struct_id(writer, struct_name), address, data_ptr)
void BLO_write_struct_at_address_by_id_with_filecode(BlendWriter *writer, int filecode, int struct_id, const void *address, const void *data_ptr)

Definition at line 115 of file BLO_read_write.hh.

Referenced by screen_blend_write().

◆ BLO_write_struct_list

Function Documentation

◆ BLO_get_struct_id_by_name()

int BLO_get_struct_id_by_name ( const BlendWriter * writer,
const char * struct_name )

Mapping between names and ids.

Definition at line 1900 of file writefile.cc.

References DNA_struct_find_with_alias(), WriteData::sdna, and BlendWriter::wd.

Referenced by BLO_write_struct_array_by_name(), and BLO_write_struct_list_by_name().

◆ BLO_read_char_array()

void BLO_read_char_array ( BlendDataReader * reader,
int array_size,
char ** ptr_p )

◆ BLO_read_data_current_library()

struct Library * BLO_read_data_current_library ( BlendDataReader * reader)

◆ BLO_read_data_globmap_add()

void BLO_read_data_globmap_add ( BlendDataReader * reader,
void * oldaddr,
void * newaddr )

Definition at line 5140 of file readfile.cc.

References BlendDataReader::fd, FileData::globmap, and oldnewmap_insert().

Referenced by window_manager_blend_read_data().

◆ BLO_read_data_is_undo()

◆ BLO_read_data_reports()

BlendFileReadReport * BLO_read_data_reports ( BlendDataReader * reader)

Definition at line 5150 of file readfile.cc.

References BlendDataReader::fd, and FileData::reports.

Referenced by BKE_modifier_blend_read_data(), and link_recurs_seq().

◆ BLO_read_double_array()

void BLO_read_double_array ( BlendDataReader * reader,
int array_size,
double ** ptr_p )

◆ BLO_read_fileversion_get()

int BLO_read_fileversion_get ( BlendDataReader * reader)

◆ BLO_read_float3_array()

void BLO_read_float3_array ( BlendDataReader * reader,
int array_size,
float ** ptr_p )

◆ BLO_read_float_array()

◆ BLO_read_get_new_data_address()

void * BLO_read_get_new_data_address ( BlendDataReader * reader,
const void * old_address )

Definition at line 4852 of file readfile.cc.

References BlendDataReader::fd, and newdataadr().

◆ BLO_read_get_new_data_address_no_us()

void * BLO_read_get_new_data_address_no_us ( BlendDataReader * reader,
const void * old_address,
size_t expected_size )

Does not consider the read data as 'used'. It will still be freed by readfile code at the end of the reading process, if no other 'real' usage was detected for it.

Typical valid usages include:

  • Restoring pointers to a specific item in an array or list (usually 'active' item e.g.). The found item is expected to also be read as part of its array/list storage reading.
  • Doing temporary access to deprecated data as part of some versioning code.

Definition at line 4857 of file readfile.cc.

References blo_verify_data_address(), BlendDataReader::fd, and newdataadr_no_us().

Referenced by BKE_modifier_blend_read_data(), modifier_replace_with_fluid(), blender::ed::outliner::outliner_space_blend_read_data(), and scene_blend_read_data().

◆ BLO_read_get_new_id_address()

ID * BLO_read_get_new_id_address ( BlendLibReader * reader,
ID * self_id,
const bool is_linked_only,
ID * id )

Search for the new address of given id, during library linking part of blend-file reading process.

Parameters
self_idthe ID owner of the given id pointer. Note that it may be an embedded ID.
is_linked_onlyIf true, only return found pointer if it is a linked ID. Used to prevent linked data to point to local IDs.
Returns
the new address of the given ID pointer, or null if not found.

Definition at line 4885 of file readfile.cc.

References BlendLibReader::fd, and newlibadr().

Referenced by lib_link_cb().

◆ BLO_read_get_new_id_address_from_session_uid()

ID * BLO_read_get_new_id_address_from_session_uid ( BlendLibReader * reader,
uint session_uid )

Search for the new address of the ID for the given session_uid.

Only IDs existing in the newly read Main will be returned. If no matching session_uid in new main can be found, nullptr is returned.

This expected to be used during library-linking and/or 'undo_preserve' processes in undo case (i.e. memfile reading), typically to find a valid value (or nullptr) for ID pointers values coming from the previous, existing Main data, when it is preserved in newly read Main. See e.g. the scene_undo_preserve code-path.

Definition at line 4893 of file readfile.cc.

References BKE_main_idmap_lookup_uid(), BlendLibReader::fd, and FileData::new_idmap_uid.

Referenced by scene_foreach_toolsettings_id_pointer_process().

◆ BLO_read_glob_list()

void BLO_read_glob_list ( BlendDataReader * reader,
ListBase * list )

Definition at line 5145 of file readfile.cc.

References BlendDataReader::fd, and link_glob_list().

Referenced by scene_blend_read_data().

◆ BLO_read_int32_array()

◆ BLO_read_int8_array()

void BLO_read_int8_array ( BlendDataReader * reader,
int array_size,
int8_t ** ptr_p )

◆ BLO_read_lib_get_main()

Main * BLO_read_lib_get_main ( BlendLibReader * reader)

◆ BLO_read_lib_is_undo()

bool BLO_read_lib_is_undo ( BlendLibReader * reader)

◆ BLO_read_lib_reports()

BlendFileReadReport * BLO_read_lib_reports ( BlendLibReader * reader)

◆ BLO_read_pointer_array()

◆ BLO_read_requires_endian_switch()

◆ BLO_read_shared()

template<typename T >
const blender::ImplicitSharingInfo * BLO_read_shared ( BlendDataReader * reader,
T ** data_ptr,
blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn )

Check if there is any shared data for the given data pointer. If yes, return the existing sharing-info. If not, call the provided function to actually read the data now.

Definition at line 347 of file BLO_read_write.hh.

References blo_read_shared_impl(), blender::ImplicitSharingInfoAndData::data, and blender::ImplicitSharingInfoAndData::sharing_info.

Referenced by BKE_packedfile_blend_read(), blender::bke::CurvesGeometry::blend_read(), CustomData_blend_read(), and mesh_blend_read_data().

◆ blo_read_shared_impl()

blender::ImplicitSharingInfoAndData blo_read_shared_impl ( BlendDataReader * reader,
const void ** ptr_p,
blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn )

Referenced by BLO_read_shared().

◆ BLO_read_string() [1/2]

void BLO_read_string ( BlendDataReader * reader,
char ** ptr_p )

◆ BLO_read_string() [2/2]

void BLO_read_string ( BlendDataReader * reader,
char *const * ptr_p )

Definition at line 5016 of file readfile.cc.

References BLO_read_string().

◆ BLO_read_struct_array_with_size()

void * BLO_read_struct_array_with_size ( BlendDataReader * reader,
const void * old_address,
size_t expected_size )

The 'main' read function and helper macros for non-basic data types.

NOTE: Currently the usage of the type info is very minimal/basic, it merely does a lose check on the data size.

Definition at line 4865 of file readfile.cc.

References blo_verify_data_address(), BlendDataReader::fd, and newdataadr().

Referenced by BLO_read_char_array(), BLO_read_double_array(), BLO_read_float_array(), BLO_read_int32_array(), BLO_read_int8_array(), BLO_read_struct_by_name_array(), BLO_read_struct_list_with_size(), BLO_read_uint32_array(), and BLO_read_uint8_array().

◆ BLO_read_struct_by_name_array()

void * BLO_read_struct_by_name_array ( BlendDataReader * reader,
const char * struct_name,
uint32_t items_num,
const void * old_address )

◆ BLO_read_struct_list_with_size()

void BLO_read_struct_list_with_size ( BlendDataReader * reader,
size_t expected_elem_size,
ListBase * list )

◆ BLO_read_uint32_array()

void BLO_read_uint32_array ( BlendDataReader * reader,
int array_size,
uint32_t ** ptr_p )

◆ BLO_read_uint8_array()

void BLO_read_uint8_array ( BlendDataReader * reader,
int array_size,
uint8_t ** ptr_p )

Definition at line 4935 of file readfile.cc.

References BLO_read_struct_array_with_size().

Referenced by blend_read_layer_data().

◆ BLO_reportf_wrap()

void BLO_reportf_wrap ( BlendFileReadReport * reports,
eReportType type,
const char * format,
... )

This function ensures that reports are printed, in the case of library linking errors this is important!

NOTE(@ideasman42) a kludge but better than doubling up on prints, we could alternatively have a versions of a report function which forces printing.

Referenced by BKE_modifier_blend_read_data(), do_versions_after_linking_400(), object_blend_read_after_liblink(), scene_blend_read_after_liblink(), and setup_app_data().

◆ BLO_write_allocate_id_buffer()

◆ BLO_write_char_array()

void BLO_write_char_array ( BlendWriter * writer,
uint num,
const char * data_ptr )

Slightly 'safer' code to write arrays of basic types data.

Definition at line 1906 of file writefile.cc.

References BLO_write_raw().

Referenced by console_space_blend_write(), IDP_WriteString(), and object_blend_write().

◆ BLO_write_destroy_id_buffer()

void BLO_write_destroy_id_buffer ( BLO_Write_IDBuffer ** id_buffer)

◆ BLO_write_double_array()

void BLO_write_double_array ( BlendWriter * writer,
uint num,
const double * data_ptr )

Definition at line 1936 of file writefile.cc.

References BLO_write_raw().

Referenced by IDP_WriteArray(), and write_ui_data().

◆ BLO_write_float3_array()

void BLO_write_float3_array ( BlendWriter * writer,
uint num,
const float * data_ptr )

◆ BLO_write_float_array()

◆ BLO_write_get_id_buffer_temp_id()

ID * BLO_write_get_id_buffer_temp_id ( BLO_Write_IDBuffer * id_buffer)

◆ blo_write_id_struct()

void blo_write_id_struct ( BlendWriter * writer,
int struct_id,
const void * id_address,
const ID * id )

Write id struct.

Definition at line 1895 of file writefile.cc.

References GS, BlendWriter::wd, and writestruct_at_address_nr().

◆ BLO_write_init_id_buffer_from_id()

void BLO_write_init_id_buffer_from_id ( BLO_Write_IDBuffer * id_buffer,
ID * id,
const bool is_undo )

◆ BLO_write_int32_array()

void BLO_write_int32_array ( BlendWriter * writer,
uint num,
const int32_t * data_ptr )

Definition at line 1921 of file writefile.cc.

References BLO_write_raw().

Referenced by blend_write(), blend_write(), IDP_WriteArray(), write_layer(), and write_ui_data().

◆ BLO_write_int8_array()

void BLO_write_int8_array ( BlendWriter * writer,
uint num,
const int8_t * data_ptr )

◆ BLO_write_is_undo()

◆ BLO_write_pointer_array()

◆ BLO_write_raw()

void BLO_write_raw ( BlendWriter * writer,
size_t size_in_bytes,
const void * data_ptr )

Write raw data.

Warning
Avoid using this function if possible. There are only a very few cases in current code where it is actually needed (e.g. the ShapeKey's data, since its items size varies depending on the type of geometry owning it, see shapekey_blend_write).
Data written with this call have no type information attached to them in the blend-file. The main consequence is that there will be no handling of endianness conversion for them in readfile code. Basic types array functions (like BLO_write_int8_array etc.) also use BLO_write_raw internally, but if their matching read function is used to load the data (like BLO_read_int8_array), the read function will take care of endianness conversion.

Definition at line 1823 of file writefile.cc.

References BLO_CODE_DATA, BlendWriter::wd, and writedata().

Referenced by BLO_write_char_array(), BLO_write_double_array(), BLO_write_float3_array(), BLO_write_float_array(), BLO_write_int32_array(), BLO_write_int8_array(), BLO_write_pointer_array(), BLO_write_string(), BLO_write_uint32_array(), BLO_write_uint8_array(), and shapekey_blend_write().

◆ BLO_write_shared()

void BLO_write_shared ( BlendWriter * writer,
const void * data,
size_t approximate_size_in_bytes,
const blender::ImplicitSharingInfo * sharing_info,
blender::FunctionRef< void()> write_fn )

Check if the data can be written more efficiently by making use of implicit-sharing. If yes, the user count of the sharing-info is increased making the data immutable. The provided callback should serialize the potentially shared data. It is only called when necessary.

Parameters
approximate_size_in_bytesUsed to be able to approximate how large the undo step is in total.
write_fnUse the #BlendWrite to serialize the potentially shared data.

Definition at line 1958 of file writefile.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::ImplicitSharingInfo::add_user(), BLO_write_is_undo(), MemFileSharedStorage::map, WriteData::mem, WriteData::per_id_written_shared_addresses, MemFile::shared_storage, MemFile::size, blender::ImplicitSharingInfo::strong_users(), BlendWriter::wd, and MemFileWriteData::written_memfile.

Referenced by BKE_packedfile_blend_write(), blender::bke::CurvesGeometry::blend_write(), CustomData_blend_write(), and mesh_blend_write().

◆ BLO_write_string()

◆ BLO_write_struct_array_at_address_by_id()

void BLO_write_struct_array_at_address_by_id ( BlendWriter * writer,
int struct_id,
int array_size,
const void * address,
const void * data_ptr )

Write struct array at address.

Definition at line 1874 of file writefile.cc.

References BLO_CODE_DATA, BlendWriter::wd, and writestruct_at_address_nr().

◆ BLO_write_struct_array_by_id()

void BLO_write_struct_array_by_id ( BlendWriter * writer,
int struct_id,
int array_size,
const void * data_ptr )

Definition at line 1866 of file writefile.cc.

References BLO_CODE_DATA, BlendWriter::wd, and writestruct_nr().

Referenced by BLO_write_struct_array_by_name().

◆ BLO_write_struct_array_by_name()

void BLO_write_struct_array_by_name ( BlendWriter * writer,
const char * struct_name,
int array_size,
const void * data_ptr )

Write struct array.

Definition at line 1833 of file writefile.cc.

References BLO_get_struct_id_by_name(), BLO_write_struct_array_by_id(), CLOG_ERROR, LOG, and UNLIKELY.

Referenced by blend_write_layer_data(), and BLO_write_struct_by_name().

◆ BLO_write_struct_at_address_by_id()

void BLO_write_struct_at_address_by_id ( BlendWriter * writer,
int struct_id,
const void * address,
const void * data_ptr )

Write single struct at address.

Definition at line 1851 of file writefile.cc.

References BLO_CODE_DATA, and BLO_write_struct_at_address_by_id_with_filecode().

◆ BLO_write_struct_at_address_by_id_with_filecode()

void BLO_write_struct_at_address_by_id_with_filecode ( BlendWriter * writer,
int filecode,
int struct_id,
const void * address,
const void * data_ptr )

Write single struct at address and specify a file-code.

Definition at line 1860 of file writefile.cc.

References BlendWriter::wd, and writestruct_at_address_nr().

Referenced by BLO_write_struct_at_address_by_id().

◆ BLO_write_struct_by_id()

void BLO_write_struct_by_id ( BlendWriter * writer,
int struct_id,
const void * data_ptr )

◆ BLO_write_struct_by_name()

void BLO_write_struct_by_name ( BlendWriter * writer,
const char * struct_name,
const void * data_ptr )

◆ BLO_write_struct_list_by_id()

void BLO_write_struct_list_by_id ( BlendWriter * writer,
int struct_id,
const ListBase * list )

Definition at line 1880 of file writefile.cc.

References BLO_CODE_DATA, BlendWriter::wd, and writelist_nr().

Referenced by BLO_write_struct_list_by_name().

◆ BLO_write_struct_list_by_name()

void BLO_write_struct_list_by_name ( BlendWriter * writer,
const char * struct_name,
ListBase * list )

Write struct list.

Definition at line 1885 of file writefile.cc.

References BLO_get_struct_id_by_name(), BLO_write_struct_list_by_id(), CLOG_ERROR, LOG, and UNLIKELY.

◆ BLO_write_uint32_array()

void BLO_write_uint32_array ( BlendWriter * writer,
uint num,
const uint32_t * data_ptr )

Definition at line 1926 of file writefile.cc.

References BLO_write_raw().

Referenced by BKE_previewimg_blend_write(), BKE_ptcache_blend_write(), and blend_write().

◆ BLO_write_uint8_array()

void BLO_write_uint8_array ( BlendWriter * writer,
uint num,
const uint8_t * data_ptr )

Definition at line 1916 of file writefile.cc.

References BLO_write_raw().

Referenced by blend_write_layer_data().