# gdcmSwapCode.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2010 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html 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 =========================================================================*/
    00015 #ifndef GDCMSWAPCODE_H
    00016 #define GDCMSWAPCODE_H
    00017
    00018 #include "gdcmTypes.h"
    00019 #include <iostream>
    00020
    00021 namespace gdcm
    00022 {
    00023
    00028 class GDCM_EXPORT SwapCode
    00029 {
    00030 public:
    00031   typedef enum {
    00032     Unknown         = 0,
    00033     LittleEndian    = 1234,
    00034     BigEndian       = 4321,
    00035     BadLittleEndian = 3412,
    00036     BadBigEndian    = 2143
    00037   } SwapCodeType;
    00038
    00039   operator SwapCode::SwapCodeType() const { return SwapCodeValue; }
    00040   SwapCode(SwapCodeType sc = Unknown):SwapCodeValue(sc) { }
    00041   static const char* GetSwapCodeString(SwapCode const & sc);
    00042
    00043   friend std::ostream& operator<<(std::ostream& os, const SwapCode& sc);
    00044 protected:
    00045   static int GetIndex(SwapCode const & sc);
    00046
    00047 private:
    00048   SwapCodeType SwapCodeValue;
    00049 };
    00050 //-----------------------------------------------------------------------------
    00051 inline std::ostream& operator<<(std::ostream& os, const SwapCode& sc)
    00052 {
    00053   os << SwapCode::GetSwapCodeString(sc);
    00054   return os;
    00055 }
    00056
    00057 } // end namespace gdcm
    00058
    00059 #endif //GDCMSWAPCODE_H