Isis Developer Reference
EndianSwapper.h
Go to the documentation of this file.
1 #ifndef EndianSwapper_h
2 #define EndianSwapper_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include "IException.h"
11 
12 namespace Isis {
13 
38  class EndianSwapper {
39  private:
41  bool p_needSwap;
46  int p_swapDirection;
47 
53  union {
55  uint32_t p_uint32;
57  double p_double;
59  float p_float;
61  int p_int;
63  long long int p_longLongInt;
65  short int p_shortInt;
70  unsigned short int p_uShortInt;
72  char p_char[8];
73  } p_swapper;
74 
75  public:
76  EndianSwapper(QString inputEndian);
78  double Double(void *buf);
79  float Float(void *buf);
80  int ExportFloat(void *buf);
81  int Int(void *buf);
82  uint32_t Uint32_t(void *buf);
83  long long int LongLongInt(void *buf);
84  short int ShortInt(void *buf);
85  unsigned short int UnsignedShortInt(void *buf);
86  bool willSwap() const {
87  return p_needSwap;
88  }
89  };
90 };
91 
92 #endif
Isis::EndianSwapper::Float
float Float(void *buf)
Swaps a floating point value.
Definition: EndianSwapper.cpp:78
Isis::EndianSwapper::p_double
double p_double
Union containing the output double precision value with swapped bytes.
Definition: EndianSwapper.h:57
Isis::EndianSwapper::UnsignedShortInt
unsigned short int UnsignedShortInt(void *buf)
Swaps an unsigned short integer value.
Definition: EndianSwapper.cpp:197
Isis::EndianSwapper::p_float
float p_float
Union containing the output floating point value with swapped bytes.
Definition: EndianSwapper.h:59
Isis::EndianSwapper::Uint32_t
uint32_t Uint32_t(void *buf)
Swaps a 32bit unsigned integer.
Definition: EndianSwapper.cpp:130
Isis::IsLsb
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
Definition: Endian.h:67
Isis::EndianSwapper::p_uShortInt
unsigned short int p_uShortInt
Union containing the output unsigned short integer value with swapped bytes.
Definition: EndianSwapper.h:70
Isis::EndianSwapper::willSwap
bool willSwap() const
Definition: EndianSwapper.h:86
Isis::EndianSwapper::~EndianSwapper
~EndianSwapper()
Destroys the EndianSwapper object.
Definition: EndianSwapper.cpp:46
Isis::EndianSwapper::ExportFloat
int ExportFloat(void *buf)
Swaps a floating point value for Exporting.
Definition: EndianSwapper.cpp:99
Isis::EndianSwapper::ShortInt
short int ShortInt(void *buf)
Swaps a short integer value.
Definition: EndianSwapper.cpp:174
Endian.h
Isis::IsMsb
bool IsMsb()
Return true if this host is an MSB first machine and false if it is not.
Definition: Endian.h:83
Isis::Double
@ Double
Definition: PixelType.h:36
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
EndianSwapper.h
Isis::EndianSwapper::EndianSwapper
EndianSwapper(QString inputEndian)
Constructs an EndianSwapper object, determining whether swapping of bytes actually needs to occur and...
Definition: EndianSwapper.cpp:23
Isis::EndianSwapper::p_char
char p_char[8]
Union containing the output value in byte format.
Definition: EndianSwapper.h:72
Isis::EndianSwapper::p_int
int p_int
Union containing the output 4 byte integer value with swapped bytes.
Definition: EndianSwapper.h:61
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::EndianSwapper::Int
int Int(void *buf)
Swaps a 4 byte integer value.
Definition: EndianSwapper.cpp:108
IException.h
std
Namespace for the standard library.
Isis::EndianSwapper::p_longLongInt
long long int p_longLongInt
Union containing the output 8 byte integer value with swapped bytes.
Definition: EndianSwapper.h:63
Isis::EndianSwapper::LongLongInt
long long int LongLongInt(void *buf)
Swaps an 8 byte integer value.
Definition: EndianSwapper.cpp:152
Isis::EndianSwapper
Byte swapper.
Definition: EndianSwapper.h:38
Isis::EndianSwapper::p_uint32
uint32_t p_uint32
Union containing the output uint32_t value with swapped bytes.
Definition: EndianSwapper.h:55
Isis::EndianSwapper::Double
double Double(void *buf)
Swaps a double precision value.
Definition: EndianSwapper.cpp:55
Isis::EndianSwapper::p_shortInt
short int p_shortInt
Union containing the output 2 byte integer value with swapped bytes.
Definition: EndianSwapper.h:65
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Message.h