USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::EndianSwapper Class Reference
[Utility]

#include <EndianSwapper.h>

Collaboration diagram for Isis::EndianSwapper:

Collaboration graph
[legend]
List of all members.

Detailed Description

Byte swapper.

This class is used to swap bytes on data that is from a different machine architecture.

Author:
2002-07-10 Tracie Sucharski

For internal use only.

Todo:
This class needs an example.
History:
2003-05-16 Stuart Sides modified schema from astrogeology...isis.astrogeology.
History:
2004-03-18 Stuart Sides used Endian.h instead of the linux gcc endian.h to figure the system's endian type.
History:
2008-08-14 Christopher Austin - Added ExportFloat() for exporting real data to the non-native endians. i.e. exporting to msb on a lsb system
History:
2009-04-16 Steven Lambright - Added Int and LongLongInt. Long was not added because it is 4 bytes on 32-bit linux and 8 bytes on 64-bit linux.

Definition at line 53 of file EndianSwapper.h.

Public Member Functions

 EndianSwapper (std::string inputEndian)
 Constructs an EndianSwapper object, determining whether swapping of bytes actually needs to occur and sets the direction of swapping.
 ~EndianSwapper ()
 Destroys the EndianSwapper object.
double Double (void *buf)
 Swaps a double precision value.
float Float (void *buf)
 Swaps a floating point value.
int ExportFloat (void *buf)
 Swaps a floating point value for Exporting.
int Int (void *buf)
 Swaps a 4 byte integer value.
long long int LongLongInt (void *buf)
 Swaps an 8 byte integer value.
short int ShortInt (void *buf)
 Swaps a short integer value.
unsigned short int UnsignedShortInt (unsigned short int *buf)
 Swaps an unsigned short integer value.

Private Attributes

bool p_needSwap
 Indicates whether bytes need to be swapped.
int p_swapDirection
 Indicates which direction to increment the pointer for swapping.
union {
   double   p_double
 Union containing the output double precision value with swapped bytes.
   float   p_float
 Union containing the output floating point value with swapped bytes.
   int   p_int
 Union containing the output 4 byte integer value with swapped bytes.
   long long int   p_longLongInt
 Union containing the output 8 byte integer value with swapped bytes.
   short int   p_shortInt
 Union containing the output 2 byte integer value with swapped bytes.
   unsigned short int   p_uShortInt
 Union containing the output unsigned short integer value with swapped bytes.
   char   p_char [8]
 Union containing the output value in byte format.
p_swapper
 Union containing the output double precision value, floating point value, short integer value, unsigned short integer value and byte format - all with swapped bytes.


Constructor & Destructor Documentation

Isis::EndianSwapper::EndianSwapper ( std::string  inputEndian  ) 

Constructs an EndianSwapper object, determining whether swapping of bytes actually needs to occur and sets the direction of swapping.

Parameters:
inputEndian Byte order of input value (MSB or LSB).

Definition at line 39 of file EndianSwapper.cpp.

References _FILEINFO_, Isis::IsLsb(), Isis::IsMsb(), Isis::iException::Message(), p_needSwap, and p_swapDirection.

Isis::EndianSwapper::~EndianSwapper (  ) 

Destroys the EndianSwapper object.

Definition at line 62 of file EndianSwapper.cpp.


Member Function Documentation

double Isis::EndianSwapper::Double ( void *  buf  ) 

Swaps a double precision value.

Parameters:
buf Input double precision value to swap.

Definition at line 71 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

int Isis::EndianSwapper::ExportFloat ( void *  buf  ) 

Swaps a floating point value for Exporting.

Definition at line 101 of file EndianSwapper.cpp.

References Int().

Referenced by Isis::ProcessExport::isisOut32().

float Isis::EndianSwapper::Float ( void *  buf  ) 

Swaps a floating point value.

Parameters:
buf Input floating point value to swap.

Definition at line 87 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::ProcessImport::ProcessBil(), Isis::ProcessImport::ProcessBip(), and Isis::ProcessImport::ProcessBsq().

int Isis::EndianSwapper::Int ( void *  buf  ) 

Swaps a 4 byte integer value.

Parameters:
buf Input integer value to swap.

Definition at line 110 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by ExportFloat().

long long int Isis::EndianSwapper::LongLongInt ( void *  buf  ) 

Swaps an 8 byte integer value.

Parameters:
buf Input integer value to swap.

Definition at line 126 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

short int Isis::EndianSwapper::ShortInt ( void *  buf  ) 

Swaps a short integer value.

Parameters:
buf Input short integer value to swap.

Definition at line 142 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::ProcessExport::isisOut16s(), Isis::ProcessImport::ProcessBil(), Isis::ProcessImport::ProcessBip(), and Isis::ProcessImport::ProcessBsq().

unsigned short int Isis::EndianSwapper::UnsignedShortInt ( unsigned short int *  buf  ) 

Swaps an unsigned short integer value.

Parameters:
buf Input unsigned short integer value to swap.

Definition at line 158 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::ProcessExport::isisOut16u(), Isis::ProcessImport::ProcessBil(), Isis::ProcessImport::ProcessBip(), and Isis::ProcessImport::ProcessBsq().


Member Data Documentation

char Isis::EndianSwapper::p_char[8] [private]

Union containing the output value in byte format.

Definition at line 85 of file EndianSwapper.h.

double Isis::EndianSwapper::p_double [private]

Union containing the output double precision value with swapped bytes.

Definition at line 70 of file EndianSwapper.h.

float Isis::EndianSwapper::p_float [private]

Union containing the output floating point value with swapped bytes.

Definition at line 72 of file EndianSwapper.h.

int Isis::EndianSwapper::p_int [private]

Union containing the output 4 byte integer value with swapped bytes.

Definition at line 74 of file EndianSwapper.h.

long long int Isis::EndianSwapper::p_longLongInt [private]

Union containing the output 8 byte integer value with swapped bytes.

Definition at line 76 of file EndianSwapper.h.

bool Isis::EndianSwapper::p_needSwap [private]

Indicates whether bytes need to be swapped.

Definition at line 56 of file EndianSwapper.h.

Referenced by Double(), EndianSwapper(), Float(), Int(), LongLongInt(), ShortInt(), and UnsignedShortInt().

short int Isis::EndianSwapper::p_shortInt [private]

Union containing the output 2 byte integer value with swapped bytes.

Definition at line 78 of file EndianSwapper.h.

int Isis::EndianSwapper::p_swapDirection [private]

Indicates which direction to increment the pointer for swapping.

(Possible values: -1,1)

Definition at line 61 of file EndianSwapper.h.

Referenced by Double(), EndianSwapper(), Float(), Int(), LongLongInt(), ShortInt(), and UnsignedShortInt().

union { ... } Isis::EndianSwapper::p_swapper [private]

Union containing the output double precision value, floating point value, short integer value, unsigned short integer value and byte format - all with swapped bytes.

Referenced by Double(), Float(), Int(), LongLongInt(), ShortInt(), and UnsignedShortInt().

unsigned short int Isis::EndianSwapper::p_uShortInt [private]

Union containing the output unsigned short integer value with swapped bytes.

Definition at line 83 of file EndianSwapper.h.


The documentation for this class was generated from the following files: