VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkByteSwap.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00026 #ifndef __vtkByteSwap_h 00027 #define __vtkByteSwap_h 00028 00029 #include "vtkCommonCoreModule.h" // For export macro 00030 #include "vtkObject.h" 00031 00032 class VTKCOMMONCORE_EXPORT vtkByteSwap : public vtkObject 00033 { 00034 public: 00035 static vtkByteSwap *New(); 00036 vtkTypeMacro(vtkByteSwap,vtkObject); 00037 00038 //BTX 00040 00043 #define VTK_BYTE_SWAP_DECL(T) \ 00044 static void SwapLE(T* p); \ 00045 static void SwapBE(T* p); \ 00046 static void SwapLERange(T* p, size_t num); \ 00047 static void SwapBERange(T* p, size_t num); \ 00048 static bool SwapLERangeWrite(const T* p, size_t num, FILE* file); \ 00049 static bool SwapBERangeWrite(const T* p, size_t num, FILE* file); \ 00050 static void SwapLERangeWrite(const T* p, size_t num, ostream* os); \ 00051 static void SwapBERangeWrite(const T* p, size_t num, ostream* os) 00052 VTK_BYTE_SWAP_DECL(float); 00053 VTK_BYTE_SWAP_DECL(double); 00054 VTK_BYTE_SWAP_DECL(char); 00055 VTK_BYTE_SWAP_DECL(short); 00056 VTK_BYTE_SWAP_DECL(int); 00057 VTK_BYTE_SWAP_DECL(long); 00058 VTK_BYTE_SWAP_DECL(signed char); 00059 VTK_BYTE_SWAP_DECL(unsigned char); 00060 VTK_BYTE_SWAP_DECL(unsigned short); 00061 VTK_BYTE_SWAP_DECL(unsigned int); 00062 VTK_BYTE_SWAP_DECL(unsigned long); 00063 #if defined(VTK_DECL_USE_LONG_LONG) 00064 VTK_BYTE_SWAP_DECL(long long); 00065 VTK_BYTE_SWAP_DECL(unsigned long long); 00066 #endif 00067 #if defined(VTK_DECL_USE___INT64) 00068 VTK_BYTE_SWAP_DECL(__int64); 00069 VTK_BYTE_SWAP_DECL(unsigned __int64); 00070 #endif 00071 #undef VTK_BYTE_SWAP_DECL 00072 //ETX 00074 00076 00077 static void Swap2LE(void* p); 00078 static void Swap4LE(void* p); 00079 static void Swap8LE(void* p); 00081 00083 00085 static void Swap2LERange(void* p, size_t num); 00086 static void Swap4LERange(void* p, size_t num); 00087 static void Swap8LERange(void* p, size_t num); 00089 00091 00094 static bool SwapWrite2LERange(void const* p, size_t num, FILE* f); 00095 static bool SwapWrite4LERange(void const* p, size_t num, FILE* f); 00096 static bool SwapWrite8LERange(void const* p, size_t num, FILE* f); 00097 static void SwapWrite2LERange(void const* p, size_t num, ostream* os); 00098 static void SwapWrite4LERange(void const* p, size_t num, ostream* os); 00099 static void SwapWrite8LERange(void const* p, size_t num, ostream* os); 00101 00103 00104 static void Swap2BE(void* p); 00105 static void Swap4BE(void* p); 00106 static void Swap8BE(void* p); 00108 00110 00111 static void Swap2BERange(void* p, size_t num); 00112 static void Swap4BERange(void* p, size_t num); 00113 static void Swap8BERange(void* p, size_t num); 00115 00117 00120 static bool SwapWrite2BERange(void const* p, size_t num, FILE* f); 00121 static bool SwapWrite4BERange(void const* p, size_t num, FILE* f); 00122 static bool SwapWrite8BERange(void const* p, size_t num, FILE* f); 00123 static void SwapWrite2BERange(void const* p, size_t num, ostream* os); 00124 static void SwapWrite4BERange(void const* p, size_t num, ostream* os); 00125 static void SwapWrite8BERange(void const* p, size_t num, ostream* os); 00127 00130 static void SwapVoidRange(void *buffer, size_t numWords, size_t wordSize); 00131 00132 protected: 00133 vtkByteSwap(); 00134 ~vtkByteSwap(); 00135 00136 private: 00137 vtkByteSwap(const vtkByteSwap&); // Not implemented. 00138 void operator=(const vtkByteSwap&); // Not implemented. 00139 }; 00140 00141 #endif 00142 // VTK-HeaderTest-Exclude: vtkByteSwap.h