20 #define BYTE_ORDER 1234
21#elif defined(__MACH__) && defined(__APPLE__)
22 #include <machine/endian.h>
23#elif defined(__FreeBSD__) || defined(__DragonFly__)
24 #include <sys/endian.h>
28 #error "Can't detect endian (missing header)"
31 #define LITTLE_ENDIAN 1234
34 #define BIG_ENDIAN 4321
36#if !defined(BYTE_ORDER) && defined(_BYTE_ORDER)
37 #define BYTE_ORDER _BYTE_ORDER
38#elif !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
39 #define BYTE_ORDER __BYTE_ORDER
42#define FIXEDPOINT_FACTOR 1000.0f
51#define F1000_MIN ((float)(s32)((float)(-0x7FFFFFFF - 1) / FIXEDPOINT_FACTOR))
52#define F1000_MAX ((float)(s32)((float)(0x7FFFFFFF) / FIXEDPOINT_FACTOR))
54#define STRING_MAX_LEN 0xFFFF
55#define WIDE_STRING_MAX_LEN 0xFFFF
57#define LONG_STRING_MAX_LEN (64 * 1024 * 1024)
66inline u16
readU16(
const u8 *data)
69 memcpy(&val, data, 2);
73inline u32
readU32(
const u8 *data)
76 memcpy(&val, data, 4);
80inline u64
readU64(
const u8 *data)
83 memcpy(&val, data, 8);
90 memcpy(data, &val, 2);
96 memcpy(data, &val, 4);
101 u64 val = htobe64(i);
102 memcpy(data, &val, 8);
111 ((u16)data[0] << 8) | ((u16)data[1] << 0);
117 ((u32)data[0] << 24) | ((u32)data[1] << 16) |
118 ((u32)data[2] << 8) | ((u32)data[3] << 0);
124 ((u64)data[0] << 56) | ((u64)data[1] << 48) |
125 ((u64)data[2] << 40) | ((u64)data[3] << 32) |
126 ((u64)data[4] << 24) | ((u64)data[5] << 16) |
127 ((u64)data[6] << 8) | ((u64)data[7] << 0);
132 data[0] = (i >> 8) & 0xFF;
133 data[1] = (i >> 0) & 0xFF;
138 data[0] = (i >> 24) & 0xFF;
139 data[1] = (i >> 16) & 0xFF;
140 data[2] = (i >> 8) & 0xFF;
141 data[3] = (i >> 0) & 0xFF;
146 data[0] = (i >> 56) & 0xFF;
147 data[1] = (i >> 48) & 0xFF;
148 data[2] = (i >> 40) & 0xFF;
149 data[3] = (i >> 32) & 0xFF;
150 data[4] = (i >> 24) & 0xFF;
151 data[5] = (i >> 16) & 0xFF;
152 data[6] = (i >> 8) & 0xFF;
153 data[7] = (i >> 0) & 0xFF;
162 return ((u8)data[0] << 0);
380#define MAKE_STREAM_READ_FXN(T, N, S) \
381 inline T read ## N(std::istream &is) \
384 is.read(buf, sizeof(buf)); \
385 return read ## N((u8 *)buf); \
388#define MAKE_STREAM_WRITE_FXN(T, N, S) \
389 inline void write ## N(std::ostream &os, T val) \
392 write ## N((u8 *)buf, val); \
393 os.write(buf, sizeof(buf)); \
Definition exceptions.h:45
u32 f32Tou32Slow(f32 f)
Definition ieee_float.cpp:64
FloatType getFloatSerializationType()
Definition ieee_float.cpp:95
f32 u32Tof32Slow(u32 i)
Definition ieee_float.cpp:35
FloatType
Definition ieee_float.h:10
@ FLOATTYPE_UNKNOWN
Definition ieee_float.h:11
@ FLOATTYPE_SLOW
Definition ieee_float.h:12
@ FLOATTYPE_SYSTEM
Definition ieee_float.h:13
core::vector2d< s32 > v2s32
Definition irr_v2d.h:13
core::vector2d< s16 > v2s16
Definition irr_v2d.h:12
core::vector2d< f32 > v2f
Definition irr_v2d.h:11
core::vector3d< s32 > v3s32
Definition irr_v3d.h:15
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
std::string serializeJsonStringIfNeeded(std::string_view s)
Definition serialize.cpp:251
v2s16 readV2S16(const u8 *data)
Definition serialize.h:215
void writeU16(u8 *data, u16 i)
Definition serialize.h:130
u32 readU32(const u8 *data)
Definition serialize.h:114
void writeV3S16(u8 *data, v3s16 p)
Definition serialize.h:336
std::string deSerializeJsonString(std::istream &is)
Definition serialize.cpp:220
v2s32 readV2S32(const u8 *data)
Definition serialize.h:232
void writeF1000(u8 *data, f32 i)
Definition serialize.h:302
void writeS16(u8 *data, s16 i)
Definition serialize.h:287
s64 readS64(const u8 *data)
Definition serialize.h:180
#define FIXEDPOINT_FACTOR
Definition serialize.h:42
void writeV2F32(u8 *data, v2f p)
Definition serialize.h:363
void writeF32(u8 *data, f32 i)
Definition serialize.h:308
void writeU64(u8 *data, u64 i)
Definition serialize.h:144
s32 readS32(const u8 *data)
Definition serialize.h:175
std::string deSerializeString32(std::istream &is)
Definition serialize.cpp:79
u8 readU8(const u8 *data)
Definition serialize.h:160
void writeV2S32(u8 *data, v2s32 p)
Definition serialize.h:343
video::SColor readARGB8(const u8 *data)
Definition serialize.h:209
std::string deSerializeJsonStringIfNeeded(std::istream &is)
Definition serialize.cpp:260
v3f readV3F1000(const u8 *data)
Definition serialize.h:249
v3s16 readV3S16(const u8 *data)
Definition serialize.h:223
void writeV2S16(u8 *data, v2s16 p)
Definition serialize.h:330
f32 readF32(const u8 *data)
Definition serialize.h:190
f32 readF1000(const u8 *data)
Definition serialize.h:185
void writeARGB8(u8 *data, video::SColor p)
Definition serialize.h:325
std::string serializeJsonString(std::string_view plain)
Definition serialize.cpp:110
#define MAKE_STREAM_READ_FXN(T, N, S)
Definition serialize.h:380
FloatType g_serialize_f32_type
Definition serialize.cpp:15
u64 readU64(const u8 *data)
Definition serialize.h:121
void writeU32(u8 *data, u32 i)
Definition serialize.h:136
void writeV3F32(u8 *data, v3f p)
Definition serialize.h:369
std::string serializeString16(std::string_view plain)
Definition serialize.cpp:22
void writeS8(u8 *data, s8 i)
Definition serialize.h:282
std::string deSerializeString16(std::istream &is)
Definition serialize.cpp:38
void writeV3S32(u8 *data, v3s32 p)
Definition serialize.h:349
std::string serializeString32(std::string_view plain)
Definition serialize.cpp:64
#define F1000_MIN
Definition serialize.h:51
u16 readU16(const u8 *data)
Definition serialize.h:108
v2f readV2F32(const u8 *data)
Definition serialize.h:258
float clampToF1000(float v)
Definition serialize.h:438
v3s32 readV3S32(const u8 *data)
Definition serialize.h:240
void writeV3F1000(u8 *data, v3f p)
Definition serialize.h:356
#define MAKE_STREAM_WRITE_FXN(T, N, S)
Definition serialize.h:388
void writeU8(u8 *data, u8 i)
Definition serialize.h:277
v3f readV3F32(const u8 *data)
Definition serialize.h:266
void writeS32(u8 *data, s32 i)
Definition serialize.h:292
s8 readS8(const u8 *data)
Definition serialize.h:165
s16 readS16(const u8 *data)
Definition serialize.h:170
#define F1000_MAX
Definition serialize.h:52
void writeS64(u8 *data, s64 i)
Definition serialize.h:297
static std::string p(std::string path)
Definition test_filesys.cpp:53