00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __LESWAPS_H
00009 #define __LESWAPS_H
00010
00011 #include "LETypes.h"
00012
00018 U_NAMESPACE_BEGIN
00019
00026 #define SWAPW(value) LESwaps::swapWord((const le_uint16 &) (value))
00027
00034 #define SWAPL(value) LESwaps::swapLong((const le_uint32 &) (value))
00035
00045 class U_LAYOUT_API LESwaps {
00046 public:
00047
00058 static le_uint16 swapWord(const le_uint16 &value)
00059 {
00060 const le_uint8 *p = (const le_uint8 *) &value;
00061
00062 return ((p[0] << 8) + p[1]);
00063 };
00064
00075 static le_uint32 swapLong(const le_uint32 &value)
00076 {
00077 const le_uint8 *p = (const le_uint8 *) &value;
00078
00079 return ((p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3]);
00080 };
00081
00082 private:
00083 LESwaps() {}
00084 };
00085
00086 U_NAMESPACE_END
00087 #endif