Blender V5.0
BLO_core_bhead.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <optional>
8
9#include "BLI_endian_switch.h"
10#include "BLI_sys_types.h"
11
12struct FileReader;
13
14struct BHead {
16 int code;
18 int SDNAnr;
25 const void *old;
30};
31
32struct BHead4 {
33 int code, len;
35 int SDNAnr, nr;
36};
37
39 int code, len;
41 int SDNAnr, nr;
42};
43
51
57
59#ifdef __BIG_ENDIAN__
60/* Big Endian */
61# define BLEND_MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d))
62#else
63/* Little Endian */
64# define BLEND_MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
65#endif
66
72enum {
77 BLO_CODE_DATA = BLEND_MAKE_ID('D', 'A', 'T', 'A'),
81 BLO_CODE_GLOB = BLEND_MAKE_ID('G', 'L', 'O', 'B'),
86 BLO_CODE_DNA1 = BLEND_MAKE_ID('D', 'N', 'A', '1'),
91 BLO_CODE_TEST = BLEND_MAKE_ID('T', 'E', 'S', 'T'),
96 BLO_CODE_REND = BLEND_MAKE_ID('R', 'E', 'N', 'D'),
101 BLO_CODE_USER = BLEND_MAKE_ID('U', 'S', 'E', 'R'),
105 BLO_CODE_ENDB = BLEND_MAKE_ID('E', 'N', 'D', 'B'),
106};
107
114std::optional<BHead> BLO_readfile_read_bhead(FileReader *file, BHeadType type);
115
123{
124 /* NOTE: this is endianness-sensitive. */
125 /* Switching endianness would be required to reduce the risk of two different 64bits pointers
126 * generating the same 32bits value. */
127 /* Behavior has to match #cast_pointer_64_to_32. */
128 ptr >>= 3;
129 return uint32_t(ptr);
130}
unsigned int uint
uint32_t uint32_from_uint64_ptr(uint64_t ptr)
BHeadType
@ BLO_CODE_ENDB
@ BLO_CODE_REND
@ BLO_CODE_TEST
@ BLO_CODE_GLOB
@ BLO_CODE_DATA
@ BLO_CODE_DNA1
@ BLO_CODE_USER
std::optional< BHead > BLO_readfile_read_bhead(FileReader *file, BHeadType type)
#define BLEND_MAKE_ID(a, b, c, d)
long long int int64_t
unsigned long long int uint64_t
int64_t len
int64_t nr
const void * old
PointerRNA * ptr
Definition wm_files.cc:4238