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-2003 - 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 
00024 
00031 #define SWAPL(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapLong(value))
00032 
00044 class U_LAYOUT_API LESwaps /* not : public UObject because all methods are static */ {
00045 public:
00046 
00058     static le_bool isBigEndian()
00059     {
00060         const le_uint16 word = 0xFF00;
00061 
00062         return *((le_uint8 *) &word);
00063     };
00064 
00075     static le_uint16 swapWord(le_uint16 value)
00076     {
00077         return (((le_uint8) (value >> 8)) | (value << 8));
00078     };
00079 
00090     static le_uint32 swapLong(le_uint32 value)
00091     {
00092         return swapWord((le_uint16) (value >> 16)) | (swapWord((le_uint16) value) << 16);
00093     };
00094 
00095 private:
00096     LESwaps() {} // private - forbid instantiation
00097 };
00098 
00099 U_NAMESPACE_END
00100 #endif

Generated on Mon Nov 24 14:35:32 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001