Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

LESwaps.h

Go to the documentation of this file.
00001 
00002 /*
00003  * @(#)LESwaps.h        1.3 00/03/15
00004  *
00005  * (C) Copyright IBM Corp. 1998, 1999, 2000 - All Rights Reserved
00006  *
00007  */
00008 
00009 #ifndef __LESWAPS_H
00010 #define __LESWAPS_H
00011 
00012 #include "LETypes.h"
00013 
00014 U_NAMESPACE_BEGIN
00015 
00020 #define SWAPW(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapWord(value))
00021 #define SWAPL(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapLong(value))
00022 
00032 class LESwaps
00033 {
00034 public:
00035 
00045     static le_bool isBigEndian()
00046     {
00047         static le_uint16 word = 0xFF00;
00048         static le_uint8 *byte = (le_uint8 *) &word;
00049 
00050         return *byte;
00051     };
00052 
00061     static le_uint16 swapWord(le_uint16 value)
00062     {
00063         return (((le_uint8) (value >> 8)) | (value << 8));
00064     };
00065 
00074     static le_uint32 swapLong(le_uint32 value)
00075     {
00076         return swapWord((le_uint16) (value >> 16)) | (swapWord((le_uint16) value) << 16);
00077     };
00078 };
00079 
00080 U_NAMESPACE_END
00081 #endif

Generated on Mon Dec 3 19:00:21 2001 for ICU 2.0 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001