Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkByteSwapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkByteSwapper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/09/10 14:29:03 $
00007   Version:   $Revision: 1.14 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
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&); //purposely not implemented
00147   void operator=(const ByteSwapper&); //purposely not implemented
00148   
00149 };
00150 
00151 } // end namespace itk
00152   
00153 #ifndef ITK_MANUAL_INSTANTIATION
00154 #include "itkByteSwapper.txx"
00155 #endif
00156 
00157 #endif

Generated at Wed May 24 22:54:02 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000