Blender  V2.93
Macros | Typedefs | Functions
BLO_read_write.h File Reference
#include "dna_type_offsets.h"
#include "DNA_windowmanager_types.h"

Go to the source code of this file.

Macros

#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)
 
#define BLO_read_data_address(reader, ptr_p)    *((void **)ptr_p) = BLO_read_get_new_data_address((reader), *(ptr_p))
 
#define BLO_read_packed_address(reader, ptr_p)    *((void **)ptr_p) = BLO_read_get_new_packed_address((reader), *(ptr_p))
 
#define BLO_read_id_address(reader, lib, id_ptr_p)    *((void **)id_ptr_p) = (void *)BLO_read_get_new_id_address((reader), (lib), (ID *)*(id_ptr_p))
 
#define BLO_expand(expander, id)   BLO_expand_id(expander, (struct ID *)id)
 

Typedefs

typedef struct BlendDataReader BlendDataReader
 
typedef struct BlendExpander BlendExpander
 
typedef struct BlendLibReader BlendLibReader
 
typedef struct BlendWriter BlendWriter
 
typedef void(* BlendReadListFn) (BlendDataReader *reader, void *data)
 

Functions

int BLO_get_struct_id_by_name (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, struct ListBase *list)
 
void BLO_write_struct_list_by_id (BlendWriter *writer, int struct_id, struct ListBase *list)
 
void blo_write_id_struct (BlendWriter *writer, int struct_id, const void *id_address, const struct ID *id)
 
void BLO_write_raw (BlendWriter *writer, size_t size_in_bytes, const void *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)
 
bool BLO_write_is_undo (BlendWriter *writer)
 
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)
 
void * BLO_read_get_new_packed_address (BlendDataReader *reader, const void *old_address)
 
void BLO_read_list_cb (BlendDataReader *reader, struct ListBase *list, BlendReadListFn callback)
 
void BLO_read_list (BlendDataReader *reader, struct ListBase *list)
 
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, void **ptr_p)
 
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, struct ListBase *list)
 
struct ReportListBLO_read_data_reports (BlendDataReader *reader)
 
IDBLO_read_get_new_id_address (BlendLibReader *reader, struct Library *lib, struct ID *id)
 
bool BLO_read_lib_is_undo (BlendLibReader *reader)
 
struct MainBLO_read_lib_get_main (BlendLibReader *reader)
 
struct ReportListBLO_read_lib_reports (BlendLibReader *reader)
 
void BLO_expand_id (BlendExpander *expander, struct ID *id)
 
void BLO_reportf_wrap (struct ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
 

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:

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.h.

Macro Definition Documentation

◆ BLO_expand

#define BLO_expand (   expander,
  id 
)    BLO_expand_id(expander, (struct ID *)id)

Definition at line 247 of file BLO_read_write.h.

◆ BLO_get_struct_id

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

Definition at line 97 of file BLO_read_write.h.

◆ BLO_read_data_address

#define BLO_read_data_address (   reader,
  ptr_p 
)     *((void **)ptr_p) = BLO_read_get_new_data_address((reader), *(ptr_p))

Definition at line 197 of file BLO_read_write.h.

◆ BLO_read_id_address

#define BLO_read_id_address (   reader,
  lib,
  id_ptr_p 
)     *((void **)id_ptr_p) = (void *)BLO_read_get_new_id_address((reader), (lib), (ID *)*(id_ptr_p))

Definition at line 230 of file BLO_read_write.h.

◆ BLO_read_packed_address

#define BLO_read_packed_address (   reader,
  ptr_p 
)     *((void **)ptr_p) = BLO_read_get_new_packed_address((reader), *(ptr_p))

Definition at line 199 of file BLO_read_write.h.

◆ BLO_write_id_struct

#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)

Definition at line 155 of file BLO_read_write.h.

◆ 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 102 of file BLO_read_write.h.

◆ 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: writefile.c:1328

Definition at line 131 of file BLO_read_write.h.

◆ 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: writefile.c:1336

Definition at line 138 of file BLO_read_write.h.

◆ 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: writefile.c:1314

Definition at line 110 of file BLO_read_write.h.

◆ 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: writefile.c:1322

Definition at line 117 of file BLO_read_write.h.

◆ BLO_write_struct_list

#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)

Definition at line 147 of file BLO_read_write.h.

Typedef Documentation

◆ BlendDataReader

Definition at line 1 of file BLO_read_write.h.

◆ BlendExpander

typedef struct BlendExpander BlendExpander

Definition at line 1 of file BLO_read_write.h.

◆ BlendLibReader

Definition at line 1 of file BLO_read_write.h.

◆ BlendReadListFn

typedef void(* BlendReadListFn) (BlendDataReader *reader, void *data)

Definition at line 202 of file BLO_read_write.h.

◆ BlendWriter

typedef struct BlendWriter BlendWriter

Definition at line 1 of file BLO_read_write.h.

Function Documentation

◆ BLO_expand_id()

void BLO_expand_id ( BlendExpander expander,
struct ID id 
)

Definition at line 5805 of file readfile.c.

References expand_doit, BlendExpander::fd, and BlendExpander::main.

◆ BLO_get_struct_id_by_name()

int BLO_get_struct_id_by_name ( BlendWriter writer,
const char *  struct_name 
)

◆ BLO_read_data_globmap_add()

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

Definition at line 5775 of file readfile.c.

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

Referenced by window_manager_blend_read_data().

◆ BLO_read_data_is_undo()

bool BLO_read_data_is_undo ( BlendDataReader reader)

◆ BLO_read_data_reports()

struct ReportList* BLO_read_data_reports ( BlendDataReader reader)

Definition at line 5785 of file readfile.c.

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

Referenced by BKE_modifier_blend_read_data().

◆ BLO_read_double_array()

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

◆ BLO_read_float3_array()

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

Definition at line 5683 of file readfile.c.

References BLO_read_float_array().

Referenced by blendRead().

◆ BLO_read_float_array()

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

◆ BLO_read_get_new_data_address()

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

◆ BLO_read_get_new_data_address_no_us()

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

Definition at line 5605 of file readfile.c.

References BlendDataReader::fd, and newdataadr_no_us().

Referenced by direct_link_area().

◆ BLO_read_get_new_id_address()

ID* BLO_read_get_new_id_address ( BlendLibReader reader,
struct Library lib,
struct ID id 
)

◆ BLO_read_get_new_packed_address()

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

Definition at line 5610 of file readfile.c.

References BlendDataReader::fd, and newpackedadr().

◆ BLO_read_glob_list()

void BLO_read_glob_list ( BlendDataReader reader,
struct ListBase list 
)

Definition at line 5780 of file readfile.c.

References BlendDataReader::fd, and link_glob_list().

Referenced by scene_blend_read_data().

◆ BLO_read_int32_array()

void BLO_read_int32_array ( BlendDataReader reader,
int  array_size,
int32_t **  ptr_p 
)

◆ BLO_read_lib_get_main()

struct Main* BLO_read_lib_get_main ( BlendLibReader reader)

◆ BLO_read_lib_is_undo()

bool BLO_read_lib_is_undo ( BlendLibReader reader)

Definition at line 5790 of file readfile.c.

References BlendLibReader::fd, FileData::memfile, and NULL.

Referenced by BKE_pose_blend_read_lib(), and ntreeBlendReadLib().

◆ BLO_read_lib_reports()

struct ReportList* BLO_read_lib_reports ( BlendLibReader reader)

Definition at line 5800 of file readfile.c.

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

Referenced by object_blend_read_lib(), and scene_blend_read_lib().

◆ BLO_read_list()

void BLO_read_list ( BlendDataReader reader,
struct ListBase list 
)

◆ BLO_read_list_cb()

void BLO_read_list_cb ( BlendDataReader reader,
ListBase list,
BlendReadListFn  callback 
)

Updates all ->prev and ->next pointers of the list elements. Updates the list->first and list->last pointers. When not NULL, calls the callback on every element.

Definition at line 5630 of file readfile.c.

References BLI_listbase_is_empty(), BLO_read_data_address, callback, ListBase::first, ListBase::last, Link::next, NULL, and Link::prev.

Referenced by BLO_read_list(), direct_link_id_common(), direct_link_id_override_property_cb(), and direct_link_pointcache().

◆ BLO_read_pointer_array()

void BLO_read_pointer_array ( BlendDataReader reader,
void **  ptr_p 
)

◆ BLO_read_requires_endian_switch()

bool BLO_read_requires_endian_switch ( BlendDataReader reader)

◆ BLO_read_uint32_array()

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

◆ BLO_reportf_wrap()

void BLO_reportf_wrap ( struct ReportList reports,
ReportType  type,
const char *  format,
  ... 
)

◆ BLO_write_double_array()

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

Definition at line 1383 of file writefile.c.

References BLO_write_raw().

◆ BLO_write_float3_array()

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

Definition at line 1393 of file writefile.c.

References BLO_write_raw().

Referenced by blendWrite(), and write_mdisps().

◆ BLO_write_float_array()

void BLO_write_float_array ( BlendWriter writer,
uint  num,
const float data_ptr 
)

◆ blo_write_id_struct()

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

◆ BLO_write_int32_array()

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

Definition at line 1368 of file writefile.c.

References BLO_write_raw().

Referenced by blendWrite().

◆ BLO_write_is_undo()

bool BLO_write_is_undo ( BlendWriter writer)

◆ BLO_write_pointer_array()

void BLO_write_pointer_array ( BlendWriter writer,
uint  num,
const void *  data_ptr 
)

◆ BLO_write_raw()

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

◆ BLO_write_string()

void BLO_write_string ( BlendWriter writer,
const char *  data_ptr 
)

◆ 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 
)

Definition at line 1336 of file writefile.c.

References 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 1328 of file writefile.c.

References 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 
)

◆ 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 
)

Definition at line 1314 of file writefile.c.

References BLO_write_struct_at_address_by_id_with_filecode(), and DATA.

◆ 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 
)

Definition at line 1322 of file writefile.c.

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,
struct ListBase list 
)

Definition at line 1342 of file writefile.c.

References 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,
struct ListBase list 
)

◆ BLO_write_uint32_array()

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

Definition at line 1373 of file writefile.c.

References BLO_write_raw().

Referenced by BKE_previewimg_blend_write(), and blendWrite().