1 /* 2 * Copyright 2010-2019 Branimir Karadzic. All rights reserved. 3 * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 */ 5 6 #ifndef BX_ENDIAN_H_HEADER_GUARD 7 #define BX_ENDIAN_H_HEADER_GUARD 8 9 #include "bx.h" 10 11 namespace bx 12 { 13 /// 14 int16_t endianSwap(int16_t _in); 15 16 /// 17 uint16_t endianSwap(uint16_t _in); 18 19 /// 20 int32_t endianSwap(int32_t _in); 21 22 /// 23 uint32_t endianSwap(uint32_t _in); 24 25 /// 26 int64_t endianSwap(int64_t _in); 27 28 /// 29 uint64_t endianSwap(uint64_t _in); 30 31 /// Input argument is encoded as little endian, convert it if neccessary 32 /// depending on host CPU endianess. 33 template <typename Ty> 34 Ty toLittleEndian(const Ty _in); 35 36 /// Input argument is encoded as big endian, convert it if neccessary 37 /// depending on host CPU endianess. 38 template <typename Ty> 39 Ty toBigEndian(const Ty _in); 40 41 /// If _littleEndian is true, converts input argument to from little endian 42 /// to host CPU endiness. 43 template <typename Ty> 44 Ty toHostEndian(const Ty _in, bool _fromLittleEndian); 45 46 } // namespace bx 47 48 #include "inline/endian.inl" 49 50 #endif // BX_ENDIAN_H_HEADER_GUARD 51