Blender V5.0
BLO_core_bhead.hh File Reference
#include <optional>
#include "BLI_endian_switch.h"
#include "BLI_sys_types.h"

Go to the source code of this file.

Classes

struct  BHead
struct  BHead4
struct  SmallBHead8
struct  LargeBHead8

Macros

#define BLEND_MAKE_ID(a, b, c, d)

Enumerations

enum class  BHeadType { BHead4 , SmallBHead8 , LargeBHead8 }
enum  {
  BLO_CODE_DATA = BLEND_MAKE_ID('D', 'A', 'T', 'A') , BLO_CODE_GLOB = BLEND_MAKE_ID('G', 'L', 'O', 'B') , BLO_CODE_DNA1 = BLEND_MAKE_ID('D', 'N', 'A', '1') , BLO_CODE_TEST = BLEND_MAKE_ID('T', 'E', 'S', 'T') ,
  BLO_CODE_REND = BLEND_MAKE_ID('R', 'E', 'N', 'D') , BLO_CODE_USER = BLEND_MAKE_ID('U', 'S', 'E', 'R') , BLO_CODE_ENDB = BLEND_MAKE_ID('E', 'N', 'D', 'B')
}

Functions

std::optional< BHeadBLO_readfile_read_bhead (FileReader *file, BHeadType type)
uint32_t uint32_from_uint64_ptr (uint64_t ptr)

Macro Definition Documentation

◆ BLEND_MAKE_ID

#define BLEND_MAKE_ID ( a,
b,
c,
d )
Value:
((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))

Make BHead.code from 4 chars.

Definition at line 64 of file BLO_core_bhead.hh.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Codes used for BHead.code.

These coexist with ID codes such as ID_OB, ID_SCE ... etc.

Enumerator
BLO_CODE_DATA 

Arbitrary allocated memory (typically owned by ID's, will be freed when there are no users).

BLO_CODE_GLOB 

Used for Global struct.

BLO_CODE_DNA1 

Used for storing the encoded SDNA string (decoded into an SDNA on load).

BLO_CODE_TEST 

Used to store thumbnail previews, written between #REND and #GLOB blocks, (ignored for regular file reading).

BLO_CODE_REND 

Used for RenderInfo, basic Scene and frame range info, can be easily read by other applications without writing a full blend file parser.

BLO_CODE_USER 

Used for UserDef, (user-preferences data). (written to BLENDER_STARTUP_FILE & BLENDER_USERPREF_FILE).

BLO_CODE_ENDB 

Terminate reading (no data).

Definition at line 72 of file BLO_core_bhead.hh.

◆ BHeadType

enum class BHeadType
strong
Enumerator
BHead4 
SmallBHead8 
LargeBHead8 

Definition at line 52 of file BLO_core_bhead.hh.

Function Documentation

◆ BLO_readfile_read_bhead()

std::optional< BHead > BLO_readfile_read_bhead ( FileReader * file,
BHeadType type )

Parse the next BHead in the file, increasing the file reader to after the BHead. This automatically converts the stored BHead (one of BHeadType) to the runtime BHead type.

Returns
The next #BHEad or #std::nullopt if the file is exhausted.

Definition at line 52 of file blo_core_bhead.cc.

References BHead4, bhead_from_bhead4(), bhead_from_large_bhead8(), bhead_from_small_bhead8(), BLO_CODE_DATA, BLO_CODE_ENDB, BHead4::code, LargeBHead8::code, SmallBHead8::code, LargeBHead8, FileReader::read, and SmallBHead8.

Referenced by blendthumb_extract_from_file_impl(), and get_bhead().

◆ uint32_from_uint64_ptr()

uint32_t uint32_from_uint64_ptr ( uint64_t ptr)
inline

Converts a BHead.old pointer from 64 to 32 bit. This can't work in the general case, but only when the lower 32 bits of all relevant 64 bit pointers are different. Otherwise two different pointers will map to the same, which will break things later on. There is no way to check for that here unfortunately.

Definition at line 122 of file BLO_core_bhead.hh.

References ptr.

Referenced by convert_pointer_array_64_to_32(), and old_ptr_from_uint64_ptr().