Commit 7e24d18c authored by Adam Goins's avatar Adam Goins
Browse files

Added uint32 behavior to EndianSwapper.

parent 762420a4
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -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.
   *
@@ -203,4 +225,3 @@ namespace Isis {
    return result;
  }
}
+4 −0
Original line number Diff line number Diff line
@@ -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:
@@ -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.
@@ -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);