00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkByteSwapper_h
00021 #define __itkByteSwapper_h
00022
00023 #include "itkObject.h"
00024 #include "itkObjectFactory.h"
00025
00026 namespace itk
00027 {
00028
00040 template <class T>
00041 class ITK_EXPORT ByteSwapper : public Object
00042 {
00043 public:
00045 typedef ByteSwapper Self;
00046 typedef Object Superclass;
00047 typedef SmartPointer<Self> Pointer;
00048 typedef SmartPointer<const Self> ConstPointer;
00049
00051 typedef std::ostream OStreamType;
00052
00054 itkTypeMacro(ByteSwapper,Object);
00055
00057 static bool SystemIsBigEndian ();
00058 static bool SystemIsBE () { return SystemIsBigEndian(); }
00059 static bool SystemIsLittleEndian ();
00060 static bool SystemIsLE () { return SystemIsLittleEndian(); }
00061
00067 static void SwapFromSystemToBigEndian(T *p);
00068
00074 static void SwapRangeFromSystemToBigEndian(T *p, unsigned long num);
00075
00083 static void SwapWriteRangeFromSystemToBigEndian(T *p, int num, OStreamType *fp);
00084
00090 static void SwapFromSystemToLittleEndian(T *p);
00091
00097 static void SwapRangeFromSystemToLittleEndian(T *p, unsigned long num);
00098
00106 static void SwapWriteRangeFromSystemToLittleEndian(T *p, int num, OStreamType *fp);
00107
00108 protected:
00109 ByteSwapper() {}
00110 ~ByteSwapper() {}
00111
00113 static void Swap2(void *p);
00114
00117 static void Swap2Range(void *p, unsigned long num);
00118
00121 static void SwapWrite2Range(void *p, unsigned long num, OStreamType *fp);
00122
00124 static void Swap4(void *p);
00125
00128 static void Swap4Range(void *p, unsigned long num);
00129
00132 static void SwapWrite4Range(void *p, unsigned long num, OStreamType *fp);
00133
00135 static void Swap8(void *p);
00136
00139 static void Swap8Range(void *p, unsigned long num);
00140
00143 static void SwapWrite8Range(void *p, unsigned long num, OStreamType *fp);
00144
00145 private:
00146 ByteSwapper(const ByteSwapper&);
00147 void operator=(const ByteSwapper&);
00148
00149 };
00150
00151 }
00152
00153 #ifndef ITK_MANUAL_INSTANTIATION
00154 #include "itkByteSwapper.txx"
00155 #endif
00156
00157 #endif