Blender V5.3
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
10#include "BLI_sys_types.hh"
11
12namespace blender {
13
14struct FileReader;
15
16struct BHead {
18 int code;
20 int SDNAnr;
27 const void *old;
32};
33
34struct BHead4 {
35 int code, len;
37 int SDNAnr, nr;
38};
39
41 int code, len;
43 int SDNAnr, nr;
44};
45
53
59
61#ifdef __BIG_ENDIAN__
62/* Big Endian */
63# define BLEND_MAKE_ID(a, b, c, d) (int(a) << 24 | int(b) << 16 | (c) << 8 | (d))
64#else
65/* Little Endian */
66# define BLEND_MAKE_ID(a, b, c, d) (int(d) << 24 | int(c) << 16 | (b) << 8 | (a))
67#endif
68
74enum {
79 BLO_CODE_DATA = BLEND_MAKE_ID('D', 'A', 'T', 'A'),
83 BLO_CODE_GLOB = BLEND_MAKE_ID('G', 'L', 'O', 'B'),
88 BLO_CODE_DNA1 = BLEND_MAKE_ID('D', 'N', 'A', '1'),
93 BLO_CODE_TEST = BLEND_MAKE_ID('T', 'E', 'S', 'T'),
98 BLO_CODE_REND = BLEND_MAKE_ID('R', 'E', 'N', 'D'),
103 BLO_CODE_USER = BLEND_MAKE_ID('U', 'S', 'E', 'R'),
107 BLO_CODE_ENDB = BLEND_MAKE_ID('E', 'N', 'D', 'B'),
108};
109
116std::optional<BHead> BLO_readfile_read_bhead(FileReader *file, BHeadType type);
117
125{
126 /* NOTE: this is endianness-sensitive. */
127 /* Switching endianness would be required to reduce the risk of two different 64bits pointers
128 * generating the same 32bits value. */
129 /* Behavior has to match #cast_pointer_64_to_32. */
130 ptr >>= 3;
131 return uint32_t(ptr);
132}
133
134} // namespace blender
#define BLEND_MAKE_ID(a, b, c, d)
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91
__int64 int64_t
Definition BKE_text.h:90
unsigned int uint
Definition BKE_text.h:55
std::optional< BHead > BLO_readfile_read_bhead(FileReader *file, BHeadType type)
unsigned int uint32_t
Definition BKE_text.h:81
uint32_t uint32_from_uint64_ptr(uint64_t ptr)
const void * old