6 #if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
7 # define BYTE_ORDER_1 ByteOrder::BigEndian
8 # define BYTE_ORDER_2 ByteOrder::LittleEndian
9 #elif defined(CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN)
10 # define BYTE_ORDER_2 ByteOrder::BigEndian
11 # define BYTE_ORDER_1 ByteOrder::LittleEndian
12 #elif defined(CONVERSION_UTILITIES_BYTE_ORDER_MIDDLE_ENDIAN)
13 # error "Middle endian byte order is not supported!"
15 # error "Byte order not determined!"
18 #if defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_LITTLE_ENDIAN)
19 # define FLOAT_BYTE_ORDER_1 ByteOrder::BigEndian
20 # define FLOAT_BYTE_ORDER_2 ByteOrder::LittleEndian
21 #elif defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_BIG_ENDIAN)
22 # define FLOAT_BYTE_ORDER_2 ByteOrder::BigEndian
23 # define FLOAT_BYTE_ORDER_1 ByteOrder::LittleEndian
24 #elif defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_MIDDLE_ENDIAN)
25 # error "Middle endian byte order is not supported!"
27 # error "Byte order not determined!"
51 return (static_cast<int16>(value[startIndex ]) << 8 & 0xFF00)
52 | (
static_cast<int16>(value[startIndex + 1]) & 0x00FF);
54 return (static_cast<int16>(value[startIndex + 1]) << 8 & 0xFF00)
55 | (static_cast<int16>(value[startIndex ]) & 0x00FF);
68 return (static_cast<uint16>(value[startIndex ]) << 8 & 0xFF00)
69 | (
static_cast<uint16>(value[startIndex + 1]) & 0x00FF);
71 return (static_cast<uint16>(value[startIndex + 1]) << 8 & 0xFF00)
72 | (static_cast<uint16>(value[startIndex ]) & 0x00FF);
85 return (static_cast<int32>(value[startIndex ]) << 24 & 0xFF000000)
86 | (
static_cast<int32>(value[startIndex + 1]) << 16 & 0x00FF0000)
87 | (
static_cast<int32>(value[startIndex + 2]) << 8 & 0x0000FF00)
88 | (
static_cast<int32>(value[startIndex + 3]) & 0x000000FF);
90 return (static_cast<int32>(value[startIndex + 3]) << 24 & 0xFF000000)
91 | (static_cast<int32>(value[startIndex + 2]) << 16 & 0x00FF0000)
92 | (static_cast<int32>(value[startIndex + 1]) << 8 & 0x0000FF00)
93 | (static_cast<int32>(value[startIndex ]) & 0x000000FF);
106 return (static_cast<uint32>(value[startIndex ]) << 16 & 0x00FF0000)
107 | (
static_cast<uint32>(value[startIndex + 1]) << 8 & 0x0000FF00)
108 | (
static_cast<uint32>(value[startIndex + 2]) & 0x000000FF);
110 return (static_cast<uint32>(value[startIndex + 2]) << 16 & 0x00FF0000)
111 | (static_cast<uint32>(value[startIndex + 1]) << 8 & 0x0000FF00)
112 | (static_cast<uint32>(value[startIndex ]) & 0x000000FF);
125 return (static_cast<uint32>(value[startIndex ]) << 24 & 0xFF000000)
126 | (
static_cast<uint32>(value[startIndex + 1]) << 16 & 0x00FF0000)
127 | (
static_cast<uint32>(value[startIndex + 2]) << 8 & 0x0000FF00)
128 | (
static_cast<uint32>(value[startIndex + 3]) & 0x000000FF);
130 return (static_cast<uint32>(value[startIndex + 3]) << 24 & 0xFF000000)
131 | (static_cast<uint32>(value[startIndex + 2]) << 16 & 0x00FF0000)
132 | (static_cast<uint32>(value[startIndex + 1]) << 8 & 0x0000FF00)
133 | (static_cast<uint32>(value[startIndex ]) & 0x000000FF);
146 return (static_cast<int64>(value[startIndex ]) << 56 & 0xFF00000000000000)
147 | (
static_cast<int64>(value[startIndex + 1]) << 48 & 0x00FF000000000000)
148 | (
static_cast<int64>(value[startIndex + 2]) << 40 & 0x0000FF0000000000)
149 | (
static_cast<int64>(value[startIndex + 3]) << 32 & 0x000000FF00000000)
150 | (
static_cast<int64>(value[startIndex + 4]) << 24 & 0x00000000FF000000)
151 | (
static_cast<int64>(value[startIndex + 5]) << 16 & 0x0000000000FF0000)
152 | (
static_cast<int64>(value[startIndex + 6]) << 8 & 0x000000000000FF00)
153 | (
static_cast<int64>(value[startIndex + 7]) & 0x00000000000000FF);
155 return (static_cast<int64>(value[startIndex + 7]) << 56 & 0xFF00000000000000)
156 | (static_cast<int64>(value[startIndex + 6]) << 48 & 0x00FF000000000000)
157 | (static_cast<int64>(value[startIndex + 5]) << 40 & 0x0000FF0000000000)
158 | (static_cast<int64>(value[startIndex + 4]) << 32 & 0x000000FF00000000)
159 | (static_cast<int64>(value[startIndex + 3]) << 24 & 0x00000000FF000000)
160 | (static_cast<int64>(value[startIndex + 2]) << 16 & 0x0000000000FF0000)
161 | (static_cast<int64>(value[startIndex + 1]) << 8 & 0x000000000000FF00)
162 | (static_cast<int64>(value[startIndex ]) & 0x00000000000000FF);
175 return (static_cast<uint64>(value[startIndex ]) << 56 & 0xFF00000000000000)
176 | (
static_cast<uint64>(value[startIndex + 1]) << 48 & 0x00FF000000000000)
177 | (
static_cast<uint64>(value[startIndex + 2]) << 40 & 0x0000FF0000000000)
178 | (
static_cast<uint64>(value[startIndex + 3]) << 32 & 0x000000FF00000000)
179 | (
static_cast<uint64>(value[startIndex + 4]) << 24 & 0x00000000FF000000)
180 | (
static_cast<uint64>(value[startIndex + 5]) << 16 & 0x0000000000FF0000)
181 | (
static_cast<uint64>(value[startIndex + 6]) << 8 & 0x000000000000FF00)
182 | (
static_cast<uint64>(value[startIndex + 7]) & 0x00000000000000FF);
184 return (static_cast<uint64>(value[startIndex + 7]) << 56 & 0xFF00000000000000)
185 | (static_cast<uint64>(value[startIndex + 6]) << 48 & 0x00FF000000000000)
186 | (static_cast<uint64>(value[startIndex + 5]) << 40 & 0x0000FF0000000000)
187 | (static_cast<uint64>(value[startIndex + 4]) << 32 & 0x000000FF00000000)
188 | (static_cast<uint64>(value[startIndex + 3]) << 24 & 0x00000000FF000000)
189 | (static_cast<uint64>(value[startIndex + 2]) << 16 & 0x0000000000FF0000)
190 | (static_cast<uint64>(value[startIndex + 1]) << 8 & 0x000000000000FF00)
191 | (static_cast<uint64>(value[startIndex ]) & 0x00000000000000FF);
206 val =
toInt32(value, startIndex, FLOAT_BYTE_ORDER_1);
207 c =
reinterpret_cast<char*
>(&val);
208 return *
reinterpret_cast<float32*
>(c);
210 val =
toInt32(value, startIndex, FLOAT_BYTE_ORDER_2);
211 c =
reinterpret_cast<char*
>(&val);
212 return *
reinterpret_cast<float32*
>(c);
227 val =
toInt64(value, startIndex, FLOAT_BYTE_ORDER_1);
228 c =
reinterpret_cast<char*
>(&val);
229 return *
reinterpret_cast<float64*
>(c);
231 val =
toInt64(value, startIndex, FLOAT_BYTE_ORDER_2);
232 c =
reinterpret_cast<char*
>(&val);
233 return *
reinterpret_cast<float64*
>(c);
248 return ((normalInt & 0x0000007fu) )
249 | ((normalInt & 0x00003f80u) << 1)
250 | ((normalInt & 0x001fc000u) << 2)
251 | ((normalInt & 0x0fe00000u) << 3);
263 return ((synchsafeInt & 0x0000007fu) )
264 | ((synchsafeInt & 0x00007f00u) >> 1)
265 | ((synchsafeInt & 0x007f0000u) >> 2)
266 | ((synchsafeInt & 0x7f000000u) >> 3);
276 outputbuffer[startIndex ] =
static_cast<char>((value >> 8) & 0xFF);
277 outputbuffer[startIndex + 1] =
static_cast<char>((value ) & 0xFF);
280 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 8) & 0xFF);
281 outputbuffer[startIndex ] =
static_cast<char>((value ) & 0xFF);
293 outputbuffer[startIndex ] =
static_cast<char>((value >> 8) & 0xFF);
294 outputbuffer[startIndex + 1] =
static_cast<char>((value ) & 0xFF);
297 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 8) & 0xFF);
298 outputbuffer[startIndex ] =
static_cast<char>((value ) & 0xFF);
310 outputbuffer[startIndex ] =
static_cast<char>((value >> 24) & 0xFF);
311 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 16) & 0xFF);
312 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 8) & 0xFF);
313 outputbuffer[startIndex + 3] =
static_cast<char>((value ) & 0xFF);
316 outputbuffer[startIndex + 3] =
static_cast<char>((value >> 24) & 0xFF);
317 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 16) & 0xFF);
318 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 8) & 0xFF);
319 outputbuffer[startIndex ] =
static_cast<char>((value ) & 0xFF);
331 outputbuffer[startIndex ] =
static_cast<char>((value >> 24) & 0xFF);
332 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 16) & 0xFF);
333 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 8) & 0xFF);
334 outputbuffer[startIndex + 3] =
static_cast<char>((value ) & 0xFF);
337 outputbuffer[startIndex + 3] =
static_cast<char>((value >> 24) & 0xFF);
338 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 16) & 0xFF);
339 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 8) & 0xFF);
340 outputbuffer[startIndex ] =
static_cast<char>((value ) & 0xFF);
352 outputbuffer[startIndex ] =
static_cast<char>((value >> 56) & 0xFF);
353 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 48) & 0xFF);
354 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 40) & 0xFF);
355 outputbuffer[startIndex + 3] =
static_cast<char>((value >> 32) & 0xFF);
356 outputbuffer[startIndex + 4] =
static_cast<char>((value >> 24) & 0xFF);
357 outputbuffer[startIndex + 5] =
static_cast<char>((value >> 16) & 0xFF);
358 outputbuffer[startIndex + 6] =
static_cast<char>((value >> 8) & 0xFF);
359 outputbuffer[startIndex + 7] =
static_cast<char>((value ) & 0xFF);
362 outputbuffer[startIndex + 7] =
static_cast<char>((value >> 56) & 0xFF);
363 outputbuffer[startIndex + 6] =
static_cast<char>((value >> 48) & 0xFF);
364 outputbuffer[startIndex + 5] =
static_cast<char>((value >> 40) & 0xFF);
365 outputbuffer[startIndex + 4] =
static_cast<char>((value >> 32) & 0xFF);
366 outputbuffer[startIndex + 3] =
static_cast<char>((value >> 24) & 0xFF);
367 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 16) & 0xFF);
368 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 8) & 0xFF);
369 outputbuffer[startIndex ] =
static_cast<char>((value ) & 0xFF);
381 outputbuffer[startIndex ] =
static_cast<char>((value >> 56) & 0xFF);
382 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 48) & 0xFF);
383 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 40) & 0xFF);
384 outputbuffer[startIndex + 3] =
static_cast<char>((value >> 32) & 0xFF);
385 outputbuffer[startIndex + 4] =
static_cast<char>((value >> 24) & 0xFF);
386 outputbuffer[startIndex + 5] =
static_cast<char>((value >> 16) & 0xFF);
387 outputbuffer[startIndex + 6] =
static_cast<char>((value >> 8) & 0xFF);
388 outputbuffer[startIndex + 7] =
static_cast<char>((value ) & 0xFF);
391 outputbuffer[startIndex + 7] =
static_cast<char>((value >> 56) & 0xFF);
392 outputbuffer[startIndex + 6] =
static_cast<char>((value >> 48) & 0xFF);
393 outputbuffer[startIndex + 5] =
static_cast<char>((value >> 40) & 0xFF);
394 outputbuffer[startIndex + 4] =
static_cast<char>((value >> 32) & 0xFF);
395 outputbuffer[startIndex + 3] =
static_cast<char>((value >> 24) & 0xFF);
396 outputbuffer[startIndex + 2] =
static_cast<char>((value >> 16) & 0xFF);
397 outputbuffer[startIndex + 1] =
static_cast<char>((value >> 8) & 0xFF);
398 outputbuffer[startIndex ] =
static_cast<char>((value ) & 0xFF);
408 char *c =
reinterpret_cast<char*
>(&value);
412 getBytes(i, outputbuffer, startIndex, FLOAT_BYTE_ORDER_1);
415 getBytes(i, outputbuffer, startIndex, FLOAT_BYTE_ORDER_2);
426 char *c =
reinterpret_cast<char*
>(&value);
430 getBytes(i, outputbuffer, startIndex, FLOAT_BYTE_ORDER_1);
433 getBytes(i, outputbuffer, startIndex, FLOAT_BYTE_ORDER_2);
void getBytes(int16 value, char *outputbuffer, int startIndex, ByteOrder byteOrder)
Stores the specified 16-bit signed integer value at a specified position in a char array...
ByteOrder
Specifies the byte order/endianness.
std::int64_t int64
signed 64-bit integer
float64 toFloat64(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 64-bit floating point number converted from eight bytes at a specified position in a char a...
uint32 toNormalInt(uint32 synchsafeInt)
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
int16 toInt16(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 16-bit signed integer converted from two bytes at a specified position in a char array...
std::uint64_t uint64
unsigned 64-bit integer
float32 toFloat32(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 32-bit floating point number converted from four bytes at a specified position in a char ar...
uint32 toUInt24(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 32-bit unsigned integer converted from three bytes at a specified position in a char array...
Contains several functions providing conversions between different data types.
std::uint32_t uint32
unsigned 32-bit integer
uint32 toSynchsafeInt(uint32 normalInt)
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
uint64 toUInt64(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a char array...
std::int32_t int32
signed 32-bit integer
int32 toInt32(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 32-bit signed integer converted from four bytes at a specified position in a char array...
uint32 toUInt32(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 32-bit unsigned integer converted from four bytes at a specified position in a char array...
std::int16_t int16
signed 16-bit integer
uint16 toUInt16(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 16-bit unsigned integer converted from two bytes at a specified position in a char array...
std::uint16_t uint16
unsigned 16-bit integer
int64 toInt64(const char *value, int startIndex, ByteOrder byteOrder)
Returns a 64-bit signed integer converted from eight bytes at a specified position in a char array...