Main MRPT website > C++ reference for MRPT 1.9.9
reverse_bytes.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <cstdint>
12 
13 namespace mrpt
14 {
15 /** Reverse the order of the bytes of a given type (useful for transforming btw
16  * little/big endian) */
17 void reverseBytesInPlace(bool& v_in_out);
18 void reverseBytesInPlace(uint8_t& v_in_out);
19 void reverseBytesInPlace(int8_t& v_in_out);
20 void reverseBytesInPlace(uint16_t& v_in_out);
21 void reverseBytesInPlace(int16_t& v_in_out);
22 void reverseBytesInPlace(uint32_t& v_in_out);
23 void reverseBytesInPlace(int32_t& v_in_out);
24 void reverseBytesInPlace(uint64_t& v_in_out);
25 void reverseBytesInPlace(int64_t& v_in_out);
26 void reverseBytesInPlace(float& v_in_out);
27 void reverseBytesInPlace(double& v_in_out);
28 void reverseBytesInPlace(long double& v_in_out);
29 
30 /** Reverse the order of the bytes of a given type (useful for transforming btw
31  * little/big endian) */
32 template <class T>
33 inline void reverseBytes(const T& v_in, T& v_out)
34 {
35  v_out = v_in;
36  reverseBytesInPlace(v_out);
37 }
38 } // end of namespace
uint16_t
unsigned __int16 uint16_t
Definition: rptypes.h:44
int64_t
__int64 int64_t
Definition: rptypes.h:49
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
int8_t
signed char int8_t
Definition: rptypes.h:40
mrpt::reverseBytes
void reverseBytes(const T &v_in, T &v_out)
Reverse the order of the bytes of a given type (useful for transforming btw little/big endian)
Definition: reverse_bytes.h:33
int16_t
__int16 int16_t
Definition: rptypes.h:43
mrpt::reverseBytesInPlace
void reverseBytesInPlace(bool &v_in_out)
Reverse the order of the bytes of a given type (useful for transforming btw little/big endian)
Definition: reverse_bytes.cpp:93
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
int32_t
__int32 int32_t
Definition: rptypes.h:46
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST