43 #if __WIN32__ || __LINUX__
65 template<
class TYPE> TYPE
Convert(TYPE val)
const;
69 template<
class TYPE>
static TYPE
Convert(
Type fromByteOrder,
Type toByteOrder, TYPE val);
115 this->
from = fromByteOrder;
133 this->
to = toByteOrder;
148template<> __forceinline
void
151 if (fromByteOrder != toByteOrder)
161template<> __forceinline
void
164 if (this->
from != this->
to)
174template<> __forceinline
short
177 if (fromByteOrder != toByteOrder)
179 return (
short)_byteswap_ushort((
ushort)val);
190template<> __forceinline
short
193 if (this->
from != this->
to)
195 return (
short)_byteswap_ushort((
ushort)val);
206template<> __forceinline
void
209 if (fromByteOrder != toByteOrder)
211 val = _byteswap_ushort(val);
218template<> __forceinline
void
221 if (this->
from != this->
to)
223 val = _byteswap_ushort(val);
233 if (fromByteOrder != toByteOrder)
235 return _byteswap_ushort(val);
249 if (this->
from != this->
to)
251 return _byteswap_ushort(val);
262template<> __forceinline
void
265 if (fromByteOrder != toByteOrder)
267 uint res = _byteswap_ulong((
uint)val);
275template<> __forceinline
void
278 if (this->
from != this->
to)
280 uint res = _byteswap_ulong((
uint)val);
288template<> __forceinline
int
291 if (fromByteOrder != toByteOrder)
293 return (
int) _byteswap_ulong((
uint)val);
304template<> __forceinline
int
307 if (this->
from != this->
to)
309 return (
int) _byteswap_ulong((
uint)val);
320template<> __forceinline
void
323 if (fromByteOrder != toByteOrder)
325 val = _byteswap_ulong(val);
332template<> __forceinline
void
335 if (this->
from != this->
to)
337 val = _byteswap_ulong(val);
347 if (fromByteOrder != toByteOrder)
349 return _byteswap_ulong(val);
363 if (this->
from != this->
to)
365 return _byteswap_ulong(val);
376template<> __forceinline
void
379 if (fromByteOrder != toByteOrder)
383 pun.
u = _byteswap_ulong(pun.
u);
391template<> __forceinline
void
394 if (this->
from != this->
to)
398 pun.
u = _byteswap_ulong(pun.
u);
406template<> __forceinline
float
409 if (fromByteOrder != toByteOrder)
413 pun.
u = _byteswap_ulong(pun.
u);
425template<> __forceinline
float
428 if (this->
from != this->
to)
432 pun.
u = _byteswap_ulong(pun.
u);
444template<> __forceinline
void
447 if (fromByteOrder != toByteOrder)
451 pun.
u = _byteswap_uint64(pun.
u);
459template<> __forceinline
void
462 if (this->
from != this->
to)
466 pun.
u = _byteswap_uint64(pun.
u);
474template<> __forceinline
double
477 if (fromByteOrder != toByteOrder)
481 pun.
u = _byteswap_uint64(pun.
u);
493template<> __forceinline uint64_t
496 if (fromByteOrder != toByteOrder)
498 return _byteswap_uint64(val);
509template<> __forceinline int64_t
512 if (fromByteOrder != toByteOrder)
514 return _byteswap_uint64(val);
525template<> __forceinline int64_t
528 if (this->
from != this->
to)
530 return _byteswap_uint64(val);
541template<> __forceinline uint64_t
544 if (this->
from != this->
to)
546 return _byteswap_uint64(val);
557template<> __forceinline
double
560 if (this->
from != this->
to)
564 pun.
u = _byteswap_uint64(pun.
u);
577template<> __forceinline
void
578ByteOrder::ConvertInPlace<Math::vec4>(Type fromByteOrder, Type toByteOrder,
Math::vec4& val)
580 if (fromByteOrder != toByteOrder)
582 ConvertInPlace<float>(fromByteOrder, toByteOrder, val.
x);
583 ConvertInPlace<float>(fromByteOrder, toByteOrder, val.
y);
584 ConvertInPlace<float>(fromByteOrder, toByteOrder, val.
z);
585 ConvertInPlace<float>(fromByteOrder, toByteOrder, val.
w);
592template<> __forceinline
void
593ByteOrder::ConvertInPlace<Math::vec4>(
Math::vec4& val)
const
595 if (this->from != this->to)
597 ConvertInPlace<float>(val.
x);
598 ConvertInPlace<float>(val.
y);
599 ConvertInPlace<float>(val.
z);
600 ConvertInPlace<float>(val.
w);
607template<> __forceinline
void
608ByteOrder::ConvertInPlace<Math::mat4>(Type fromByteOrder, Type toByteOrder,
Math::mat4& val)
610 if (fromByteOrder != toByteOrder)
630template<> __forceinline
void
631ByteOrder::ConvertInPlace<Math::mat4>(
Math::mat4& val)
const
633 if (this->from != this->to)
(C) 2007 Radon Labs GmbH (C) 2013-2018 Individual contributors, see AUTHORS file
void SetFromByteOrder(Type fromByteOrder)
set from-byte-order
Definition byteorder.h:113
Type from
Definition byteorder.h:72
static void ConvertInPlace(Type fromByteOrder, Type toByteOrder, TYPE &val)
endian-convert in place
Type GetToByteOrder() const
get to-byte-order
Definition byteorder.h:140
void ConvertInPlace(TYPE &val) const
endian-convert in place
static TYPE Convert(Type fromByteOrder, Type toByteOrder, TYPE val)
endian-convert by copy
Type to
Definition byteorder.h:73
ByteOrder()
default constructor
Definition byteorder.h:91
Type
Definition byteorder.h:37
@ Network
Definition byteorder.h:40
@ Host
Definition byteorder.h:46
@ BigEndian
Definition byteorder.h:39
@ LittleEndian
Definition byteorder.h:38
Type GetFromByteOrder() const
get from-byte-order
Definition byteorder.h:122
void SetToByteOrder(Type toByteOrder)
set to-byte-order
Definition byteorder.h:131
TYPE Convert(TYPE val) const
endian-convert by copy
Definition osxsysfunc.h:15
__forceinline void ByteOrder::ConvertInPlace< Math::vec4 >(Type fromByteOrder, Type toByteOrder, Math::vec4 &val)
Definition byteorder.h:578
A 4x4 single point precision float matrix.
Definition mat4.h:49
vec4 row3
Definition mat4.h:138
vec4 row1
Definition mat4.h:136
vec4 row0
Definition mat4.h:135
vec4 row2
Definition mat4.h:137
A 4D vector.
Definition vec4.h:24
float y
Definition vec4.h:93
float z
Definition vec4.h:93
float w
Definition vec4.h:93
float x
Definition vec4.h:93
unsigned long ulong
Definition types.h:30
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32
Definition byteorder.h:81
unsigned long long u
Definition byteorder.h:83
double d
Definition byteorder.h:82
Definition byteorder.h:76
float f
Definition byteorder.h:77
ulong u
Definition byteorder.h:78