1 #ifndef _PFC_BYTE_ORDER_HELPER_ 2 #define _PFC_BYTE_ORDER_HELPER_ 14 enum { width =
sizeof(
T) };
16 tU in = p_source, out = 0;
17 for(
unsigned walk = 0; walk < width; ++walk) {
18 out |= ((in >> (walk * 8)) & 0xFF) << ((width - 1 - walk) * 8);
23 #ifdef _MSC_VER//does this even help with performance/size? 26 template<>
inline short byteswap_t<short>(
short p_source) {
return _byteswap_ushort(p_source);}
29 template<>
inline int byteswap_t<int>(
int p_source) {
return _byteswap_ulong(p_source);}
32 template<>
inline long byteswap_t<long>(
long p_source) {
return _byteswap_ulong(p_source);}
71 ret.
Data4[0] = p_guid.Data4[0];
72 ret.
Data4[1] = p_guid.Data4[1];
73 ret.
Data4[2] = p_guid.Data4[2];
74 ret.
Data4[3] = p_guid.Data4[3];
75 ret.
Data4[4] = p_guid.Data4[4];
76 ret.
Data4[5] = p_guid.Data4[5];
77 ret.
Data4[6] = p_guid.Data4[6];
78 ret.
Data4[7] = p_guid.Data4[7];
88 #if defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) 89 #define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 94 #if defined(__APPLE__) 95 #include <architecture/byte_order.h> 100 #if __BYTE_ORDER == __LITTLE_ENDIAN 101 #define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 103 #define PFC_BYTE_ORDER_IS_BIG_ENDIAN 1 108 #ifdef PFC_BYTE_ORDER_IS_BIG_ENDIAN 109 #define PFC_BYTE_ORDER_IS_LITTLE_ENDIAN (!(PFC_BYTE_ORDER_IS_BIG_ENDIAN)) 111 #error please update byte order #defines 125 #if PFC_BYTE_ORDER_IS_BIG_ENDIAN//big endian 141 template<
typename TInt,
unsigned w
idth,
bool IsBigEndian>
150 template<
typename TInt,
bool IsBigEndian>
157 template<
typename TInt,
bool IsBigEndian>
163 template<
typename TInt>
167 template<
typename TInt>
173 template<
typename TInt,
unsigned w
idth,
bool IsBigEndian>
181 template<
typename TInt,
bool IsBigEndian>
187 template<
typename TInt,
bool IsBigEndian>
193 template<
typename TInt>
198 template<
typename TInt>
203 template<
typename TInt>
210 template<
typename TInt>
217 template<
bool IsBigEndian,
typename TInt>
222 template<
bool IsBigEndian,
typename TInt>
230 template<
unsigned w
idth>
wchar_t byteswap_t< wchar_t >(wchar_t p_source)
int byteswap_t< int >(int p_source)
void encode_little_endian(t_uint8 *p_buffer, TInt p_value)
static const bool byte_order_is_little_endian
void reverse_bytes< 1 >(t_uint8 *p_buffer)
void byteswap_raw(void *p_buffer, t_size p_bytes)
T byteswap_if_le_t(T p_param)
void reverse_bytes< 0 >(t_uint8 *p_buffer)
signed char byteswap_t< signed char >(signed char p_source)
void decode_big_endian(TInt &p_out, const t_uint8 *p_buffer)
void order_native_to_le_t(T ¶m)
double byteswap_t< double >(double p_source)
static TInt Run(const t_uint8 *)
void decode_little_endian(TInt &p_out, const t_uint8 *p_buffer)
static const bool byte_order_is_big_endian
void order_be_to_native_t(T ¶m)
static void Run(TInt, t_uint8 *)
unsigned short byteswap_t< unsigned short >(unsigned short p_source)
short byteswap_t< short >(short p_source)
unsigned char byteswap_t< unsigned char >(unsigned char p_source)
static void Run(TInt p_value, t_uint8 *p_out)
void reverse_bytes(t_uint8 *p_buffer)
void order_le_to_native_t(T ¶m)
static TInt Run(const t_uint8 *p_in)
char byteswap_t< char >(char p_source)
unsigned long long byteswap_t< unsigned long long >(unsigned long long p_source)
long long byteswap_t< long long >(long long p_source)
void encode_endian(t_uint8 *p_buffer, TInt p_in)
static void Run(TInt p_value, t_uint8 *p_out)
void encode_big_endian(t_uint8 *p_buffer, TInt p_value)
unsigned int byteswap_t< unsigned int >(unsigned int p_source)
void decode_endian(TInt &p_out, const t_uint8 *p_buffer)
T byteswap_int_t(T p_source)
unsigned long byteswap_t< unsigned long >(unsigned long p_source)
long byteswap_t< long >(long p_source)
GUID byteswap_t< GUID >(GUID p_guid)
void swap_t(T &p_item1, T &p_item2)
float byteswap_t< float >(float p_source)
static TInt Run(const t_uint8 *p_in)
T byteswap_if_be_t(T p_param)
void order_native_to_be_t(T ¶m)