Skip to content

Commit

Permalink
use std::endian
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Jun 30, 2023
1 parent 8528744 commit 84e45a3
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

// + standard includes
#include <array>
#include <bit>
#include <cstdio>
#include <cstring>
#include <limits>
Expand Down Expand Up @@ -168,23 +169,11 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) {
}

bool Image::isBigEndianPlatform() {
#if defined(__BYTE_ORDER)
#if __BYTE_ORDER == __BIG_ENDIAN
return true;
#else
return false;
#endif
#else
union {
uint32_t i;
char c[4];
} e = {0x01000000};

return e.c[0] != 0;
#endif
return std::endian::native == std::endian::big;
}

bool Image::isLittleEndianPlatform() {
return !isBigEndianPlatform();
return std::endian::native == std::endian::little;
}

uint64_t Image::byteSwap(uint64_t value, bool bSwap) {
Expand Down

0 comments on commit 84e45a3

Please sign in to comment.