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(); }
00062
00068 static void SwapFromSystemToBigEndian(T *p);
00069
00072 typedef ::size_t BufferSizeType;
00073
00079 static void SwapRangeFromSystemToBigEndian(T *p, BufferSizeType num);
00080
00088 static void SwapWriteRangeFromSystemToBigEndian(T *p, int num,
00089 OStreamType *fp);
00091
00097 static void SwapFromSystemToLittleEndian(T *p);
00098
00104 static void SwapRangeFromSystemToLittleEndian(T *p, BufferSizeType num);
00105
00113 static void SwapWriteRangeFromSystemToLittleEndian(T *p, int num,
00114 OStreamType *fp);
00116
00117 protected:
00118 ByteSwapper() {}
00119 ~ByteSwapper() {}
00120
00122 static void Swap2(void *p);
00123
00126 static void Swap2Range(void *p, BufferSizeType num);
00127
00130 static void SwapWrite2Range(void *p, BufferSizeType num, OStreamType *fp);
00131
00133 static void Swap4(void *p);
00134
00137 static void Swap4Range(void *p, BufferSizeType num);
00138
00141 static void SwapWrite4Range(void *p, BufferSizeType num, OStreamType *fp);
00142
00144 static void Swap8(void *p);
00145
00148 static void Swap8Range(void *p, BufferSizeType num);
00149
00152 static void SwapWrite8Range(void *p, BufferSizeType num, OStreamType *fp);
00153
00154 private:
00155 ByteSwapper(const ByteSwapper&);
00156 void operator=(const ByteSwapper&);
00157
00158 };
00159
00160 }
00161
00162 #ifndef ITK_MANUAL_INSTANTIATION
00163 #include "itkByteSwapper.txx"
00164 #endif
00165
00166 #endif
00167