Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_IO_PLY_BYTE_ORDER_H
00041 #define PCL_IO_PLY_BYTE_ORDER_H
00042
00043 #include <boost/detail/endian.hpp>
00044
00045 namespace pcl
00046 {
00047 namespace io
00048 {
00049 namespace ply
00050 {
00057 enum byte_order
00058 {
00059 little_endian_byte_order,
00060 big_endian_byte_order,
00061 #if defined(BOOST_BIG_ENDIAN)
00062 host_byte_order = big_endian_byte_order,
00063 #elif defined(BOOST_LITTLE_ENDIAN)
00064 host_byte_order = little_endian_byte_order,
00065 #else
00066 #error "unable to determine system endianness"
00067 #endif
00068 network_byte_order = big_endian_byte_order
00069 };
00070
00071 template <std::size_t N>
00072 void swap_byte_order (char* bytes);
00073
00074 template <>
00075 inline void swap_byte_order<1> (char*) {}
00076
00077 template <>
00078 inline void swap_byte_order<2> (char* bytes)
00079 {
00080 std::swap (bytes[0], bytes[1]);
00081 }
00082
00083 template <>
00084 inline void swap_byte_order<4> (char* bytes)
00085 {
00086 std::swap (bytes[0], bytes[3]);
00087 std::swap (bytes[1], bytes[2]);
00088 }
00089
00090 template <>
00091 inline void swap_byte_order<8> (char* bytes)
00092 {
00093 std::swap (bytes[0], bytes[7]);
00094 std::swap (bytes[1], bytes[6]);
00095 std::swap (bytes[2], bytes[5]);
00096 std::swap (bytes[3], bytes[4]);
00097 }
00098
00099 template <typename T>
00100 void swap_byte_order (T& value)
00101 {
00102 swap_byte_order<sizeof (T)> (reinterpret_cast<char*> (&value));
00103 }
00104
00105 }
00106 }
00107 }
00108
00109 #endif // PLY_BYTE_ORDER_H