Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

wendian.h

00001 //  Copyright (c) 1996-2001 by Autodesk, Inc.
00002 //
00003 //  By using this code, you are agreeing to the terms and conditions of
00004 //  the License Agreement included in the documentation for this code.
00005 //
00006 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00007 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00008 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00009 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00010 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00011 //
00012 //  Use, duplication, or disclosure by the U.S. Government is subject to
00013 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00014 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00015 //  Data and Computer Software), as applicable.
00016 //
00017 
00018 #if !defined ENDIAN_HEADER
00019 #define ENDIAN_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 
00023 
00024 // We could handle the endian flipping by using a "union" structure
00025 // of a word and a character array, and then use direct subscripts rather
00026 // than all the bitwise and shift operations.
00027 
00029 
00030 class WHIPTK_API WT_Endian
00031 {
00032 public:
00033 
00035     static WT_Integer16 adjust(WT_Integer16 value)
00036     {
00037 #if WD_BIGENDIAN
00038         return (   ( (value << 8) & 0xFF00) |
00039                    ( (value >> 8) & 0x00FF)    );
00040 #else
00041         return value;
00042 #endif
00043     }
00044 
00046     static WT_Unsigned_Integer16 adjust(WT_Unsigned_Integer16 value)
00047     {
00048 #if WD_BIGENDIAN
00049         return (   ( (value << 8) & 0xFF00) |
00050                    ( (value >> 8) & 0x00FF)    );
00051 #else
00052         return value;
00053 #endif
00054     }
00055 
00057     static WT_Integer32 adjust(WT_Integer32 value)
00058     {
00059 #if WD_BIGENDIAN
00060         return (   ( (value << 24) & 0xFF000000)  |
00061                    ( (value <<  8) & 0x00FF0000)  |
00062                    ( (value >>  8) & 0x0000FF00)  |
00063                    ( (value >> 24) & 0x000000FF)    );
00064 #else
00065         return value;
00066 #endif
00067     }
00068 
00070     static WT_Unsigned_Integer32 adjust(WT_Unsigned_Integer32 value)
00071     {
00072 #if WD_BIGENDIAN
00073         return (   ( (value << 24) & 0xFF000000)  |
00074                    ( (value <<  8) & 0x00FF0000)  |
00075                    ( (value >>  8) & 0x0000FF00)  |
00076                    ( (value >> 24) & 0x000000FF)    );
00077 #else
00078         return value;
00079 #endif
00080     }
00081 
00082 };
00083 
00084 #endif // ENDIAN_HEADER

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1