1 #ifndef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 2 #error "Do not include binaryconversionprivate.h directly." 14 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 15 return (static_cast<int16>(value[0]) << 8 & 0xFF00) | (static_cast<int16>(value[1]) & 0x00FF);
17 return (static_cast<int16>(value[1]) << 8 & 0xFF00) | (static_cast<int16>(value[0]) & 0x00FF);
26 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 27 return (static_cast<uint16>(value[0]) << 8 & 0xFF00) | (static_cast<uint16>(value[1]) & 0x00FF);
29 return (static_cast<uint16>(value[1]) << 8 & 0xFF00) | (static_cast<uint16>(value[0]) & 0x00FF);
38 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 39 return (static_cast<int32>(value[0]) << 24 & 0xFF000000) | (static_cast<int32>(value[1]) << 16 & 0x00FF0000)
40 | (static_cast<int32>(value[2]) << 8 & 0x0000FF00) | (static_cast<int32>(value[3]) & 0x000000FF);
42 return (static_cast<int32>(value[3]) << 24 & 0xFF000000) | (static_cast<int32>(value[2]) << 16 & 0x00FF0000)
43 | (static_cast<int32>(value[1]) << 8 & 0x0000FF00) | (static_cast<int32>(value[0]) & 0x000000FF);
52 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 53 return (static_cast<uint32>(value[0]) << 16 & 0x00FF0000) | (static_cast<uint32>(value[1]) << 8 & 0x0000FF00)
54 | (static_cast<uint32>(value[2]) & 0x000000FF);
56 return (static_cast<uint32>(value[2]) << 16 & 0x00FF0000) | (static_cast<uint32>(value[1]) << 8 & 0x0000FF00)
57 | (static_cast<uint32>(value[0]) & 0x000000FF);
66 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 67 return (static_cast<uint32>(value[0]) << 24 & 0xFF000000) | (static_cast<uint32>(value[1]) << 16 & 0x00FF0000)
68 | (static_cast<uint32>(value[2]) << 8 & 0x0000FF00) | (static_cast<uint32>(value[3]) & 0x000000FF);
70 return (static_cast<uint32>(value[3]) << 24 & 0xFF000000) | (static_cast<uint32>(value[2]) << 16 & 0x00FF0000)
71 | (static_cast<uint32>(value[1]) << 8 & 0x0000FF00) | (static_cast<uint32>(value[0]) & 0x000000FF);
80 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 81 return (static_cast<int64>(value[0]) << 56 & 0xFF00000000000000) | (static_cast<int64>(value[1]) << 48 & 0x00FF000000000000)
82 | (static_cast<int64>(value[2]) << 40 & 0x0000FF0000000000) | (static_cast<int64>(value[3]) << 32 & 0x000000FF00000000)
83 | (static_cast<int64>(value[4]) << 24 & 0x00000000FF000000) | (static_cast<int64>(value[5]) << 16 & 0x0000000000FF0000)
84 | (static_cast<int64>(value[6]) << 8 & 0x000000000000FF00) | (static_cast<int64>(value[7]) & 0x00000000000000FF);
86 return (static_cast<int64>(value[7]) << 56 & 0xFF00000000000000) | (static_cast<int64>(value[6]) << 48 & 0x00FF000000000000)
87 | (static_cast<int64>(value[5]) << 40 & 0x0000FF0000000000) | (static_cast<int64>(value[4]) << 32 & 0x000000FF00000000)
88 | (static_cast<int64>(value[3]) << 24 & 0x00000000FF000000) | (static_cast<int64>(value[2]) << 16 & 0x0000000000FF0000)
89 | (static_cast<int64>(value[1]) << 8 & 0x000000000000FF00) | (static_cast<int64>(value[0]) & 0x00000000000000FF);
98 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 99 return (static_cast<uint64>(value[0]) << 56 & 0xFF00000000000000) | (static_cast<uint64>(value[1]) << 48 & 0x00FF000000000000)
100 | (static_cast<uint64>(value[2]) << 40 & 0x0000FF0000000000) | (static_cast<uint64>(value[3]) << 32 & 0x000000FF00000000)
101 | (static_cast<uint64>(value[4]) << 24 & 0x00000000FF000000) | (static_cast<uint64>(value[5]) << 16 & 0x0000000000FF0000)
102 | (static_cast<uint64>(value[6]) << 8 & 0x000000000000FF00) | (static_cast<uint64>(value[7]) & 0x00000000000000FF);
104 return (static_cast<uint64>(value[7]) << 56 & 0xFF00000000000000) | (static_cast<uint64>(value[6]) << 48 & 0x00FF000000000000)
105 | (static_cast<uint64>(value[5]) << 40 & 0x0000FF0000000000) | (static_cast<uint64>(value[4]) << 32 & 0x000000FF00000000)
106 | (static_cast<uint64>(value[3]) << 24 & 0x00000000FF000000) | (static_cast<uint64>(value[2]) << 16 & 0x0000000000FF0000)
107 | (static_cast<uint64>(value[1]) << 8 & 0x000000000000FF00) | (static_cast<uint64>(value[0]) & 0x00000000000000FF);
117 const char *
const c = reinterpret_cast<const char *>(&val);
118 return *reinterpret_cast<const float32 *>(c);
127 const char *
const c = reinterpret_cast<const char *>(&val);
128 return *reinterpret_cast<const float64 *const>(c);
136 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 137 outputbuffer[0] = static_cast<char>((value >> 8) & 0xFF);
138 outputbuffer[1] = static_cast<char>((value)&0xFF);
140 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
141 outputbuffer[0] = static_cast<char>((value)&0xFF);
150 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 151 outputbuffer[0] = static_cast<char>((value >> 8) & 0xFF);
152 outputbuffer[1] = static_cast<char>((value)&0xFF);
154 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
155 outputbuffer[0] = static_cast<char>((value)&0xFF);
165 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 166 outputbuffer[0] = static_cast<char>((value >> 16) & 0xFF);
167 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
168 outputbuffer[2] = static_cast<char>((value)&0xFF);
170 outputbuffer[2] = static_cast<char>((value >> 16) & 0xFF);
171 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
172 outputbuffer[0] = static_cast<char>((value)&0xFF);
181 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 182 outputbuffer[0] = static_cast<char>((value >> 24) & 0xFF);
183 outputbuffer[1] = static_cast<char>((value >> 16) & 0xFF);
184 outputbuffer[2] = static_cast<char>((value >> 8) & 0xFF);
185 outputbuffer[3] = static_cast<char>((value)&0xFF);
187 outputbuffer[3] = static_cast<char>((value >> 24) & 0xFF);
188 outputbuffer[2] = static_cast<char>((value >> 16) & 0xFF);
189 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
190 outputbuffer[0] = static_cast<char>((value)&0xFF);
199 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 200 outputbuffer[0] = static_cast<char>((value >> 24) & 0xFF);
201 outputbuffer[1] = static_cast<char>((value >> 16) & 0xFF);
202 outputbuffer[2] = static_cast<char>((value >> 8) & 0xFF);
203 outputbuffer[3] = static_cast<char>((value)&0xFF);
205 outputbuffer[3] = static_cast<char>((value >> 24) & 0xFF);
206 outputbuffer[2] = static_cast<char>((value >> 16) & 0xFF);
207 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
208 outputbuffer[0] = static_cast<char>((value)&0xFF);
217 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 218 outputbuffer[0] = static_cast<char>((value >> 56) & 0xFF);
219 outputbuffer[1] = static_cast<char>((value >> 48) & 0xFF);
220 outputbuffer[2] = static_cast<char>((value >> 40) & 0xFF);
221 outputbuffer[3] = static_cast<char>((value >> 32) & 0xFF);
222 outputbuffer[4] = static_cast<char>((value >> 24) & 0xFF);
223 outputbuffer[5] = static_cast<char>((value >> 16) & 0xFF);
224 outputbuffer[6] = static_cast<char>((value >> 8) & 0xFF);
225 outputbuffer[7] = static_cast<char>((value)&0xFF);
227 outputbuffer[7] = static_cast<char>((value >> 56) & 0xFF);
228 outputbuffer[6] = static_cast<char>((value >> 48) & 0xFF);
229 outputbuffer[5] = static_cast<char>((value >> 40) & 0xFF);
230 outputbuffer[4] = static_cast<char>((value >> 32) & 0xFF);
231 outputbuffer[3] = static_cast<char>((value >> 24) & 0xFF);
232 outputbuffer[2] = static_cast<char>((value >> 16) & 0xFF);
233 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
234 outputbuffer[0] = static_cast<char>((value)&0xFF);
243 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 244 outputbuffer[0] = static_cast<char>((value >> 56) & 0xFF);
245 outputbuffer[1] = static_cast<char>((value >> 48) & 0xFF);
246 outputbuffer[2] = static_cast<char>((value >> 40) & 0xFF);
247 outputbuffer[3] = static_cast<char>((value >> 32) & 0xFF);
248 outputbuffer[4] = static_cast<char>((value >> 24) & 0xFF);
249 outputbuffer[5] = static_cast<char>((value >> 16) & 0xFF);
250 outputbuffer[6] = static_cast<char>((value >> 8) & 0xFF);
251 outputbuffer[7] = static_cast<char>((value)&0xFF);
253 outputbuffer[7] = static_cast<char>((value >> 56) & 0xFF);
254 outputbuffer[6] = static_cast<char>((value >> 48) & 0xFF);
255 outputbuffer[5] = static_cast<char>((value >> 40) & 0xFF);
256 outputbuffer[4] = static_cast<char>((value >> 32) & 0xFF);
257 outputbuffer[3] = static_cast<char>((value >> 24) & 0xFF);
258 outputbuffer[2] = static_cast<char>((value >> 16) & 0xFF);
259 outputbuffer[1] = static_cast<char>((value >> 8) & 0xFF);
260 outputbuffer[0] = static_cast<char>((value)&0xFF);
269 char *c = reinterpret_cast<char *>(&value);
270 int32 i = *reinterpret_cast<int32 *>(c);
279 char *c = reinterpret_cast<char *>(&value);
280 int64 i = *reinterpret_cast<int64 *>(c);
284 #endif // CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL CPP_UTILITIES_EXPORT constexpr uint16 toUInt16(const char *value)
Returns a 16-bit unsigned integer converted from two bytes at a specified position in a char array.
CPP_UTILITIES_EXPORT constexpr uint32 toUInt24(const char *value)
Returns a 32-bit unsigned integer converted from three bytes at a specified position in a char array.
std::int64_t int64
signed 64-bit integer
#define CPP_UTILITIES_EXPORT
CPP_UTILITIES_EXPORT constexpr int32 toInt32(const char *value)
Returns a 32-bit signed integer converted from four bytes at a specified position in a char array.
std::uint64_t uint64
unsigned 64-bit integer
CPP_UTILITIES_EXPORT constexpr int16 toInt16(const char *value)
Returns a 16-bit signed integer converted from two bytes at a specified position in a char array.
CPP_UTILITIES_EXPORT float32 toFloat32(const char *value)
Returns a 32-bit floating point number converted from four bytes at a specified position in a char ar...
CPP_UTILITIES_EXPORT void getBytes24(uint32 value, char *outputbuffer)
Stores the specified 24-bit unsigned integer value at a specified position in a char array.
std::uint32_t uint32
unsigned 32-bit integer
CPP_UTILITIES_EXPORT float64 toFloat64(const char *value)
Returns a 64-bit floating point number converted from eight bytes at a specified position in a char a...
CPP_UTILITIES_EXPORT constexpr uint64 toUInt64(const char *value)
Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a char array.
CPP_UTILITIES_EXPORT constexpr int64 toInt64(const char *value)
Returns a 64-bit signed integer converted from eight bytes at a specified position in a char array.
std::int32_t int32
signed 32-bit integer
std::int16_t int16
signed 16-bit integer
std::uint16_t uint16
unsigned 16-bit integer
CPP_UTILITIES_EXPORT void getBytes(int16 value, char *outputbuffer)
Stores the specified 16-bit signed integer value at a specified position in a char array.
CPP_UTILITIES_EXPORT constexpr uint32 toUInt32(const char *value)
Returns a 32-bit unsigned integer converted from four bytes at a specified position in a char array.