2#ifndef DARWIN_DARWINBYTEORDER_H
3#define DARWIN_DARWINBYTEORDER_H
12#include <libkern/OSByteOrder.h>
47 template<
class TYPE>
void Convert(TYPE& val)
const;
82 this->
from = fromByteOrder;
100 this->
to = toByteOrder;
115template<> __forceinline
void
118 if (this->
from != this->
to)
128template<> __forceinline
void
131 if (this->
from != this->
to)
133 val = OSSwapInt16(val);
140template<> __forceinline
void
143 if (this->
from != this->
to)
145 uint res = OSSwapInt32(*(
uint*)&val);
153template<> __forceinline
void
156 if (this->
from != this->
to)
158 val = OSSwapInt32(val);
165template<> __forceinline
void
168 if (this->
from != this->
to)
170 uint res = OSSwapInt32(*(
uint*)&val);
178template<> __forceinline
void
181 if (this->
from != this->
to)
183 unsigned long long res = OSSwapInt64(*(
unsigned long long*)&val);
184 val = *(
double*)&res;
191template<> __forceinline
void
192ByteOrder::Convert<Math::float4>(
Math::float4& val)
const
194 if (this->from != this->to)
196 Convert<float>(val.
x());
197 Convert<float>(val.
y());
198 Convert<float>(val.
z());
199 Convert<float>(val.
w());
206template<> __forceinline
void
207ByteOrder::Convert<Math::matrix44>(Math::matrix44& val)
const
209 if (this->from != this->to)
Provides information and methods to help with byte ordering issues.
Definition darwinbyteorder.h:18
void SetFromByteOrder(Type fromByteOrder)
set from-byte-order
Definition byteorder.h:113
ByteOrder()
default constructor
Type from
Definition byteorder.h:72
void Convert(TYPE &val) const
endian-convert in place
Type GetToByteOrder() const
get to-byte-order
Definition byteorder.h:140
void SetToByteOrder(Type toByteOrder)
set to-byte-order
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
ByteOrder(Type fromByteOrder, Type toByteOrder)
constructor: set byte order conversion rule
void SetFromByteOrder(Type fromByteOrder)
set from-byte-order
void SetToByteOrder(Type toByteOrder)
set to-byte-order
Definition byteorder.h:131
TYPE Convert(TYPE val) const
endian-convert by copy
Type GetToByteOrder() const
get to-byte-order
Type GetFromByteOrder() const
get from-byte-order
Definition osxsysfunc.h:15
__forceinline void ByteOrder::Convert< Math::float4 >(Math::float4 &val) const
Definition darwinbyteorder.h:192
scalar x
Definition scalar.h:79
scalar y
Definition scalar.h:79
scalar w
Definition scalar.h:79
scalar z
Definition scalar.h:79
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32