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<std::int16_t>(value[0]) << 8 & 0xFF00) | (static_cast<std::int16_t>(value[1]) & 0x00FF);
17 return (static_cast<std::int16_t>(value[1]) << 8 & 0xFF00) | (static_cast<std::int16_t>(value[0]) & 0x00FF);
26 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
27 return (static_cast<std::uint16_t>(value[0]) << 8 & 0xFF00) | (static_cast<std::uint16_t>(value[1]) & 0x00FF);
29 return (static_cast<std::uint16_t>(value[1]) << 8 & 0xFF00) | (static_cast<std::uint16_t>(value[0]) & 0x00FF);
38 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
39 return (static_cast<std::int32_t>(value[0]) << 24 & 0xFF000000) | (static_cast<std::int32_t>(value[1]) << 16 & 0x00FF0000)
40 | (static_cast<std::int32_t>(value[2]) << 8 & 0x0000FF00) | (static_cast<std::int32_t>(value[3]) & 0x000000FF);
42 return (static_cast<std::int32_t>(value[3]) << 24 & 0xFF000000) | (static_cast<std::int32_t>(value[2]) << 16 & 0x00FF0000)
43 | (static_cast<std::int32_t>(value[1]) << 8 & 0x0000FF00) | (static_cast<std::int32_t>(value[0]) & 0x000000FF);
52 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
53 return (static_cast<std::uint32_t>(value[0]) << 16 & 0x00FF0000) | (static_cast<std::uint32_t>(value[1]) << 8 & 0x0000FF00)
54 | (static_cast<std::uint32_t>(value[2]) & 0x000000FF);
56 return (static_cast<std::uint32_t>(value[2]) << 16 & 0x00FF0000) | (static_cast<std::uint32_t>(value[1]) << 8 & 0x0000FF00)
57 | (static_cast<std::uint32_t>(value[0]) & 0x000000FF);
66 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
67 return (static_cast<std::uint32_t>(value[0]) << 24 & 0xFF000000) | (static_cast<std::uint32_t>(value[1]) << 16 & 0x00FF0000)
68 | (static_cast<std::uint32_t>(value[2]) << 8 & 0x0000FF00) | (static_cast<std::uint32_t>(value[3]) & 0x000000FF);
70 return (static_cast<std::uint32_t>(value[3]) << 24 & 0xFF000000) | (static_cast<std::uint32_t>(value[2]) << 16 & 0x00FF0000)
71 | (static_cast<std::uint32_t>(value[1]) << 8 & 0x0000FF00) | (static_cast<std::uint32_t>(value[0]) & 0x000000FF);
80 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
81 return (static_cast<std::int64_t>(value[0]) << 56 & 0xFF00000000000000) | (static_cast<std::int64_t>(value[1]) << 48 & 0x00FF000000000000)
82 | (static_cast<std::int64_t>(value[2]) << 40 & 0x0000FF0000000000) | (static_cast<std::int64_t>(value[3]) << 32 & 0x000000FF00000000)
83 | (static_cast<std::int64_t>(value[4]) << 24 & 0x00000000FF000000) | (static_cast<std::int64_t>(value[5]) << 16 & 0x0000000000FF0000)
84 | (static_cast<std::int64_t>(value[6]) << 8 & 0x000000000000FF00) | (static_cast<std::int64_t>(value[7]) & 0x00000000000000FF);
86 return (static_cast<std::int64_t>(value[7]) << 56 & 0xFF00000000000000) | (static_cast<std::int64_t>(value[6]) << 48 & 0x00FF000000000000)
87 | (static_cast<std::int64_t>(value[5]) << 40 & 0x0000FF0000000000) | (static_cast<std::int64_t>(value[4]) << 32 & 0x000000FF00000000)
88 | (static_cast<std::int64_t>(value[3]) << 24 & 0x00000000FF000000) | (static_cast<std::int64_t>(value[2]) << 16 & 0x0000000000FF0000)
89 | (static_cast<std::int64_t>(value[1]) << 8 & 0x000000000000FF00) | (static_cast<std::int64_t>(value[0]) & 0x00000000000000FF);
98 #if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
99 return (static_cast<std::uint64_t>(value[0]) << 56 & 0xFF00000000000000) | (static_cast<std::uint64_t>(value[1]) << 48 & 0x00FF000000000000)
100 | (static_cast<std::uint64_t>(value[2]) << 40 & 0x0000FF0000000000) | (static_cast<std::uint64_t>(value[3]) << 32 & 0x000000FF00000000)
101 | (static_cast<std::uint64_t>(value[4]) << 24 & 0x00000000FF000000) | (static_cast<std::uint64_t>(value[5]) << 16 & 0x0000000000FF0000)
102 | (static_cast<std::uint64_t>(value[6]) << 8 & 0x000000000000FF00) | (static_cast<std::uint64_t>(value[7]) & 0x00000000000000FF);
104 return (static_cast<std::uint64_t>(value[7]) << 56 & 0xFF00000000000000) | (static_cast<std::uint64_t>(value[6]) << 48 & 0x00FF000000000000)
105 | (static_cast<std::uint64_t>(value[5]) << 40 & 0x0000FF0000000000) | (static_cast<std::uint64_t>(value[4]) << 32 & 0x000000FF00000000)
106 | (static_cast<std::uint64_t>(value[3]) << 24 & 0x00000000FF000000) | (static_cast<std::uint64_t>(value[2]) << 16 & 0x0000000000FF0000)
107 | (static_cast<std::uint64_t>(value[1]) << 8 & 0x000000000000FF00) | (static_cast<std::uint64_t>(value[0]) & 0x00000000000000FF);
116 const auto val = toInt32(value);
117 const auto *
const c = reinterpret_cast<const char *>(&val);
118 return *reinterpret_cast<const float *>(c);
126 const auto val = toInt64(value);
127 const auto *
const c = reinterpret_cast<const char *>(&val);
128 return *reinterpret_cast<const double *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 auto *c = reinterpret_cast<char *>(&value);
270 auto i = *reinterpret_cast<std::int32_t *>(c);
271 getBytes(
i, outputbuffer);
279 auto *c = reinterpret_cast<char *>(&value);
280 auto i = *reinterpret_cast<std::int64_t *>(c);
281 getBytes(
i, outputbuffer);
284 #endif // CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL