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

cl_endian.h

Go to the documentation of this file.
00001 /*
00002         $Id: cl_endian.h,v 1.4 2001/03/04 17:54:47 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00016 
00017 #ifndef header_endian
00018 #define header_endian
00019 
00020 class CL_Endian
00021 //: Endianess management class.
00022 // The CL_Endian class is used to convert between different endianess. There
00023 // are also a set of defines to the lazy developer:
00024 // <code>
00025 // #define SWAP_IF_BIG(i)
00026 // #define SWAP_IF_LITTLE(i)
00027 // #define SWAP_IF_BIG_ALOT(i, times)
00028 // #define SWAP_IF_LITTLE_ALOT(i, times)
00029 // #define IS_SYSTEM_64BIT()
00030 // </code>
00031 // Each of these defines call CL_Endian::is_system_big() and CL_Endian::swap.
00032 // For the exact definition of the defines, have a look in
00033 // ClanLib/Layer1/IOData/API/endian.h
00034 {
00035 public:
00036  //     static void swap(void *data, int type_size);
00037         //: Swaps the bytes between little and big endian.
00040         
00041         static void swap(void *data, int type_size, int total_times=1);
00042         //: Swaps larger amounts of data between little and big endian.
00046 
00047         static bool is_system_big();
00048         //: Returns true if big endian system.
00050 
00051         static bool is_system_64bit();
00052         //: Returns true if 64 bit system.
00054 };
00055 
00056 // Defines to the lazy developer:
00057 #define SWAP_IF_BIG(i) if (CL_Endian::is_system_big()) CL_Endian::swap(&i, sizeof(i));
00058 #define SWAP_IF_LITTLE(i) if (!CL_Endian::is_system_big()) CL_Endian::swap(&i, sizeof(i));
00059 
00060 #define SWAP_IF_BIG_ALOT(i, times) if (CL_Endian::is_system_big()) CL_Endian::swap(&i, sizeof(i), times);
00061 #define SWAP_IF_LITTLE_ALOT(i, times) if (!CL_Endian::is_system_big()) CL_Endian::swap(&i, sizeof(i), times);
00062 
00063 #define IS_SYSTEM_64BIT() CL_Endian::is_system_64bit();
00064 
00065 #endif

Generated at Wed Apr 4 19:53:59 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001