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

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 
00018 #define SWAPW(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapWord(value))
00019 #define SWAPL(value) (LESwaps::isBigEndian() ? (value) : LESwaps::swapLong(value))
00020 
00030 class LESwaps
00031 {
00032 public:
00033 
00043     static le_bool isBigEndian()
00044     {
00045         static le_uint16 word = 0xFF00;
00046         static le_uint8 *byte = (le_uint8 *) &word;
00047 
00048         return *byte;
00049     };
00050 
00059     static le_uint16 swapWord(le_uint16 value)
00060     {
00061         return (((le_uint8) (value >> 8)) | (value << 8));
00062     };
00063 
00072     static le_uint32 swapLong(le_uint32 value)
00073     {
00074         return swapWord((le_uint16) (value >> 16)) | (swapWord((le_uint16) value) << 16);
00075     };
00076 };
00077 
00078 #endif

Generated at Tue Jun 12 14:03:57 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000