Loading isis/src/base/objs/EndianSwapper/EndianSwapper.cpp +22 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,28 @@ namespace Isis { return result; } /** * Swaps a 32bit unsigned integer. * * @param buf Input uint32 integer value to swap. */ uint32_t EndianSwapper::Uint32_t(void *buf) { uint32_t result = *(uint32_t *)buf; if(p_needSwap) { char *ptr = (char *)buf + (sizeof(uint32_t) - 1) * p_needSwap; for(unsigned int i = 0; i < sizeof(uint32_t); i++) { p_swapper.p_char[i] = *ptr; ptr += p_swapDirection; } result = p_swapper.p_uint32; } return result; } /** * Swaps an 8 byte integer value. * Loading Loading @@ -203,4 +225,3 @@ namespace Isis { return result; } } isis/src/base/objs/EndianSwapper/EndianSwapper.h +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ namespace Isis { * not added because it is 4 bytes on 32-bit linux and 8 bytes on * 64-bit linux. * @history 2016-04-21 Makayla Shepherd - Added UnsignedWord pixel type handling. * @history 2018-01-29 Adam Goins - Added uint32_t behavior to EndianSwapper. */ class EndianSwapper { private: Loading @@ -67,6 +68,8 @@ namespace Isis { * byte format - all with swapped bytes. */ union { //! Union containing the output uint32_t value with swapped bytes. uint32_t p_uint32; //! Union containing the output double precision value with swapped bytes. double p_double; //! Union containing the output floating point value with swapped bytes. Loading @@ -93,6 +96,7 @@ namespace Isis { float Float(void *buf); int ExportFloat(void *buf); int Int(void *buf); uint32_t Uint32_t(void *buf); long long int LongLongInt(void *buf); short int ShortInt(void *buf); unsigned short int UnsignedShortInt(void *buf); Loading isis/src/base/objs/EndianSwapper/EndianSwapper.truth +1 −0 Original line number Diff line number Diff line Size of Double: 8 Double 0x12345678 to HOST: 3.0542e+08 Size of Float: 4 Float 0x1234 to HOST: 4660 Size of Uint32_t: 4 Uint32_t 0x1234 to HOST: 4660 Size of Short Int: 2 Short Int 0x1234 to HOST: 4660 Size of Unsigned Short Int: 2 Unsigned Short Int 0x1234 to HOST: 4660 Size of Double: 8 Double 0x12345678 to HOST: 2.55354e-312 Loading isis/src/base/objs/EndianSwapper/unitTest.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ int main(int argc, char *argv[]) { double DoubleValue; float FloatValue; uint32_t UIntValue; short int ShortIntValue; unsigned short int UShortIntValue; int IntValue; Loading @@ -19,6 +20,7 @@ int main(int argc, char *argv[]) { DoubleValue = 0x12345678; FloatValue = 0x1234; UIntValue = 0x1234; ShortIntValue = 0x1234; UShortIntValue = 0x1234; IntValue = 0x12345678; Loading @@ -30,6 +32,8 @@ int main(int argc, char *argv[]) { cout << " Double 0x12345678 to HOST: " << lsb.Double(&DoubleValue) << endl; cout << "Size of Float: " << sizeof(float); cout << " Float 0x1234 to HOST: " << lsb.Float(&FloatValue) << endl; cout << "Size of Uint32_t: " << sizeof(uint32_t); cout << " Uint32_t 0x1234 to HOST: " << lsb.Uint32_t(&UIntValue) << endl; cout << "Size of Short Int: " << sizeof(short int); cout << " Short Int 0x1234 to HOST: " << lsb.ShortInt(&ShortIntValue) << endl; cout << "Size of Unsigned Short Int: " << sizeof(unsigned short int); Loading Loading @@ -74,6 +78,8 @@ int main(int argc, char *argv[]) { cout << " Double 0x12345678 to HOST: " << msb.Double(&DoubleValue) << endl; cout << "Size of Float: " << sizeof(float); cout << " Float 0x1234 to HOST: " << msb.Float(&FloatValue) << endl; cout << "Size of Uint32_t: " << sizeof(uint32_t); cout << " Uint32_t 0x1234 to HOST: " << msb.Uint32_t(&UIntValue) << endl; cout << "Size of Short Int: " << sizeof(short int); cout << " Short Int 0x1234 to HOST: " << msb.ShortInt(&ShortIntValue) << endl; cout << "Size of Unsigned Short Int: " << sizeof(unsigned short int); Loading isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include "ControlNet.h" #include "ControlMeasureLogData.h" #include "Distance.h" #include "EndianSwapper.h" #include "FileName.h" #include "IException.h" #include "Latitude.h" Loading Loading @@ -1249,6 +1250,7 @@ namespace Isis { progress->CheckStatus(); } Isis::EndianSwapper lsb("LSB"); int pointIndex = -1; while (pointInStream.ByteCount() < pointsLength) { pointIndex += 1; Loading @@ -1263,6 +1265,8 @@ namespace Isis { uint32_t size; pointCodedInStream.ReadRaw(reinterpret_cast<char *>(&size), sizeof(size)); size = lsb.Uint32_t(&size); CodedInputStream::Limit oldPointLimit = pointCodedInStream.PushLimit(size); newPoint->ParseFromCodedStream(&pointCodedInStream); pointCodedInStream.PopLimit(oldPointLimit); Loading Loading @@ -2069,6 +2073,10 @@ namespace Isis { } uint32_t byteSize = protoPoint.ByteSize(); Isis::EndianSwapper lsb("LSB"); byteSize = lsb.Uint32_t(&byteSize); output->write(reinterpret_cast<char *>(&byteSize), sizeof(byteSize)); if ( !protoPoint.SerializeToOstream(output) ) { Loading Loading
isis/src/base/objs/EndianSwapper/EndianSwapper.cpp +22 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,28 @@ namespace Isis { return result; } /** * Swaps a 32bit unsigned integer. * * @param buf Input uint32 integer value to swap. */ uint32_t EndianSwapper::Uint32_t(void *buf) { uint32_t result = *(uint32_t *)buf; if(p_needSwap) { char *ptr = (char *)buf + (sizeof(uint32_t) - 1) * p_needSwap; for(unsigned int i = 0; i < sizeof(uint32_t); i++) { p_swapper.p_char[i] = *ptr; ptr += p_swapDirection; } result = p_swapper.p_uint32; } return result; } /** * Swaps an 8 byte integer value. * Loading Loading @@ -203,4 +225,3 @@ namespace Isis { return result; } }
isis/src/base/objs/EndianSwapper/EndianSwapper.h +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ namespace Isis { * not added because it is 4 bytes on 32-bit linux and 8 bytes on * 64-bit linux. * @history 2016-04-21 Makayla Shepherd - Added UnsignedWord pixel type handling. * @history 2018-01-29 Adam Goins - Added uint32_t behavior to EndianSwapper. */ class EndianSwapper { private: Loading @@ -67,6 +68,8 @@ namespace Isis { * byte format - all with swapped bytes. */ union { //! Union containing the output uint32_t value with swapped bytes. uint32_t p_uint32; //! Union containing the output double precision value with swapped bytes. double p_double; //! Union containing the output floating point value with swapped bytes. Loading @@ -93,6 +96,7 @@ namespace Isis { float Float(void *buf); int ExportFloat(void *buf); int Int(void *buf); uint32_t Uint32_t(void *buf); long long int LongLongInt(void *buf); short int ShortInt(void *buf); unsigned short int UnsignedShortInt(void *buf); Loading
isis/src/base/objs/EndianSwapper/EndianSwapper.truth +1 −0 Original line number Diff line number Diff line Size of Double: 8 Double 0x12345678 to HOST: 3.0542e+08 Size of Float: 4 Float 0x1234 to HOST: 4660 Size of Uint32_t: 4 Uint32_t 0x1234 to HOST: 4660 Size of Short Int: 2 Short Int 0x1234 to HOST: 4660 Size of Unsigned Short Int: 2 Unsigned Short Int 0x1234 to HOST: 4660 Size of Double: 8 Double 0x12345678 to HOST: 2.55354e-312 Loading
isis/src/base/objs/EndianSwapper/unitTest.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ int main(int argc, char *argv[]) { double DoubleValue; float FloatValue; uint32_t UIntValue; short int ShortIntValue; unsigned short int UShortIntValue; int IntValue; Loading @@ -19,6 +20,7 @@ int main(int argc, char *argv[]) { DoubleValue = 0x12345678; FloatValue = 0x1234; UIntValue = 0x1234; ShortIntValue = 0x1234; UShortIntValue = 0x1234; IntValue = 0x12345678; Loading @@ -30,6 +32,8 @@ int main(int argc, char *argv[]) { cout << " Double 0x12345678 to HOST: " << lsb.Double(&DoubleValue) << endl; cout << "Size of Float: " << sizeof(float); cout << " Float 0x1234 to HOST: " << lsb.Float(&FloatValue) << endl; cout << "Size of Uint32_t: " << sizeof(uint32_t); cout << " Uint32_t 0x1234 to HOST: " << lsb.Uint32_t(&UIntValue) << endl; cout << "Size of Short Int: " << sizeof(short int); cout << " Short Int 0x1234 to HOST: " << lsb.ShortInt(&ShortIntValue) << endl; cout << "Size of Unsigned Short Int: " << sizeof(unsigned short int); Loading Loading @@ -74,6 +78,8 @@ int main(int argc, char *argv[]) { cout << " Double 0x12345678 to HOST: " << msb.Double(&DoubleValue) << endl; cout << "Size of Float: " << sizeof(float); cout << " Float 0x1234 to HOST: " << msb.Float(&FloatValue) << endl; cout << "Size of Uint32_t: " << sizeof(uint32_t); cout << " Uint32_t 0x1234 to HOST: " << msb.Uint32_t(&UIntValue) << endl; cout << "Size of Short Int: " << sizeof(short int); cout << " Short Int 0x1234 to HOST: " << msb.ShortInt(&ShortIntValue) << endl; cout << "Size of Unsigned Short Int: " << sizeof(unsigned short int); Loading
isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include "ControlNet.h" #include "ControlMeasureLogData.h" #include "Distance.h" #include "EndianSwapper.h" #include "FileName.h" #include "IException.h" #include "Latitude.h" Loading Loading @@ -1249,6 +1250,7 @@ namespace Isis { progress->CheckStatus(); } Isis::EndianSwapper lsb("LSB"); int pointIndex = -1; while (pointInStream.ByteCount() < pointsLength) { pointIndex += 1; Loading @@ -1263,6 +1265,8 @@ namespace Isis { uint32_t size; pointCodedInStream.ReadRaw(reinterpret_cast<char *>(&size), sizeof(size)); size = lsb.Uint32_t(&size); CodedInputStream::Limit oldPointLimit = pointCodedInStream.PushLimit(size); newPoint->ParseFromCodedStream(&pointCodedInStream); pointCodedInStream.PopLimit(oldPointLimit); Loading Loading @@ -2069,6 +2073,10 @@ namespace Isis { } uint32_t byteSize = protoPoint.ByteSize(); Isis::EndianSwapper lsb("LSB"); byteSize = lsb.Uint32_t(&byteSize); output->write(reinterpret_cast<char *>(&byteSize), sizeof(byteSize)); if ( !protoPoint.SerializeToOstream(output) ) { Loading