|
Point Cloud Library (PCL)
1.6.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2007-2012, Ares Lagae 00006 * Copyright (c) 2012, Willow Garage, Inc. 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id: byte_order.h 4868 2012-03-01 02:50:19Z rusu $ 00037 * 00038 */ 00039 00040 #ifndef PCL_IO_PLY_BYTE_ORDER_H 00041 #define PCL_IO_PLY_BYTE_ORDER_H 00042 00043 namespace pcl 00044 { 00045 namespace io 00046 { 00047 namespace ply 00048 { 00055 #if defined (PLY_BIG_ENDIAN) || defined (PLY_LITTLE_ENDIAN) 00056 # error 00057 #endif 00058 00059 #if (defined (__powerpc) || defined (__powerpc__) || defined (__POWERPC__) || defined (__ppc__) || defined (_M_PPC) || defined (__ARCH_PPC)) 00060 # define PLY_BIG_ENDIAN 00061 #elif (defined (i386) || defined (__i386__) || defined (__i386) || defined (_M_IX86) || defined (_X86_) || defined (__THW_INTEL__) || defined (__I86__) || defined (__INTEL__)) \ 00062 || (defined (__amd64__) || defined (__amd64) || defined (__x86_64__) || defined (__x86_64) || defined (_M_X64) || defined (ANDROID)) 00063 # define PLY_LITTLE_ENDIAN 00064 #else 00065 # error 00066 #endif 00067 00068 enum byte_order 00069 { 00070 little_endian_byte_order, 00071 big_endian_byte_order, 00072 #if defined (PLY_BIG_ENDIAN) 00073 host_byte_order = big_endian_byte_order, 00074 #elif defined (PLY_LITTLE_ENDIAN) 00075 host_byte_order = little_endian_byte_order, 00076 #else 00077 # error 00078 #endif 00079 network_byte_order = big_endian_byte_order 00080 }; 00081 00082 #undef PLY_BIG_ENDIAN 00083 #undef PLY_LITTLE_ENDIAN 00084 00085 template <std::size_t N> 00086 void swap_byte_order (char* bytes); 00087 00088 template <> 00089 inline void swap_byte_order<1> (char*) {} 00090 00091 template <> 00092 inline void swap_byte_order<2> (char* bytes) 00093 { 00094 std::swap (bytes[0], bytes[1]); 00095 } 00096 00097 template <> 00098 inline void swap_byte_order<4> (char* bytes) 00099 { 00100 std::swap (bytes[0], bytes[3]); 00101 std::swap (bytes[1], bytes[2]); 00102 } 00103 00104 template <> 00105 inline void swap_byte_order<8> (char* bytes) 00106 { 00107 std::swap (bytes[0], bytes[7]); 00108 std::swap (bytes[1], bytes[6]); 00109 std::swap (bytes[2], bytes[5]); 00110 std::swap (bytes[3], bytes[4]); 00111 } 00112 00113 template <typename T> 00114 void swap_byte_order (T& value) 00115 { 00116 swap_byte_order<sizeof (T)> (reinterpret_cast<char*> (&value)); 00117 } 00118 00119 } // namespace ply 00120 } // namespace io 00121 } // namespace pcl 00122 00123 #endif // PLY_BYTE_ORDER_H
1.7.6.1