From 6bb5e165cfd354b1e170ba464c86bb6ac501eb54 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 27 Feb 2018 19:13:18 +0100 Subject: [PATCH] qrtplib: added missing file --- qrtplib/rtpendian.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 qrtplib/rtpendian.h diff --git a/qrtplib/rtpendian.h b/qrtplib/rtpendian.h new file mode 100644 index 000000000..9c03534d4 --- /dev/null +++ b/qrtplib/rtpendian.h @@ -0,0 +1,39 @@ +/* + * rtpendian.h + * + * Created on: Feb 27, 2018 + * Author: f4exb + */ + +#ifndef QRTPLIB_RTPENDIAN_H_ +#define QRTPLIB_RTPENDIAN_H_ + +#include + +namespace qrtplib +{ + +class RTPEndian +{ +public: + RTPEndian() + { + uint32_t endianTest32 = 1; + uint8_t *ptr = (uint8_t*) &endianTest32; + m_isLittleEndian = (*ptr == 1); + } + + template + T qToHost(const T& x) const { + return m_isLittleEndian ? qToLittleEndian(x) : qToBigEndian(x); + } + +private: + bool m_isLittleEndian; +}; + +} + + + +#endif /* QRTPLIB_RTPENDIAN_H_ */