Isis 3 Programmer Reference
Isis::EndianSwapper Class Reference

Byte swapper. More...

#include <EndianSwapper.h>

Collaboration diagram for Isis::EndianSwapper:
Collaboration graph

Public Member Functions

 EndianSwapper (QString 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.
 
uint32_t Uint32_t (void *buf)
 Swaps a 32bit unsigned integer.
 
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 (void *buf)
 Swaps an unsigned short integer value.
 
bool willSwap () const
 

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 { 
 
   uint32_t   p_uint32 
 Union containing the output uint32_t value with swapped bytes. More...
 
   double   p_double 
 Union containing the output double precision value with swapped bytes. More...
 
   float   p_float 
 Union containing the output floating point value with swapped bytes. More...
 
   int   p_int 
 Union containing the output 4 byte integer value with swapped bytes. More...
 
   long long int   p_longLongInt 
 Union containing the output 8 byte integer value with swapped bytes. More...
 
   short int   p_shortInt 
 Union containing the output 2 byte integer value with swapped bytes. More...
 
   unsigned short int   p_uShortInt 
 Union containing the output unsigned short integer value with swapped bytes. More...
 
   char   p_char [8] 
 Union containing the output value in byte format. More...
 
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.
 

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
Todo
This class needs an example.
History

2003-05-16 Stuart Sides modified schema from astrogeology...isis.astrogeology.

2004-03-18 Stuart Sides used Endian.h instead of the linux gcc endian.h to figure the system's endian type.

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

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.

2016-04-21 Makayla Shepherd - Added UnsignedWord pixel type handling.

2018-01-29 Adam Goins - Added uint32_t behavior to EndianSwapper.

Definition at line 38 of file EndianSwapper.h.

Constructor & Destructor Documentation

◆ EndianSwapper()

Isis::EndianSwapper::EndianSwapper ( QString inputEndian)

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

Parameters
inputEndianByte order of input value (MSB or LSB).

Definition at line 23 of file EndianSwapper.cpp.

References Isis::IsLsb(), Isis::IsMsb(), p_needSwap, p_swapDirection, and Isis::IException::Programmer.

◆ ~EndianSwapper()

Isis::EndianSwapper::~EndianSwapper ( )

Destroys the EndianSwapper object.

Definition at line 46 of file EndianSwapper.cpp.

Member Function Documentation

◆ Double()

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

Swaps a double precision value.

Parameters
bufInput double precision value to swap.

Definition at line 55 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

◆ ExportFloat()

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

Swaps a floating point value for Exporting.

Definition at line 99 of file EndianSwapper.cpp.

References Int().

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

◆ Float()

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

Swaps a floating point value.

Parameters
bufInput floating point value to swap.

Definition at line 78 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().

◆ Int()

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

Swaps a 4 byte integer value.

Parameters
bufInput integer value to swap.

Definition at line 108 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by ExportFloat().

◆ LongLongInt()

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

Swaps an 8 byte integer value.

Parameters
bufInput integer value to swap.

Definition at line 152 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

◆ ShortInt()

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

Swaps a short integer value.

Parameters
bufInput short integer value to swap.

Definition at line 174 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::ProcessExport::isisOut16s(), Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().

◆ Uint32_t()

uint32_t Isis::EndianSwapper::Uint32_t ( void * buf)

Swaps a 32bit unsigned integer.

Parameters
bufInput uint32 integer value to swap.

Definition at line 130 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().

◆ UnsignedShortInt()

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

Swaps an unsigned short integer value.

Parameters
bufInput unsigned short integer value to swap.

Definition at line 197 of file EndianSwapper.cpp.

References p_needSwap, p_swapDirection, and p_swapper.

Referenced by Isis::ProcessExport::isisOut16u(), Isis::CubeIoHandler::writeIntoDouble(), and Isis::CubeIoHandler::writeIntoRaw().

◆ willSwap()

bool Isis::EndianSwapper::willSwap ( ) const
inline

Definition at line 86 of file EndianSwapper.h.

Member Data Documentation

◆ p_char

char Isis::EndianSwapper::p_char[8]

Union containing the output value in byte format.

Definition at line 72 of file EndianSwapper.h.

◆ p_double

double Isis::EndianSwapper::p_double

Union containing the output double precision value with swapped bytes.

Definition at line 57 of file EndianSwapper.h.

◆ p_float

float Isis::EndianSwapper::p_float

Union containing the output floating point value with swapped bytes.

Definition at line 59 of file EndianSwapper.h.

◆ p_int

int Isis::EndianSwapper::p_int

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

Definition at line 61 of file EndianSwapper.h.

◆ p_longLongInt

long long int Isis::EndianSwapper::p_longLongInt

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

Definition at line 63 of file EndianSwapper.h.

◆ p_needSwap

bool Isis::EndianSwapper::p_needSwap
private

Indicates whether bytes need to be swapped.

Definition at line 41 of file EndianSwapper.h.

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

◆ p_shortInt

short int Isis::EndianSwapper::p_shortInt

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

Definition at line 65 of file EndianSwapper.h.

◆ p_swapDirection

int Isis::EndianSwapper::p_swapDirection
private

Indicates which direction to increment the pointer for swapping.

(Possible values: -1,1)

Definition at line 46 of file EndianSwapper.h.

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

◆ [union]

union { ... } Isis::EndianSwapper::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.

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

◆ p_uint32

uint32_t Isis::EndianSwapper::p_uint32

Union containing the output uint32_t value with swapped bytes.

Definition at line 55 of file EndianSwapper.h.

◆ p_uShortInt

unsigned short int Isis::EndianSwapper::p_uShortInt

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

Definition at line 70 of file EndianSwapper.h.


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