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, 2001, 2002 - 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 
00022 #define SWAPW(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapWord(value))
00023 #define SWAPL(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapLong(value))
00024 
00036 class LESwaps /* not : public UObject because all methods are static */ {
00037 public:
00038 
00050     static le_bool isBigEndian()
00051     {
00052         static const le_uint16 word = 0xFF00;
00053 
00054         return *((le_uint8 *) &word);
00055     };
00056 
00067     static le_uint16 swapWord(le_uint16 value)
00068     {
00069         return (((le_uint8) (value >> 8)) | (value << 8));
00070     };
00071 
00082     static le_uint32 swapLong(le_uint32 value)
00083     {
00084         return swapWord((le_uint16) (value >> 16)) | (swapWord((le_uint16) value) << 16);
00085     };
00086 
00087 private:
00088     LESwaps() {} // private - forbid instantiation
00089 };
00090 
00091 U_NAMESPACE_END
00092 #endif

Generated on Thu Aug 15 14:13:26 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001